* * CAGAN.RPF * Estimation of a DSGE model. * * RATS User's Guide, Example from Section 10.8.5. * open data cagan_data.prn data(format=prn,org=cols) 1 34 mu x * declare series a1 a2 eps eta declare real alpha lambda sig_eta sig_eps * frml(identity) f1 x = x{1}+a1-lambda*a1{1} frml(identity) f2 mu = (1-lambda)*x{1}+lambda*mu{1}+a2-lambda*a2{1} frml(identity) f3 a1 = 1.0/(lambda+(1-lambda)*alpha)*(eps-eta) frml(identity) f4 a2 = (1.0/(lambda+(1-lambda)*alpha)*\$ ((1+alpha*(1-lambda))*eps-(1-lambda)*eta)) frml d1 = eps frml d2 = eta * group cagan f1 f2 f3 f4 d1 d2 * * lambda+(1-lambda)*alpha needs to stay clear of its zero point. It * appears that it needs to be negative, so alpha must be less than * -lambda/(1-lambda) on the guess values. * compute alpha=-3.00,lambda=.7,sig_eta=.001,sig_eps=.001 ***** function EvalModel dsge(model=cagan,a=adlm,f=fdlm) x mu a1 a2 eps eta end EvalModel ***** compute EvalModel() compute cdlm=%identity(2)~~%zeros(%rows(adlm)-2,2) * * Because we really have no idea what the scale is on the variances, we * first estimate the model with the alpha and lambda fixed. This uses * only a small number of simplex iterations to get the sigmas into the * right zone. * nonlin sig_eta sig_eps dlm(start=%(EvalModel(),sw=%diag(||sig_eps^2,sig_eta^2||)),\$ a=adlm,f=fdlm,y=||x,mu||,c=cdlm,sw=sw,presample=ergodic,\$ method=simplex,iters=5,noprint) * nonlin alpha lambda sig_eta sig_eps dlm(start=%(EvalModel(),sw=%diag(||sig_eps^2,sig_eta^2||)),\$ a=adlm,f=fdlm,y=||x,mu||,c=cdlm,sw=sw,presample=ergodic,\$ pmethod=simplex,piters=5,method=bfgs)