Problem with output gap estimation

Dear all,
I am trying to estimate output gap with Phillips curve for small open economy introduced by Gali, Monacelli (2005). To do this I need to use some observable exogenous variables (changes in terms of trade). I have no idea other than to add a deterministic shock for every period. I guess that my following problems arise from this. Code crashes at “tuning of the scale parameter ”with following error:


Error using chol
Matrix must be positive definite.

Error in gmhmaxlik_core (line 194)
dd = transpose(chol(CovJump));

Error in gmhmaxlik (line 100)
[PostMode, PostVariance, Scale, PostMean] = gmhmaxlik_core(fun, OldPostMode, bounds, gmhmaxlikOptions, Scale, flag, MeanPar,
OldPostVariance, varargin{:});

Error in dynare_minimize_objective (line 258)
[opt_par_values, hessian_mat, Scale, fval] = gmhmaxlik(objective_function, start_par_value, …

Error in dynare_estimation_1 (line 220)
[xparam1, fval, exitflag, hh, options_, Scale, new_rat_hess_info] =

Error in dynare_estimation (line 105)

Error in base_ex (line 1108)

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


I’m a beginner, so really very sorry if the question is too easy, or too stupid. Could anyone help me with this? Tanks a lot!
Elizaveta (222.2 KB)

1 Like

I am not sure I understand what you are trying to do here. But the model already does not look the way I would have expected it. See

On top of that, your model is linearized, but your data is not mean 0. That cannot work. Please take a look at Pfeifer(2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models”

Sidenote: it seems you did not get the proper training for the project you are embarking on. From my experience with hundreds of users: This is very dangerous and will most likely be a frustrating journey for you. If you are still a student, talk to your adviser.

Thanks, Johannes, for your reply.
I read the article and looked throw the mod file and feel very confused now. I just want to estimate potential output using unobserved components model, so not interested in constructing full DSGE model and don’t understand why my data should be mean zero. When I use simple output decomposition:
y = yp + g;
yp = mu + yp(-1) + eyp;
g = alphag(-1) +betag(-2)+ eg;
mu = mu(-1) + emu;
It works nice with my data. Output is not stationary variable, so I use diffuse_filter estimation option, why can’t I do the same but add Phillips curve in model:
and Okun’s law:
cu = cut + gcu;
gcu = ro1
g+ro2*gcu(-1) + egcu;
Thanks very much for your time

I see. You can work with an unobserved components model and augment it with additional equations. But you need to make sure the equations are consistent. The typical Phillips Curve is linearized, i.e. all variables are mean 0. If the rest of the model assumes that those variables still have their mean, then you will get problems.

Tanks a lot!

Dear Johannes,
I rethink the consept of the model and try to use variables in log differenses, so my observed y in model is log(Yt)-log(Yt-1) and the same for inflation. Neveretheless, y in steady state is still not zero, cause it has long-run growth of mu, and inflation has zero mean. Now i have the following error:

Matrix dimensions must agree.

Error in prior_posterior_statistics_core (line 274)
stock_filter_step_ahead(ii,IdObs,:,irun(4)) = squeeze(stock_filter_step_ahead(ii,IdObs,:,irun(4)))…

Error in prior_posterior_statistics (line 241)
[fout] = prior_posterior_statistics_core(localVars,1,B,0);

Error in dynare_estimation_1 (line 520)

Error in dynare_estimation (line 105)

Error in ex (line 182)

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

and have no idea why. feels like i’m trying to reinvent the wheel and get only the cube.
mod and data files attached
Yours faithfully,
Elizaveta (14.6 KB)

  1. Which Dynare version do you use? The error message looks like a bug.
  2. Your observation equation is still not correct. y in the model is the log-level, while in the data it is the log-difference. It should be
    You need to make the model consistent.