Debian Codegraph @

addons/SVAR/examples/SetRestrictions/exotic1.inp

raw
1 # Example script for sign restrictions in gretl's SVAR addon
2
3 ###
4 ### example with exotic restrictions
5 ###
6
7 set verbose off
8 include SVAR.gfn
9
10 ### supply & demand (artificial example)
11
12 nulldata 240
13 setobs 12 1:1
14 set seed 123123
15
16 b = -0.8 # demand elasticity
17 c = 1.1 # supply elasticity
18
19 Gamma = {1, -c; -b, 1}
20 iG = inv(Gamma)
21 U = 3 + filter(mnormal($nobs, 2), 1, 0.8)
22 Y = U * iG'
23 series p = Y[,1]
24 series q = Y[,2]
25 list X = p q
26
27 # set up the model
28
29 list W = const
30 scalar order = 1
31
32 bundle mod = SVAR_setup("SR", X, W, order)
33
34 # set up the sign restictions
35 mod.snames[1] = "Supply"
36 mod.snames[2] = "Demand"
37
38 # instantaneous restrictions
39
40 SVAR_SRplain(&mod, "p", "Supply", "-") # supply shock brings price down
41 SVAR_SRplain(&mod, "q", "Supply", "+") # and quantity up
42 SVAR_SRplain(&mod, "p", "Demand", "+") # demand shock pushes price up
43
44 try_exotic = 1
45
46 if try_exotic
47 # the effect of the demand shock on quantity is given in the form
48 # of an "exotic" restriction specification (just for illustration)
49 SVAR_SRexotic(&mod, "M[2,2] > 0", defarray("Demand"))
50 else
51 SVAR_SRplain(&mod, "q", "Demand", "+") # demand shock effect on quantity is pos.
52 endif
53
54 # do the rotations (this is the computationally intensive part)
55 SVAR_SRdraw(&mod, 100)
56
57 # check: these matrices should be the same if try_exotic is
58 # 0 or 1
59 loop i = 1..10
60 printf "%6.3f\n", mod.acc_draws[i].irfs[1]
61 endloop