Maximum likelihood estimation

Hello I’m trying to use dynare to estimate a stochastic process in order to apply the Business cycle accounting procedure à la Chaari et al (2007). The problem is that matlab return me the following
Undefined variable “estim_params_” or class “estim_params_.param_vals”.
Error in dynar (line 280)
tmp1 = find(estim_params_.param_vals(:,1)==10);

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

I dont have any idea about the problem, thank you very much for your helo
dynar.mod (2.11 KB)

You cannot use estimated_param_bounds when you did not specify estimated_params.

1 Like

Thank you very much for the answer, so what I have to add in my script to specify estimated_params?

An estimated_params-block. See e.g. the fs2000.mod in the Dynare example folder.

In this file they specify a prior shape prior mean and standard error so it’s for bayesian estimation, how can I tell to Dynare that I want to estimate using maximum likelihood ?

As described in the manual, you only provide the parameter name and the starting value for ML estimation. E.g.

estimated_params; alp, 0.356; gam, 0.0085; mst, 1.0002; rho, 0.129; psi, 0.65; del, 0.02; stderr e_a, 0.035449; stderr e_m, 0.008862; corr e_m, e_a, 0; stderr gp_obs, 0.01; end;

Ok thanks now the following message appears:

You did not declare endogenous variables after the estimation/calib_smoother command.

Error: File: data2.m Line: 1 Column: 3
The input character is not valid in MATLAB statements or expressions.

Error in read_variables (line 72)
eval(basename);

Error in initialize_dataset (line 32)
rawdata = read_variables(datafile,varobs,],xls.sheet,xls.range);

Error in dynare_estimation_init (line 477)
dataset_ =
initialize_dataset(options_.datafile,options_.varobs,options_.first_obs,options_.nobs,transformation,options_.prefilter,xls);

Error in dynare_estimation_1 (line 81)
[dataset_,xparam1, hh, M_, options_, oo_, estim_params_,bayestopt_] =
dynare_estimation_init(var_list_, dname, ], M_, options_, oo_, estim_params_,
bayestopt_);

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

Error in dynar (line 408)
dynare_estimation(var_list_);

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

There is a problem with your data-file. Please post it.

Here is the data file, thank you very much for your disponibility
data2.m (28.1 KB)

The file is not a valid matlab file. It seems to have the wrong ending.

ok originally I have it in excel files. Here is my data. What I have done is change extension from xls to .m what can I do to make it readable by Matlab? (Sorry I discovered Dynare three day’s ago I’m a very beginner)

Then you should use the excel file in Dynare. Do not rename it. See the manual on specifying e.g. xls_range.

I look at the reference manual and try the following different syntax (my xls doc is called data3):
estimation(xls_range = data3) estimation (datafile = data3); estimation(xls_sheet = data3) he always return an error either unexpecting equal either I have to provide a datafile or the same error as before with the m file

That’s not what the manual says. It should be something like:

Thanks professor, you helped me a lot. I still have a problem:
STEADY: The Jacobian contains Inf or NaN. The problem arises from:

STEADY: Derivative of Equation 8 with respect to Variable tlF (initial value of tlF: 1.5)

STEADY: The problem most often occurs, because a variable with
STEADY: exponent smaller than 1 has been initialized to 0. Taking the derivative
STEADY: and evaluating it at the steady state then results in a division by 0.
Error using dynare_solve (line 60)

I change initial values for tlF but I still have the problem, what else can I do?
dynar.mod (2.48 KB)

one of the equation I had write in the model is already loglinearized around the steady is it possible that this is the problem?
Error using dynare_solve (line 60)
An element of the Jacobian is not finite or NaN

Error in evaluate_steady_state (line 66)
[ys,check] = dynare_solve([M.fname ‘_static’],…

Error in dynare_estimation_init (line 496)
[oo_.steady_state, params] =
evaluate_steady_state(oo_.steady_state,M,options_,oo_,steadystate_check_flag);

Error in dynare_estimation_1 (line 81)
[dataset_,xparam1, hh, M_, options_, oo_, estim_params_,bayestopt_] =
dynare_estimation_init(var_list_, dname, ], M_, options_, oo_, estim_params_,
bayestopt_);

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

Error in dynar (line 409)
dynare_estimation(var_list_);

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

