# Example script for sign restrictions in gretl's SVAR addon set verbose off set seed 909090 include SVAR.gfn ### ### --- Uhlig (2005) example ### # data handling open UhligData.gdt --quiet --frompkg=SVAR series y = 100 * log(RealGDP) series p = 100 * log(CPI) series cp = 100 * log(CommodityPrice) series r = FedFund #<- Monetary policy shock # Non-borrowed reserves are bank reserves—that is, # the funds a financial institution holds in cash—that are its own, # and not money on loan from a central bank. series nbr = 100 * log(NonBorrReserves) series res = 100 * log(TotalReserves) # To identify the impulse vector corresponding to monetary policy shocks, # I impose that a contractionary policy shock does not lead to an increase in # prices or in nonborrowed reserves and does not lead to a decrease in the federal # set up the model list X = y p cp r nbr res list Z = const scalar order = 12 bundle mod = SVAR_setup("plain", X, Z, order) mod.horizon = 60 mod.snames[4] = "Monetary" err = SVAR_estimate(&mod,0) # replicate page 395 (sort of) if 0 bfail = SVAR_boot(&mod, 1024, 0.63) loop i=1..6 --quiet IRFplot(&mod, 4, i) endloop endif # Switch to a sign restriction model, but re-using the # reduced-form results from above # (and also the first three Cholesky-based shocks ?! /* Above the shock #4 is labeled Monetary, and below some sign restrictions are given for it, and no other shock. */ mod.type = 10 # (10 is internal code for SR) # set up the sign restictions SVAR_SRplain(&mod, "p", "Monetary", "-", 5) # negative from 0 to 5 SVAR_SRplain(&mod, "nbr", "Monetary", "-", 5) # ditto SVAR_SRplain(&mod, "cp", "Monetary", "-", 5) # ditto SVAR_SRplain(&mod, "r", "Monetary", "+", 5) # positive from 0 to 5 # do the rotations (this is the computationally intensive part) # (creating all bundles 'moo' is unnecessary in principle) bundles moo = SVAR_SRdraw(&mod, 200, 1, 0.75) # coverage 75% # draw the irfs (page 397) SVAR_SRirf(mod, mod.Ynames, defarray("Monetary"))