set verbose off set seed 131020 ### -------------------------------------------------- ### load the data and generate the variables ### -------------------------------------------------- open AWM18.gdt --quiet Con = log(PCR) Inv = log(GCR) Inc = log(YER) list EXO = const time ### -------------------------------------------------- ### estimate the system via FIML ### -------------------------------------------------- system method=fiml equation Con EXO Con(-1) Inc(0 to -1) equation Inv EXO Inv(-1) Inc(-1) equation Inc EXO Inc(-1 to -2) Inv(-1) end system bundle sys = $system # save the estimated system to a bundle ### -------------------------------------------------- ### compute the reduced form VAR representation ### -------------------------------------------------- matrix iG = inv(sys.Gamma) matrix rfA = iG * sys.A matrix rfB = iG * sys.B ### -------------------------------------------------- ### produce the simulation ### -------------------------------------------------- scalar horizon = 12 ### retrieve a few magnitudes from the estimated system scalar g = sys.neqns # number of equations scalar p = cols(sys.A) / g # maximum lag ### future values of the exogenous variable matrix SimExo = 1 ~ seq($nobs + 1, $nobs + horizon)' matrix X = SimExo * rfB' ### simulated disturbances E = mnormal(horizon, g) * cholesky(sys.sigma)' # reduced form disturbances V = E * iG' # structural form disturbances ### initial values list ENDO = Con Inv Inc matrix init = {ENDO}[$nobs-p+1:,] ### perform simulation Sim = varsimul(rfA, X + V, init) print Sim