No. But before estimation, make sure your model runs with stoch_simul. In your case, see
Remark 2 (Using stoch_simul before Estimation)
and
Remark 15 (initval vs. steady_state_model vs. steadystate-file)
of
Pfeifer(2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models” sites.google.com/site/pfeiferecon/Pfeifer_2013_Observation_Equations.pdf.

when I add stoch_simul before the estimation it provide me this:

Warning: Some of the parameters have no value (rhoz, rhozz, rhozl, rhozx, rhozg, rhol,
rholz, rholl, rholx, rholg, rhox, rhoxz, rhoxl, rhoxx, rhoxg, rhog, rhogz, rhogl, rhogx,
rhogg, rhop, rhopz, rhopl, rhopx, rhopg, rhopp, rhozp, rholp, rhoxp, rhogp) when using
stoch_simul. If these parameters are not initialized in a steadystate file, Dynare may not
be able to solve the model…

In test_for_deep_parameters_calibration at 46
In stoch_simul at 27
In dynar at 406
In dynare at 174

STEADY: The Jacobian contains Inf or NaN. The problem arises from:

STEADY: Derivative of Equation 7 with respect to Variable zF (initial value of zF: 1)
STEADY: Derivative of Equation 8 with respect to Variable zF (initial value of zF: 1)
STEADY: Derivative of Equation 9 with respect to Variable zF (initial value of zF: 1)
STEADY: Derivative of Equation 10 with respect to Variable zF (initial value of zF: 1)
STEADY: Derivative of Equation 11 with respect to Variable zF (initial value of zF: 1)
STEADY: Derivative of Equation 7 with respect to Variable tlF (initial value of tlF: 1.5)
STEADY: Derivative of Equation 8 with respect to Variable tlF (initial value of tlF: 1.5)
STEADY: Derivative of Equation 9 with respect to Variable tlF (initial value of tlF: 1.5)
STEADY: Derivative of Equation 10 with respect to Variable tlF (initial value of tlF: 1.5)
STEADY: Derivative of Equation 11 with respect to Variable tlF (initial value of tlF: 1.5)
STEADY: Derivative of Equation 7 with respect to Variable txF (initial value of txF: 1)
STEADY: Derivative of Equation 8 with respect to Variable txF (initial value of txF: 1)
STEADY: Derivative of Equation 9 with respect to Variable txF (initial value of txF: 1)
STEADY: Derivative of Equation 10 with respect to Variable txF (initial value of txF: 1)
STEADY: Derivative of Equation 11 with respect to Variable txF (initial value of txF: 1)
STEADY: Derivative of Equation 7 with respect to Variable gF (initial value of gF: 0.20444)
STEADY: Derivative of Equation 8 with respect to Variable gF (initial value of gF: 0.20444)
STEADY: Derivative of Equation 9 with respect to Variable gF (initial value of gF: 0.20444)
STEADY: Derivative of Equation 10 with respect to Variable gF (initial value of gF: 0.20444)
STEADY: Derivative of Equation 11 with respect to Variable gF (initial value of gF: 0.20444)
STEADY: Derivative of Equation 7 with respect to Variable pF (initial value of pF: 1)
STEADY: Derivative of Equation 8 with respect to Variable pF (initial value of pF: 1)
STEADY: Derivative of Equation 9 with respect to Variable pF (initial value of pF: 1)
STEADY: Derivative of Equation 10 with respect to Variable pF (initial value of pF: 1)
STEADY: Derivative of Equation 11 with respect to Variable pF (initial value of pF: 1)

STEADY: The problem most often occurs, because a variable with
STEADY: exponent smaller than 1 has been initialized to 0. Taking the derivative
STEADY: and evaluating it at the steady state then results in a division by 0.
Error using dynare_solve (line 60)
An element of the Jacobian is not finite or NaN

Error in evaluate_steady_state (line 66)
[ys,check] = dynare_solve([M.fname ‘_static’],…

Error in resol (line 104)
[dr.ys,M.params,info] = evaluate_steady_state(oo.steady_state,M,options,oo,0);

Error in stoch_simul (line 80)
[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);

Error in dynar (line 406)
info = stoch_simul(var_list_);

Error in dynare (line 174)
evalin(‘base’,fname) ;
dynar.mod (2.47 KB)

should I calibrate the parameters that I want to estimate first, use stoch_simul and then estimate them?

For the Remark 15 this mean that my initial values are far from the steady state?
I’m very sorry