Page 1 of 1
Simulating a simple dsge
Posted: Sun May 16, 2010 5:08 pm
by ecrgap
Hi Tom
I was trying to simulate a simple dsge model for 1000 periods. The model is already in loglinear form. I tried the standard dlm instruction, but RATS does not generate data, just one first value and then it says +NAN.
Any suggestions?
Thanks in advance.
Re: Simlating a simple dsge
Posted: Mon May 17, 2010 9:03 am
by TomDoan
Here's an example which simulates a model which is log-linearized as part of the solution process, then transformed back to levels. Without seeing how yours is set up, it would be hard to determine the reason for that behavior.
Code: Select all
*
* Stochastic AK model
*
dec series y k c theta
dec real sigma beta n a delta rho theta0
*
frml(identity) f1 = y - theta*a*k{1}
frml(identity) f2 = c^-sigma - (beta/(1+n))*((c{-1}^-sigma)*(A*theta{-1}+1-delta))
frml(identity) f3 = c+(1+n)*k - (y+(1-delta)*k{1})
frml s1 = log(theta) - (rho*log(theta)+(1-rho)*log(theta0))
*
group ak f1 f2 f3 s1
*
* Fix parameters
*
compute a=.2
compute beta=.90
compute alpha=.33
compute n=0
compute delta=.07
compute sigma=.5
compute rho=.9
*
* Choose expansion point. Because of the linear production function,
* this doesn't have a well-defined steady state; instead, there are just
* steady state ratios of c and y to capital.
*
compute gamma=(beta*(a+1-delta)/(1+n))^(1/sigma)-1
compute theta0=(1.0/a)*((1+n)/beta-(1-delta))
compute yk_ss=a*theta0
compute ck_ss=yk_ss+1-delta-(1+n)
compute k0=100
dsge(model=ak,expand=loglin,a=adlm,f=fdlm,z=zdlm,steady=ss,iters=0) $
y<<yk_ss*k0 k<<k0 c<<ck_ss*k0 theta<<theta0
*
* Simulate model. The standard error on the productivity shock is set to
* .001.
*
dlm(type=simulate,a=adlm,f=fdlm,z=zdlm,presample=ergodic,sw=.000001) 1 100 xstates
*
* Because the model is log-linearized, the states are in log differences
* from the steady state. To transform back to levels, we need to exp the
* states, then multiply by the steady state values.
*
set y 1 100 = exp(xstates(t)(1))*ss(1)
set k 1 100 = exp(xstates(t)(2))*ss(2)
set c 1 100 = exp(xstates(t)(3))*ss(3)
graph(footer="Simulated Output")
# y
graph(footer="Simulated Consumption")
# c
graph(footer="Simulated Capital")
# k
Re: Simlating a simple dsge
Posted: Mon May 17, 2010 9:32 am
by ecrgap
Ok, so basically assume a dsge model of inflation, output and interest rate as follows:
frml(identity) f1 = dp - beta*dp{-1} - kappa*y
frml(identity) f2 = y - y{-1} + (1/sigma)*(r - dp{-1})
frml(identity) f3 = r - faip*dp - faiy*y - u
frml f4 = u - rho*u{1}
group dsge f1 f2 f3 f4
dsge(...) dp y r
compute sigmaeps = 0.001
dlm(...) 1 2000 xstates
set dp 1 2000 = xstates(t) (1)
set y 1 2000 = xstates(t) (2)
set r 1 2000 = xstates(t) (3)
So this is more or less how the model looks like.
Thank you
Re: Simlating a simple dsge
Posted: Mon May 17, 2010 1:06 pm
by TomDoan
I apologize for not being clearer. If you have a problem, it's most likely with the combination of the DSGE instruction and the DLM instruction. DSGE(...) and DLM(...) aren't going to help. If you could post the full example that isn't working correctly, I can take a look.
Re: Simlating a simple dsge
Posted: Mon May 17, 2010 2:37 pm
by ecrgap
No worries. Ok so here's the example. It's a bit a big model though
Code: Select all
dec series dp z y r m g q e df du k hin fin s b d rf ep u pro h ystar prf gstar hf w de def rstar rfstar tran ner uip
dec real beta theta ra ha fa ga hta sigma faip faiy eja gai rai eta cuta zita cutat vita vitad vitaf taf cut cutt fita ta tau taut nta mitaf mitad wa va ka la
dec real cutas cuts alpha oui fui zai gaif raif sigmau rhorf zitae cute cutap cutapf rhop zitap zitapf flep flef rhof flew flefp fled flewf dem dem fdemd dem rhod rhodf
dec real rpro rprof rdem rdemf rfpro rfprof rfdem rfdemf sigmauip
compute beta = 0.7643
compute betadf = 0.8232
compute ita = 0.8562
compute ra = .05
compute ha = .0554
compute fa = -0.1431
compute ta = .04
compute gai = .3710
compute rai = .3997
compute va = .0577
compute wa = - 0.2806
compute ka = .0497
compute la = -0.1036
compute fita = .7379
compute taf = 0.3563
compute hta = 1.0
compute nta = 1.0
compute ga = -0.2313
compute sigma = -0.285
compute alpha = -0.333
compute cut = - 0.0799
compute cutt = -0.1336
compute cuts = 0.1884
compute zita = 0.0179
compute zitat = 0.15
compute zitas = -0.1180
compute theta = 1.5
compute delta = 0.60
compute ega = 0.7
compute eja = 0.6
compute eta = 0.6
compute faip = 1.5
compute faiy = 0.50
compute faiq = 0.5
compute rhom = 0.60
compute cuta = - 0.0212
compute cutat = -0.1028
compute cutas = 0.1749
compute vitad = 1.0
compute mitad = 1.0
compute mitaf = 1.0
compute vitaf = 1.0
compute tau = -0.087
compute taut = 0.1804
compute taus = -0.1002
compute oui = 0.617
compute fui = 0.615
compute ouis = 0.78
compute fuis = 0.63
compute zai = 0.3071
compute gaif = -0.2121
compute raif = -0.2284
compute tafd = -0.1782
compute zaid = -0.1535
compute rhor = 0.6
compute rhorf = 0.79
compute rhoep = 0.0
compute cute = 0.0571
compute zitae = -0.0594
compute faipf = 1.5
compute faig = 0.5
compute cutap = -0.0
compute cutapf = -0.0
compute flep = 2.2
compute flef = 0.98
compute flew = -0.136
compute flefp = 2.44
compute fled = 0.73
compute flewf = -0.055
compute rhop = 0.5
compute rhof = 0.5
compute rhow = 0.5
compute zitap = -0.0
compute zitapf = -0.0
compute dem = 2.49
compute demf = -0.585
compute fdemd = -0.438
compute fdem = 2.34
compute rhod = 0.65
compute rhodf = 0.65
compute rpro = -1.7
compute rprof = -0.735
compute rdem = 1.307
compute rdemf = -0.307
compute rfpro = -0.5475
compute rfprof = -1.464
compute rfdem = -0.23
compute rfdemf = 1.2285
compute rtran = 1.675
compute rtranf = 1.138
compute rhouip = 0.4
frml(identity) f1 = dp - (beta*dp{-1}+ra*dp{1}+fa*z+gai*y+gaif*g+cuta*q+cutat*k+cutas*s)
frml(identity) f2 = z - (beta*z{-1}+ha*z{1}+ga*dp+rai*y+raif*g+cut*q+cutt*k+cuts*s+cute*e)
frml(identity) f3 = y - (y{-1}+(sigma)*(r-hin{-1}-rstar))-((1-delta)/ega)*(g-g{-1})-oui*b{-1}-ouis*d{-1} - (1-rhod)*de
frml(identity) f4 = g - (g{-1}+(alpha)*(rf-fin{-1}-rfstar))-((1-ega)/delta)*(y-y{-1})-fui*b{-1}-fuis*d{-1} - (1-rhodf)*def
frml(identity) f5 = df - (ita*df{-1}+va*df{1}+wa*du+taf*g+tafd*y+zita*q+zitat*k+zitas*s+zitae*e)
frml(identity) f6 = du - (fita*du{-1}+ka*du{1}+la*df+zai*g+zaid*y+tau*q+taut*k+taus*s)
frml(identity) f7 = r - rhor*r{1} - (1-rhor)*(faip*hin + faiy*y +faiq*q) - u
frml(identity) f8 = q - q{1}-ner-fin+hin - 1.0*ep
frml(identity) f9 = b - (-vitad*dp+vitaf*df) - (rhow-1)*w{1}
frml(identity) f10 = hin - (hta*dp+(1-delta)*b)
frml(identity) f11 = fin - (nta*du+(1-ega)*d)
frml(identity) f12 = d - (-mitaf*du*+mitad*z) - (rhow-1)*w{1}
frml f13 = u - rhom*u{1}
frml(identity) f14 = b - (k - k{1})
frml(identity) f15 = d - (s - s{1})
frml(identity) f16 = rf - rhorf*rf{1} - (1-rhorf)*(faipf*fin + faig*g)
frml(identity) f17 = ner{-1}-r+rf - 1.0*uip
frml(identity) f18 = ystar - flep*pro - flef*prf - flew*w - dem*de - demf*def
frml(identity) f19 = gstar - flefp*prf - fled*pro - flewf*w - fdemd*de - fdem*def
frml(identity) f20 = y - (h - ystar)
frml(identity) f21 = g - (hf - gstar)
frml f22 = ep - rhoep*ep{1}
frml f23 = pro - rhop*pro{1}
frml f24 = prf - rhof*prf{1}
frml(identity) f25 = w - rhow*w{1} - tran
frml f26 = de - rhod*de
frml f27 = def - rhodf*def
frml(identity) f28 = rstar - rpro*pro - rprof*prf - rdem*de - rdemf*def - rtran*w
frml(identity) f29 = rfstar - rfpro*pro - rfprof*prf - rfdem*de - rfdemf*def - rtranf*w
frml f30 = tran - 0.0
frml(identity) f31 = ner - e +e{1}
frml f32 = uip - rhouip*uip{1}
group dsge f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24 f25 f26 f27 f28 f29 f30 f31 f32
dsge(model = dsge,a = adlm,f = fdlm,z=zdlm) hin y q dp z g df du r fin k s e b d rf ystar h gstar hf u ep pro prf w de def rstar rfstar tran ner uip
compute sw = %diag(|| 0.0092^2,1,0.00852^2,0.00852^2, 0.005^2,0.005^2,0.00225^2,0.0052^2 ||)
dlm(type=simulate, a = adlm, f = fdlm, sw = sw) 1 2000 xstates
set dp 1 2000 = xstates(t) (1)
set z 1 2000 = xstates(t) (2)
set y 1 2000 = xstates(t) (3)
set r 1 2000 = xstates(t) (4)
set g 1 2000 = xstates(t) (6)
set q 1 2000 = xstates(t) (7)
set e 1 2000 = xstates(t) (8)
set df 1 2000 = xstates(t) (9)
set du 1 2000 = xstates(t) (10)
set k 1 2000 = xstates(t) (11)
set hin 1 2000 = xstates(t) (12)
set fin 1 2000 = xstates(t) (13)
set s 1 2000 = xstates(t) (14)
set b 1 2000 = xstates(t) (15)
set d 1 2000 = xstates(t) (16)
set rf 1 2000 = xstates(t) (17)
set h 1 2000 = xstates(t) (21)
set ystar 1 2000 = xstates(t) (22)
set gstar 1 2000 = xstates(t) (24)
set hf 1 2000 = xstates(t) (25)
set rstar 1 2000 = xstates(t) (29)
set rfstar 1 2000 = xstates(t) (30)
set ner 1 2000 = xstates(t) (32)
Thank you very much
Re: Simlating a simple dsge
Posted: Mon May 17, 2010 4:04 pm
by TomDoan
There seems to be a problem with your model. As you have it written, I get an
## FO17. Mismatch between unstable roots and expectational terms.
The problem seems to be with the E and NER series, whose definition seems to be a bit vague.
Re: Simlating a simple dsge
Posted: Mon May 17, 2010 4:26 pm
by ecrgap
i ll have a look and come back. however, when i run it to get the impulse responses i don't get a signal like this and it works fine. I don't know what went wrong.
i ll have a look.
Thank you
Re: Simlating a simple dsge
Posted: Mon May 17, 2010 4:32 pm
by ecrgap
Try this form. I just corrected for the ner variable
Code: Select all
dec series dp z y r m g q e df du k hin fin s b d rf ep u pro h ystar prf gstar hf w de def rstar rfstar tran uip
dec real beta theta ra ha fa ga hta sigma faip faiy eja gai rai eta cuta zita cutat vita vitad vitaf taf cut cutt fita ta tau taut nta mitaf mitad wa va ka la
dec real cutas cuts alpha oui fui zai gaif raif sigmau rhorf zitae cute cutap cutapf rhop zitap zitapf flep flef rhof flew flefp fled flewf dem dem fdemd dem rhod rhodf
dec real rpro rprof rdem rdemf rfpro rfprof rfdem rfdemf sigmauip
compute beta = 0.7643
compute betadf = 0.8232
compute ita = 0.8562
compute ra = .05
compute ha = .0554
compute fa = -0.1431
compute ta = .04
compute gai = .3710
compute rai = .3997
compute va = .0577
compute wa = - 0.2806
compute ka = .0497
compute la = -0.1036
compute fita = .7379
compute taf = 0.3563
compute hta = 1.0
compute nta = 1.0
compute ga = -0.2313
compute sigma = -0.285
compute alpha = -0.333
compute cut = - 0.0799
compute cutt = -0.1336
compute cuts = 0.1884
compute zita = 0.0179
compute zitat = 0.15
compute zitas = -0.1180
compute theta = 1.5
compute delta = 0.60
compute ega = 0.7
compute eja = 0.6
compute eta = 0.6
compute faip = 1.5
compute faiy = 0.50
compute faiq = 0.5
compute rhom = 0.60
compute cuta = - 0.0212
compute cutat = -0.1028
compute cutas = 0.1749
compute vitad = 1.0
compute mitad = 1.0
compute mitaf = 1.0
compute vitaf = 1.0
compute tau = -0.087
compute taut = 0.1804
compute taus = -0.1002
compute oui = 0.617
compute fui = 0.615
compute ouis = 0.78
compute fuis = 0.63
compute zai = 0.3071
compute gaif = -0.2121
compute raif = -0.2284
compute tafd = -0.1782
compute zaid = -0.1535
compute rhor = 0.6
compute rhorf = 0.79
compute rhoep = 0.0
compute cute = 0.0571
compute zitae = -0.0594
compute faipf = 1.5
compute faig = 0.5
compute cutap = -0.0
compute cutapf = -0.0
compute flep = 2.2
compute flef = 0.98
compute flew = -0.136
compute flefp = 2.44
compute fled = 0.73
compute flewf = -0.055
compute rhop = 0.5
compute rhof = 0.5
compute rhow = 0.5
compute zitap = -0.0
compute zitapf = -0.0
compute dem = 2.49
compute demf = -0.585
compute fdemd = -0.438
compute fdem = 2.34
compute rhod = 0.65
compute rhodf = 0.65
compute rpro = -1.7
compute rprof = -0.735
compute rdem = 1.307
compute rdemf = -0.307
compute rfpro = -0.5475
compute rfprof = -1.464
compute rfdem = -0.23
compute rfdemf = 1.2285
compute rtran = 1.675
compute rtranf = 1.138
compute rhouip = 0.4
frml(identity) f1 = dp - (beta*dp{-1}+ra*dp{1}+fa*z+gai*y+gaif*g+cuta*q+cutat*k+cutas*s)
frml(identity) f2 = z - (beta*z{-1}+ha*z{1}+ga*dp+rai*y+raif*g+cut*q+cutt*k+cuts*s+cute*e)
frml(identity) f3 = y - (y{-1}+(sigma)*(r-hin{-1}-rstar))-((1-delta)/ega)*(g-g{-1})-oui*b{-1}-ouis*d{-1} - (1-rhod)*de
frml(identity) f4 = g - (g{-1}+(alpha)*(rf-fin{-1}-rfstar))-((1-ega)/delta)*(y-y{-1})-fui*b{-1}-fuis*d{-1} - (1-rhodf)*def
frml(identity) f5 = df - (ita*df{-1}+va*df{1}+wa*du+taf*g+tafd*y+zita*q+zitat*k+zitas*s+zitae*e)
frml(identity) f6 = du - (fita*du{-1}+ka*du{1}+la*df+zai*g+zaid*y+tau*q+taut*k+taus*s)
frml(identity) f7 = r - rhor*r{1} - (1-rhor)*(faip*hin + faiy*y +faiq*q) - u
frml(identity) f8 = q - q{1}-e + e{1} -fin+hin - 1.0*ep
frml(identity) f9 = b - (-vitad*dp+vitaf*df) - (rhow-1)*w{1}
frml(identity) f10 = hin - (hta*dp+(1-delta)*b)
frml(identity) f11 = fin - (nta*du+(1-ega)*d)
frml(identity) f12 = d - (-mitaf*du*+mitad*z) - (rhow-1)*w{1}
frml f13 = u - rhom*u{1}
frml(identity) f14 = b - (k - k{1})
frml(identity) f15 = d - (s - s{1})
frml(identity) f16 = rf - rhorf*rf{1} - (1-rhorf)*(faipf*fin + faig*g)
frml(identity) f17 = e{-1} - e -r+rf - 1.0*uip
frml(identity) f18 = ystar - flep*pro - flef*prf - flew*w - dem*de - demf*def
frml(identity) f19 = gstar - flefp*prf - fled*pro - flewf*w - fdemd*de - fdem*def
frml(identity) f20 = y - (h - ystar)
frml(identity) f21 = g - (hf - gstar)
frml f22 = ep - rhoep*ep{1}
frml f23 = pro - rhop*pro{1}
frml f24 = prf - rhof*prf{1}
frml(identity) f25 = w - rhow*w{1} - tran
frml f26 = de - rhod*de
frml f27 = def - rhodf*def
frml(identity) f28 = rstar - rpro*pro - rprof*prf - rdem*de - rdemf*def - rtran*w
frml(identity) f29 = rfstar - rfpro*pro - rfprof*prf - rfdem*de - rfdemf*def - rtranf*w
frml f30 = tran - 0.0
frml f31 = uip - rhouip*uip{1}
group dsge f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24 f25 f26 f27 f28 f29 f30 f31
dsge(model = dsge,a = adlm,f = fdlm,z=zdlm) hin y q dp z g df du r fin k s e b d rf ystar h gstar hf u ep pro prf w de def rstar rfstar tran uip
compute sw = %diag(|| 0.0092^2,1,0.00852^2,0.00852^2, 0.005^2,0.005^2,0.00225^2,0.0052^2 ||)
dlm(type=simulate, a = adlm, f = fdlm, sw = sw) 1 2000 xstates
set dp 1 2000 = xstates(t) (1)
set z 1 2000 = xstates(t) (2)
set y 1 2000 = xstates(t) (3)
set r 1 2000 = xstates(t) (4)
set g 1 2000 = xstates(t) (6)
set q 1 2000 = xstates(t) (7)
set e 1 2000 = xstates(t) (8)
set df 1 2000 = xstates(t) (9)
set du 1 2000 = xstates(t) (10)
set k 1 2000 = xstates(t) (11)
set hin 1 2000 = xstates(t) (12)
set fin 1 2000 = xstates(t) (13)
set s 1 2000 = xstates(t) (14)
set b 1 2000 = xstates(t) (15)
set d 1 2000 = xstates(t) (16)
set rf 1 2000 = xstates(t) (17)
set h 1 2000 = xstates(t) (21)
set ystar 1 2000 = xstates(t) (22)
set gstar 1 2000 = xstates(t) (24)
set hf 1 2000 = xstates(t) (25)
set rstar 1 2000 = xstates(t) (29)
set rfstar 1 2000 = xstates(t) (30)
set ner 1 2000 = xstates(t) (32)
Re: Simlating a simple dsge
Posted: Mon May 17, 2010 5:59 pm
by TomDoan
ecrgap wrote:i ll have a look and come back. however, when i run it to get the impulse responses i don't get a signal like this and it works fine. I don't know what went wrong.
i ll have a look.
Thank you
We've improved the testing for problems with the model. With 7.3 it finds (I believe correctly) that the model is defective; with earlier versions, it missed that, but the problem you have with the simulation is due to the fact that it comes up with a "solution" for a model which actually has none.
Substituting out for "ner" doesn't change the underlying problem, which is that the "e" variable doesn't have its dynamics well-enough defined.
Re: Simlating a simple dsge
Posted: Mon May 17, 2010 6:10 pm
by ecrgap
ok i see
so the problem is generated by e and ner.
thanks a lot tom
Re: Simlating a simple dsge
Posted: Mon May 17, 2010 6:32 pm
by ecrgap
Tom you are amazing.
I specified the dynamics of the e variable correctly and the simulation works perfect.
you saved me once again
thanks a lot
Re: Simlating a simple dsge
Posted: Thu May 20, 2010 10:32 pm
by luxu1983
TomDoan wrote:Here's an example which simulates a model which is log-linearized as part of the solution process, then transformed back to levels. Without seeing how yours is set up, it would be hard to determine the reason for that behavior.
Code: Select all
*
* Stochastic AK model
*
dec series y k c theta
dec real sigma beta n a delta rho theta0
*
frml(identity) f1 = y - theta*a*k{1}
frml(identity) f2 = c^-sigma - (beta/(1+n))*((c{-1}^-sigma)*(A*theta{-1}+1-delta))
frml(identity) f3 = c+(1+n)*k - (y+(1-delta)*k{1})
frml s1 = log(theta) - (rho*log(theta)+(1-rho)*log(theta0))
*
group ak f1 f2 f3 s1
*
* Fix parameters
*
compute a=.2
compute beta=.90
compute alpha=.33
compute n=0
compute delta=.07
compute sigma=.5
compute rho=.9
*
* Choose expansion point. Because of the linear production function,
* this doesn't have a well-defined steady state; instead, there are just
* steady state ratios of c and y to capital.
*
compute gamma=(beta*(a+1-delta)/(1+n))^(1/sigma)-1
compute theta0=(1.0/a)*((1+n)/beta-(1-delta))
compute yk_ss=a*theta0
compute ck_ss=yk_ss+1-delta-(1+n)
compute k0=100
dsge(model=ak,expand=loglin,a=adlm,f=fdlm,z=zdlm,steady=ss,iters=0) $
y<<yk_ss*k0 k<<k0 c<<ck_ss*k0 theta<<theta0
*
* Simulate model. The standard error on the productivity shock is set to
* .001.
*
dlm(type=simulate,a=adlm,f=fdlm,z=zdlm,presample=ergodic,sw=.000001) 1 100 xstates
*
* Because the model is log-linearized, the states are in log differences
* from the steady state. To transform back to levels, we need to exp the
* states, then multiply by the steady state values.
*
set y 1 100 = exp(xstates(t)(1))*ss(1)
set k 1 100 = exp(xstates(t)(2))*ss(2)
set c 1 100 = exp(xstates(t)(3))*ss(3)
graph(footer="Simulated Output")
# y
graph(footer="Simulated Consumption")
# c
graph(footer="Simulated Capital")
# k
dear sir
when i run your code
it shows "DLM5. Probable Model Error. Diffuse prior was not reduced to zero rank"
why?
Re: Simlating a simple dsge
Posted: Fri May 21, 2010 1:42 am
by terrya
luxu1983 wrote:TomDoan wrote:Here's an example which simulates a model which is log-linearized as part of the solution process, then transformed back to levels. Without seeing how yours is set up, it would be hard to determine the reason for that behavior.
Code: Select all
*
* Stochastic AK model
*
dec series y k c theta
dec real sigma beta n a delta rho theta0
*
frml(identity) f1 = y - theta*a*k{1}
frml(identity) f2 = c^-sigma - (beta/(1+n))*((c{-1}^-sigma)*(A*theta{-1}+1-delta))
frml(identity) f3 = c+(1+n)*k - (y+(1-delta)*k{1})
frml s1 = log(theta) - (rho*log(theta)+(1-rho)*log(theta0))
*
group ak f1 f2 f3 s1
*
* Fix parameters
*
compute a=.2
compute beta=.90
compute alpha=.33
compute n=0
compute delta=.07
compute sigma=.5
compute rho=.9
*
* Choose expansion point. Because of the linear production function,
* this doesn't have a well-defined steady state; instead, there are just
* steady state ratios of c and y to capital.
*
compute gamma=(beta*(a+1-delta)/(1+n))^(1/sigma)-1
compute theta0=(1.0/a)*((1+n)/beta-(1-delta))
compute yk_ss=a*theta0
compute ck_ss=yk_ss+1-delta-(1+n)
compute k0=100
dsge(model=ak,expand=loglin,a=adlm,f=fdlm,z=zdlm,steady=ss,iters=0) $
y<<yk_ss*k0 k<<k0 c<<ck_ss*k0 theta<<theta0
*
* Simulate model. The standard error on the productivity shock is set to
* .001.
*
dlm(type=simulate,a=adlm,f=fdlm,z=zdlm,presample=ergodic,sw=.000001) 1 100 xstates
*
* Because the model is log-linearized, the states are in log differences
* from the steady state. To transform back to levels, we need to exp the
* states, then multiply by the steady state values.
*
set y 1 100 = exp(xstates(t)(1))*ss(1)
set k 1 100 = exp(xstates(t)(2))*ss(2)
set c 1 100 = exp(xstates(t)(3))*ss(3)
graph(footer="Simulated Output")
# y
graph(footer="Simulated Consumption")
# c
graph(footer="Simulated Capital")
# k
dear sir
when i run your code
it shows "DLM5. Probable Model Error. Diffuse prior was not reduced to zero rank"
why?
I just ran the model which TD had posted. It worked for me. I'm using Rats 7.3. Your problem might be that you're using an earlier version of Rats.
Re: Simlating a simple dsge
Posted: Sat May 22, 2010 3:45 pm
by TomDoan
ecrgap wrote:Tom you are amazing.
I specified the dynamics of the e variable correctly and the simulation works perfect.
you saved me once again
thanks a lot
What change did you make? I'm trying to figure out how to improve the diagnostics so it can more easily pinpoint problems like that.
Re: Simlating a simple dsge
Posted: Mon May 24, 2010 6:45 pm
by ecrgap
sorry Tom I just saw your message,
so basically, in the paper i am working there is also the assumption that the e variable follows an AR(1) as well. So if you look at the code that I had initially sent you, I didn't have that specification. If you add the AR process for the e variable, it works perfect.