Page 1 of 1
Matheson-Stavrev EL 2013
Posted: Thu Aug 31, 2017 10:47 am
by TomDoan
MathesonStavrevEL2013.rprj is based upon upon Matheson and Stavrev(2013), "The Great Recession and the inflation puzzle,"
Economics Letters, vol. 120, no 3, pp 468-472 with a reconstructed (and extended) data set. The model is a bivariate time-varying coefficients/state-space model of the unemployment gap combined with a Phillips curve. (The TVC is in the Phillips curve). Because of the non-linear interaction between the time-varying coefficients and the unemployment gap, the model can't be estimated using a simple bivariate state-space model. Instead, it employs the extended (non-linear) Kalman filter (or EKF).
Detailed Description
The 2nd Edition of the State-Space/DSGE e-course covers both the extended Kalman filter (using this example, but without the constraints) and inequality-constrained analysis (using
a simpler example where different methods can be examined more carefully).
Re: Matheson-Stavrev EL 2013
Posted: Mon Dec 18, 2017 4:19 am
by fioramanti
Dear Tom,
I’m going through the SSM and DSGE course. I have some question on M&S following the file “ekfconstrain.rpf”, in the part which is not documented in the SSM handbook because it belongs to the constrained version of the code.
Could you please add some more explanation on the following part of the code:
Code: Select all
* Constraints for use with LQPROG
*
dec rect aqprog(4,5)
dec vect bqprog(4)
input aqprog
0 0 -1 0 0
0 0 0 -1 0
0 0 0 1 0
0 0 0 0 -1
input bqprog
0
0
1
0
*
function PreFnc xt1_t1
type vector *xt1_t1
end
*
function PostFnc xt_t vt_t
type vector *xt_t
type symm *vt_t
*
local rect eigvect
local vect eigval flip
local symm qqprog
*
eigen vt_t eigval eigvect
dim flip(%size(eigval))
ewise flip(i)=%if(eigval(i)<1.e-10,1.0,1.0/eigval(i))
compute qqprog=eigvect*%diag(flip)*tr(eigvect)
lqprog(nneg=0,a=aqprog,b=bqprog,q=qqprog,c=-1.0*qqprog*xt_t,noprint) xt_t
end
Furthermore, it is not very clear to me what
(Options for Adjusting the State or Covariance Matrix in DLM) do.
Finally, a minor question is, what is the use/meaning of the asterisk/star (*) in some part of the code like
?
Thank you,
Marco
Re: Matheson-Stavrev EL 2013
Posted: Mon Dec 18, 2017 10:02 am
by TomDoan
Have you looked at the descriptions of the options on the DLM instruction?
https://estima.com/ratshelp/dlminstruction.html
The help on the web site is always kept up-to-date with any changes to the instructions or procedures.
The * on a procedure or function parameter or option is for passing by address so it can be changed by the procedure. (Most of the time, these are strictly for input, not input/output).
The A and B matrices are the constraint inputs for LQPROG. The states are
* States are u-u* (ugap), u*, kappa, theta, gamma in that order.
* The observables are pi and u.
Because constraints are in <= form, the signs are flipped on all the >= constraints. The
ewise flip(i)=%if(eigval(i)<1.e-10,1.0,1.0/eigval(i))
compute qqprog=eigvect*%diag(flip)*tr(eigvect)
is to avoid problems with the covariance matrix having deficient rank, replacing all (effectively) zero eigenvalues with 1.0.
Re: Matheson-Stavrev EL 2013
Posted: Wed Dec 20, 2017 4:24 am
by fioramanti
Yes I have, but the explanation is a bit intricate to me.
Thank you,
M
Re: Matheson-Stavrev EL 2013
Posted: Wed Dec 20, 2017 7:32 am
by TomDoan
That's the point of the one-state example where it's much clearer what these are doing.
Re: Matheson-Stavrev EL 2013
Posted: Thu Mar 19, 2020 12:05 pm
by adrangi
Hi Tom. Hope you're well. I;m running eksmooth.rpf. I'get the linreg results fine. Then the following error message any tweaking you can suggest? Thanks for any suggestions. Of course it could be my data series too. Thanks. Best, Bahram A.
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. UGAP_0{1} 0.7071728387 0.0635554208 11.12687 0.00000000
## MAT15. Subscripts Too Large or Non-Positive
Error was evaluating entry 1
linreg ugap_0
# ugap_0{1}
compute rho=%beta(1)
compute swugap=%sigmasq
*
dec frml[vect] muf
dec frml[rect] cf
dec frml[symm] svf
dec frml[symm] swf
Re: Matheson-Stavrev EL 2013
Posted: Fri Mar 20, 2020 2:14 pm
by TomDoan
What line created the error? It's not going to be anything there.
Re: Matheson-Stavrev EL 2013
Posted: Fri Mar 20, 2020 5:49 pm
by adrangi
Hi Tom. Thanks. I changed my program a bit and this time didn't get as far as before and got the following.
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. KAPPA_R 2.4136036306 0.7236258202 3.33543 0.00159372
2. THETA_R 1.1256764796 0.2541144480 4.42980 0.00005009
3. GAMMA_R 1.0078773840 1.5570687983 0.64729 0.52034639
## MAT13. Store into out-of-range KAPPA_RE(116)
The Error Occurred At Location 181, Line 4 of loop/block
Apparently it's coming from the following loop. I do have only 115 data points! Does that put KAPPA_RE(116) out of range? Any thought are appreciated. Thanks. Best, Bahram
do time=rstart,send
compute kappa_r=0.1,gamma_r=0.1,theta_r=0.5
nlls(parmset=rollparms,frml=rollpi,noprint) pi time-(span-1) time
compute kappa_re(time)=kappa_r
compute theta_re(time)=theta_r
compute gamma_re(time)=gamma_r
end do time
Re: Matheson-Stavrev EL 2013
Posted: Sat Nov 29, 2025 9:23 pm
by TomDoan
Yes. I'm not sure what SEND is but it sounds like you running the loop past the end of the data.