Debian Codegraph @

addons/SVAR/examples/SetRestrictions/supply_demand.inp

raw
1 # Example script for sign restrictions in gretl's SVAR addon
2
3 set verbose off
4 set seed 1007241513
5
6 include SVAR.gfn
7
8 ### supply & demand (artificial example)
9
10 nulldata 240
11 setobs 12 1:1
12 b = -0.8 # demand elasticity
13 c = 1.1 # supply elasticity
14
15 # simulate data via the reduced form
16 Gamma = {1, -c; -b, 1}
17 iG = inv(Gamma)
18 U = 3 + filter(mnormal($nobs, 2), 1, 0.8)
19 Y = U * iG'
20 series p = Y[,1]
21 series q = Y[,2]
22 list X = p q
23
24 # estimate the reduced form via built-in command and check that
25 # the estimated sigma si close to the true one
26
27 var 1 X --quiet
28 eval $sigma
29 eval iG*iG'
30
31 # set up the model
32
33 list W = const
34 scalar order = 1
35
36 bundle mod = SVAR_setup("SR", X, W, order, 0) # 0: don't store all accepted draws
37
38 # set up the sign restictions
39
40 mod.snames[1] = "Supply"
41 mod.snames[2] = "Demand"
42
43 # instantaneous restrictions
44
45 mod.SRest = {}
46 SVAR_SRplain(&mod, "p", "Supply", "-") # supply shock brings price down
47 SVAR_SRplain(&mod, "q", "Supply", "+") # and quantity up
48 SVAR_SRplain(&mod, "p", "Demand", "+") # demand shock raises price
49 SVAR_SRplain(&mod, "q", "Demand", "+") # as well as quantity
50
51
52 # do the rotations (this is the computationally intensive part)
53 SVAR_SRdraw(&mod, 1000) # (with default coverage 90%)
54
55 # draw the irfs
56 SVAR_SRirf(mod, mod.Ynames, defarray("Supply","Demand"))