Problem with bayesian estimation in DSGE model

Hello everybody,

I’m trying to put together a DSGE model with open economy characteristics to represent the events of the 2008-2009 recession and it’s diffusion between Canada and the US.

I know there’s a couple of things to fix in my code since I’m new to Dynare, but the first step I wanted to take was to successfully lead a ML/Bayesian estimation and then come back to correct the many shortcuts I took in my code to simplify.

I’m getting a couple of error messages:

  • ‘‘ESTIMATION_CHECKS: There was an error in computing the likelihood for initial parameter values. You should try using the calibrated version of the model as starting values. To do this, add an empty estimated_params_init-block with use_calibration option immediately before the estimation command (and after the estimated_params-block so that it does not get overwritten)’’

(Doing exactly that doesn’t remove that message)

  • ‘‘Undefined function or variable ‘isestimation’.’’

  • ''Error in resol (line 121)
    if isestimation()

  • ‘‘Error in dynare_resolve (line 69)
    [dr,info,Model,DynareOptions,DynareResults] = resol(0,Model,DynareOptions,DynareResults);

  • ''Error in dsge_likelihood (line 256)
    [T,R,SteadyState,info,Model,DynareOptions,DynareResults] = dynare_resolve(Model,DynareOptions,DynareResults,‘restrict’);

  • ‘‘Error in initial_estimation_checks (line 47)
    [fval,junk1,junk2,a,b,c,d] =

  • ‘‘Error in dynare_estimation_1 (line 179)
    oo_ = initial_estimation_checks(objective_function,xparam1,dataset_,M_,estim_params_,options_,bayestopt_,oo_);

  • ‘‘Error in dynare_estimation (line 89)

  • ‘‘Error in code (line 309)

  • ‘‘Error in dynare (line 180)
    evalin(‘base’,fname) ;

I haven’t found explanations as to how to fix those error messages on this website. If any of you has seen this before, you would be of a great help to me if you could guide me in the right direction. Thanks a lot!

code.mod (3.7 KB)
datasheets.xlsx (16.3 KB)

Which version are you using? Dynare 4.5.4 tells you:

Error using print_info (line 98)
The loglinearization of the model cannot be performed, because the steady state is not strictly positive.

which is not surprising, given that all steady state values are 0. You cannot use the loglinear option as the model is already linearized.

Thanks for the swift response prof. Pfeifer!

I use Dynare 4.4.3 right now.

I changed my code a bit:

  • I removed the loglinear option as you instructed and it did work better
  • I added the diffuse_filter option in the estimation block to get rid of the

‘‘Error using print_info (line 100)
Likelihood is a complex number
’’ error message

  • I changed the mode_compute from =4 to =6 also in the estimation block to get rid of

‘‘Error using chol
Matrix must be positive definite’’

Since then (and also with some other tweaks in my previous code) I was able to obtain an estimation of my parameters. Still, I end up with different error messages to which I can’t find a solution or even a mention on this forum. Have you ever seen these?

Error using *
Inner matrix dimensions must agree.

Error in schur_statespace_transformation (line 55)
B = QT’RQ*R’*QT;

Error in DsgeSmoother (line 139)
**[Z,ST,R1,QT,Pstar,Pinf] = schur_statespace_transformation(mf,T,R,Q,options.qz_criterium);**_

Error in dynare_estimation_1 (line 836)
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp] =

Error in dynare_estimation (line 89)

_Error in codebruce (line 294)

Error in dynare (line 180)
evalin(‘base’,fname) ;

If the problem originates from the values I gave my parameters or the shape of the priors I could correct it with more accurate values, but otherwise I have a hard time understanding why that message would come up.

Again I will link the data set and the code:
codebruce.mod (3.2 KB)
datasheets.xlsx (16.3 KB)

  1. Please use Dynare 4.5.4
  2. Your observation equation is wrong. You are trying to match trending data to stationary model variables. Please read Pfeifer(2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models”