Debian Codegraph @

addons/SVAR/examples/SetRestrictions/exotic2.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 # create artificial data
20
21 Gamma = {1, -c; -b, 1}
22 iG = inv(Gamma)
23 U = 3 + filter(mnormal($nobs, 2), 1, 0.8)
24 Y = U * iG'
25 series p = Y[,1]
26 series q = Y[,2]
27 list X = p q
28
29 # set up the model
30
31 list W = const
32 scalar order = 1
33
34 bundle mod = SVAR_setup("SR", X, W, order)
35
36 ## set up the sign restictions
37
38 mod.snames[1] = "Supply"
39 mod.snames[2] = "Demand"
40
41 # instantaneous restrictions
42
43 SVAR_SRplain(&mod, "p", "Supply", "-") # supply shock brings price down
44 SVAR_SRplain(&mod, "q", "Supply", "+") # and quantity up
45 SVAR_SRplain(&mod, "p", "Demand", "+") # demand shock pushes price up
46 SVAR_SRplain(&mod, "q", "Demand", "+") # demand shock effect on quantity is pos.
47
48 # Now try an an "exotic" restriction -- be sure to read the documentation!
49 # Assumption: supply and demand price elasticities should be
50 # "about the same" up to lag 4
51
52 exostring = "(-M[1,1]/M[1,2] > 0.67) && (-M[1,1]/M[1,2] < 1.5)"
53 SVAR_SRexotic(&mod, exostring, defarray("Supply", "Demand"), 4) # Supply = shock 1
54
55 # do the rotations (this is the computationally intensive part)
56 SVAR_SRdraw(&mod, 100, 0)
57
58 # look at the IRFs as a check
59
60 loop i = 1..10
61 loop t = 1..5
62 printf "M[%d] =\n%6.3f\n", t, mod.acc_draws[i].irfs[t]
63 endloop
64 print ""
65 endloop