# Example script for sign restrictions in gretl's SVAR addon set verbose off set seed 1007241513 include SVAR.gfn ### supply & demand (artificial example) nulldata 240 setobs 12 1:1 b = -0.8 # demand elasticity c = 1.1 # supply elasticity # simulate data via the reduced form Gamma = {1, -c; -b, 1} iG = inv(Gamma) U = 3 + filter(mnormal($nobs, 2), 1, 0.8) Y = U * iG' series p = Y[,1] series q = Y[,2] list X = p q # estimate the reduced form via built-in command and check that # the estimated sigma si close to the true one var 1 X --quiet eval $sigma eval iG*iG' # set up the model list W = const scalar order = 1 bundle mod = SVAR_setup("SR", X, W, order, 0) # 0: don't store all accepted draws # set up the sign restictions mod.snames[1] = "Supply" mod.snames[2] = "Demand" # instantaneous restrictions mod.SRest = {} SVAR_SRplain(&mod, "p", "Supply", "-") # supply shock brings price down SVAR_SRplain(&mod, "q", "Supply", "+") # and quantity up SVAR_SRplain(&mod, "p", "Demand", "+") # demand shock raises price SVAR_SRplain(&mod, "q", "Demand", "+") # as well as quantity # do the rotations (this is the computationally intensive part) SVAR_SRdraw(&mod, 1000) # (with default coverage 90%) # draw the irfs SVAR_SRirf(mod, mod.Ynames, defarray("Supply","Demand"))