Page 1 of 1

Multivariate Trend-Cycle Model

Posted: Fri Jun 13, 2014 7:53 pm
by luching
Hi, I have a linear state space model with some of the variables following a unit root process. Is there a sample code to estimate this type of models?

Re: State Space Model

Posted: Fri Jun 13, 2014 9:30 pm
by TomDoan
Could you be more specific about your model?

Re: State Space Model

Posted: Sat Jun 14, 2014 7:22 am
by luching
The model is a MULTIVARIATE trend-cycle decomposition. Each of the trends is an independent unit root process. The cycles are stationary but linked across variables. Any sample code will be of great help.

Re: State Space Model

Posted: Sat Jun 14, 2014 8:53 am
by TomDoan
Do you actually have a model? In general, once you have a state-space representation, rendering it using DLM isn't that difficult. The tricky part about what you describe is that something needs to be done to identify the trends.

Re: State Space Model

Posted: Mon Jun 16, 2014 3:46 pm
by luching
Here's the model:

(1) y_t = y1_t + y2_t
(2) y1_t = delta + y1_t-1 + v_t; v_t is iid
(3) y2_t = a1*y2_t-1 + a2*y2_t-2 + e_t; e_t is iid
(4) z_t = z1_t + z2_t
(5) z1_t = z1_t-1 + w_t; w_t is iid
(6) z2_t = b1*y2_t-1 + b2*y2_t-2 + x_t; x_t is iid

The cross equation link is in (6).

Re: State Space Model

Posted: Mon Jun 16, 2014 3:55 pm
by TomDoan
So y and z are the observables and y1, y2, z1 and z2 are the states? You'll need to add y2_{t-1} to the state vector to handle the second lag. It should be relatively easy once you write it in state-space form.

Re: State Space Model

Posted: Mon Jun 16, 2014 4:28 pm
by luching
You are right about the states and the observables. Is there a sample code that I can adapt? I have the model written out in state space. I was also looking for a Bayesian procedure as the unit root process has apparently some issues with convergence when MLE is deployed. Many thanks.

Re: State Space Model

Posted: Mon Jun 16, 2014 5:11 pm
by TomDoan
RATS can handle the hard unit roots (in y1 and z1) just fine. Where you might run into problems is with the (I assume you hope) stationary processes if they start to become tangled up with the unit root. For instance, y2 could end up with a unit root. If there are problems with that, you would need to use the CONDITION option to avoid a discontinuity in the likelihood function.

I don't know of any examples with the behavior of your z2 process. The Diebold-Rudebusch-Aruoba replication has the sort of problem that I describe above, and needs a bit of care to converge; it is, however, more complicated than your model.

I wouldn't try to jump too far ahead. Get the model into the program first, before you start worrying about how you'll estimate it.

Re: State Space Model

Posted: Mon Jun 16, 2014 5:28 pm
by luching
Thanks Tom. I am a starter in this case with RATS. Is there a sample piece of code that does state space even for a univariate process? That will give me some starting point.

Re: State Space Model

Posted: Mon Jun 16, 2014 6:01 pm
by TomDoan
luching wrote:Thanks Tom. I am a starter in this case with RATS. Is there a sample piece of code that does state space even for a univariate process? That will give me some starting point.
Aside from the chapter in the User's Guide, there are four entire textbooks which are for state-space models: Durbin-Koopman, Commandeur-Koopman, West and Harrison and Harvey. You also might want to get the State Space/DSGE E-Course Materials.

Re: State Space Model

Posted: Wed Jun 18, 2014 1:58 pm
by luching
Hi Tom,

I created a small working code based on a simplified version of the model that takes only the first three equations. But it shows an error message:

## DLM1. Rank of Prediction Error Variance < Number of Observables

I am probably missing a syntax. Could you please help? The sample code and data are attached.

Re: State Space Model

Posted: Wed Jun 18, 2014 2:41 pm
by TomDoan
Anything that depends upon free parameters needs to be a FRML. So you want:

dec frml[symm] sw1
frml sw1 = ||sig2,0,0,0|0,sig3,0,0|0,0,0,0|0,0,0,0||

As it is, sw1 is a fixed matrix created before you've even given guesses to sig2 and sig3.

One thing to note is that your model as written has no way to deal with the drift in GDP. You'll need a Z option to add that:

dec frml[vect] zf
frml zf = ||alpha,0,0,0||

where alpha needs to be added to the parameters. You need to add Z=ZF to the DLM instruction. You don't need the SV since it's just zero. You should also have the PRESAMPLE=ERGODIC option to deal with the unit root.

dlm(method=bfgs,z=zf,sw=sw1,y=GDP,presample=ergodic,type=filter,c=cf,a=af) 1991:2 2014:2

Finally, two shocks looks like it's one too many, so you have to put inequality constraints into your parameter set:

nonlin alpha phi1 phi2 sig2 sig3 sig2>=0.0 sig3>=0.0

Again, I would strongly urge you to get the State Space course. You'll save a lot of time as these types of issues are all explained.

Re: State Space Model

Posted: Tue Apr 26, 2016 3:10 pm
by pls
What if the measurement equation (2) in DLM has zero errors, that is V sub t = 0?
Can DLM be used to estimate a state space model?
Thanks.

Re: State Space Model

Posted: Tue Apr 26, 2016 3:22 pm
by TomDoan
pls wrote:What if the measurement equation (2) in DLM has zero errors, that is V sub t = 0?
Can DLM be used to estimate a state space model?
Thanks.
In the model above, (2) is actually one of the state equations. (1) and (4) are the measurement equations and they (as you can see) both have 0 errors as all the disturbances have been pushed into the states. Any state-space model can be written with zero measurement errors if you expand the state vector enough, though that's often an unnatural complication. Can (2) also have zero errors? Yes, though that would simply make it a deterministic linear trend at rate delta.