Handling stochastic trends

I have a model with deterministic and stochastic trends. I have rewritten it in stationary forms, and I am able to solve it and simulate it as usual.

I was wondering whether there is an example file that I can look at to set up the model for estimation using either (1) nonstationary data; (2) first difference of the same nonstationary data. I have been looking at the manual and the example file fs2000a.mod, but some details are not entirely clear to me, and I was wondering whether the handling of the trends has been made easier…



Dear Matteo,

no, nothing has been done to make handling of stochastic trends easier. I could make a HOWTO on this topic one of my Summer projects.

The key issues are the following

  1. separate the deterministic from the stochastic trend and handle the deterministic trend with ‘observation_trends’
  2. in the model file, just cumulate the observable in first difference to obtain nonstationary observable variables
  3. declare all nonstationary variables (observed and unobserved) in ‘unit_root_vars’. This will automatically trigger the use of a diffuse Kalman filter

Don’t hesitate to tell me more precisely which difficulties you are encountering and what could be done as improvement

Kind regards


Hi Michel,

We made one step back and started estimating a model with deterministic trends only. The question I have is whether we need to use the option options_.unit_root_vars for the variables that are trending over time (my sense is that the answer is yes, otherwise I seem to get nonsensical values for the likelihood).

I am sending you separately the mod file to estimate the model and a sketch of the model itself, in case you want to look at it in more detail.



Hi Michel,

I was wondering whether you had devoted some thoughts to the issue above. My coauthor and are using different codes (Dynare vs modified version of Peter Ireland codes) to estimate the same model. Without trends, we get the same value when calculating the likelihood and the prior at the same parameter value. With trends, this is no longer the case.

I have some questions:

  1. With deterministic trends, do we need to cumulate the detrended variable and declare that as observable, or not? Say, let x be detrended output in the model, but output in the data has a deterministic trend. Do we need to declare as observable x and tell Dynare that x has a deterministic trend, or do we need to create the variable y=x+y(-1) and declare that as our observable?

  2. With deterministic trends, do we need to use the option unit_root_vars or not?

Any suggestions or examples would be appreciated. Thanks

don’t cumulate the detrended variables. “observation_trends” tells Dynare that, in the data, the variable corresponding to x has a linear trend with the specified coefficient addet to it

no, you don’t