# Example script for sign restrictions in gretl's SVAR addon ### ### example with exotic restrictions ### set verbose off include SVAR.gfn ### supply & demand (artificial example) nulldata 240 setobs 12 1:1 set seed 123123 b = -0.8 # demand elasticity c = 1.1 # supply elasticity # create artificial data 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 # set up the model list W = const scalar order = 1 bundle mod = SVAR_setup("SR", X, W, order) ## set up the sign restictions mod.snames[1] = "Supply" mod.snames[2] = "Demand" # instantaneous restrictions 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 pushes price up SVAR_SRplain(&mod, "q", "Demand", "+") # demand shock effect on quantity is pos. # Now try an an "exotic" restriction -- be sure to read the documentation! # Assumption: supply and demand price elasticities should be # "about the same" up to lag 4 exostring = "(-M[1,1]/M[1,2] > 0.67) && (-M[1,1]/M[1,2] < 1.5)" SVAR_SRexotic(&mod, exostring, defarray("Supply", "Demand"), 4) # Supply = shock 1 # do the rotations (this is the computationally intensive part) SVAR_SRdraw(&mod, 100, 0) # look at the IRFs as a check loop i = 1..10 loop t = 1..5 printf "M[%d] =\n%6.3f\n", t, mod.acc_draws[i].irfs[t] endloop print "" endloop