# 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:

Blockquote

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] =
dynare_minimize_objective(objective_function,xparam1,options_.mode_compute,options_,[bounds.lb
bounds.ub],bayestopt_.name,bayestopt_,hh,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);

Error in dynare_estimation (line 105)
dynare_estimation_1(var_list,dname);

Error in base_ex (line 1108)
oo_recursive_=dynare_estimation(var_list_);

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

Blockquote

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!
Best,
Elizaveta
Output_gap.zip (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 https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Gali_Monacelli_2005/Gali_Monacelli_2005.mod

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.

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:
model(linear);
y = yp + g;
yp = mu + yp(-1) + eyp;
g = alphag(-1) +betag(-2)+ eg;
mu = mu(-1) + emu;
end;
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:
pi=beta1pi(+1)+beta2pi(-1)+deltag+epi;
and Okun’s law:
cu = cut + gcu;
gcu = ro1
g+ro2*gcu(-1) + egcu;
cut=cut(-1)+ecut;
Thanks very much for your time
Elizaveta

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)

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

Error in dynare_estimation_1 (line 520)
prior_posterior_statistics(‘posterior’,dataset_,dataset_info);

Error in dynare_estimation (line 105)
dynare_estimation_1(var_list,dname);

Error in ex (line 182)
oo_recursive_=dynare_estimation(var_list_);

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

OutputG.zip (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
`y_obs=mean_y+y-y(-1)`
You need to make the model consistent.