Estimation of Third-order model
Posted: Mon Jan 26, 2015 3:04 pm
Dear All,
I would like to use the Dynare 2nd & 3rd order solvers inside a MATLAB function that takes model parameters and data as inputs, in order to compute decision rules that are then used to generate the likelihood (or some other function of the parameters and data). The key issue is that, in order to permit maximization of the likelihood with respect to the model parameters, the decision rules have to be computed INSIDE the Matlab function. (NB I do not want to use the particle filter-based methods available in Dynare.)
For second-order accurate decision rules, this can be done very easily and efficiently, using set_param_value and resol (inside the MATLAB function). Please see simplified code I) below, where MODEL_RBC.mod is a model with two parameters (RISKAV & ELS).
However, this does NOT work for third-order approximations! It seems that, unfortunately, set_param_value cannot be used to pass new parameter values to k_order_pert.
What works for third-order approximations: run the .mod file inside the Matlab function, for each new parameter vector. But this is VERY slow (see simplified code II below).
Is there any other faster method that could be used to compute the 3rd order decision rule repeatedly inside a Matlab function?
I think that this issue is of great interest for all users who want to write code for estimators (or for other optimization problems w.r.t. model parameters) based on higher order Dynare/Dynare++ DSGE model solutions.
Thank you very much for any feedback and advice!
Best, Robert Kollmann; http://www.robertkollmann.com
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
I) CODE (simplified ) THAT WORKS ONLY FOR SECOND-ORDER MODELS
1) MATLAB script file
clear all;
dynare MODEL_RBC.mod
fminsearch(MODEL_LL,x0)
2) MODEL_RBC.mod (steady state is computed in closed form using steady_state_model)
RISKAV=10; ELS=4; //any values can be set here (these values are only used when MODEL_RBC.mod is run for the first time in the script file
stoch_simul(periods=0,order=2,pruning,noprint,nograph,nocorr,…
nofunctions,nomoments,IRF=0);
3)Matlab Function that computes likelihood (L) for parameter vector PARAM
function [L]=MODEL_L(PARAM,DATA)
global oo_ M_ options_
RISKAV1=PARAM(1); % risk aversion
ELS1=PARAM(2); % elasticity of labor supply
set_param_value('RISKAV',RISKAV1);
set_param_value('ELS',ELS1);
[dr,info,M2_,options2_,oo2_] = resol(0,M_,options_,oo_);
//UNFORTUNATELY using k_order_pert here does NOT work
//[dr,info] = k_order_pert(oo_.dr,M_,options_);
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
II. CODE (simplified ) THAT WORKS FOR (SECOND AND) THIRD ORDER MODELS, BUT IS MUCH SLOWER. IS THERE A MORE EFFICIENT SET-UP?
1) MATLAB script file
clear all;
fminsearch(MODEL_LL,x0)
2) MODEL_RBC.mod
load PARAM1
set_param_value('RISKAV',RISKAV1);
set_param_value('ELS',ELS1);
stoch_simul(periods=0,order=3,pruning,noprint,nograph,nocorr,…
nofunctions,nomoments,IRF=0);
3)
function [L]=MODEL_L(PARAM,DATA)
global oo_ M_ options_
RISKAV1=PARAM(1); % risk aversion
ELS1=PARAM(2); % elasticity of labor supply
save PARAM1 RISKAV1 ELS1;
dynare MODEL_RBC.mod noclearall
I would like to use the Dynare 2nd & 3rd order solvers inside a MATLAB function that takes model parameters and data as inputs, in order to compute decision rules that are then used to generate the likelihood (or some other function of the parameters and data). The key issue is that, in order to permit maximization of the likelihood with respect to the model parameters, the decision rules have to be computed INSIDE the Matlab function. (NB I do not want to use the particle filter-based methods available in Dynare.)
For second-order accurate decision rules, this can be done very easily and efficiently, using set_param_value and resol (inside the MATLAB function). Please see simplified code I) below, where MODEL_RBC.mod is a model with two parameters (RISKAV & ELS).
However, this does NOT work for third-order approximations! It seems that, unfortunately, set_param_value cannot be used to pass new parameter values to k_order_pert.
What works for third-order approximations: run the .mod file inside the Matlab function, for each new parameter vector. But this is VERY slow (see simplified code II below).
Is there any other faster method that could be used to compute the 3rd order decision rule repeatedly inside a Matlab function?
I think that this issue is of great interest for all users who want to write code for estimators (or for other optimization problems w.r.t. model parameters) based on higher order Dynare/Dynare++ DSGE model solutions.
Thank you very much for any feedback and advice!
Best, Robert Kollmann; http://www.robertkollmann.com
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
I) CODE (simplified ) THAT WORKS ONLY FOR SECOND-ORDER MODELS
1) MATLAB script file
clear all;
dynare MODEL_RBC.mod
fminsearch(MODEL_LL,x0)
2) MODEL_RBC.mod (steady state is computed in closed form using steady_state_model)
RISKAV=10; ELS=4; //any values can be set here (these values are only used when MODEL_RBC.mod is run for the first time in the script file
stoch_simul(periods=0,order=2,pruning,noprint,nograph,nocorr,…
nofunctions,nomoments,IRF=0);
3)Matlab Function that computes likelihood (L) for parameter vector PARAM
function [L]=MODEL_L(PARAM,DATA)
global oo_ M_ options_
RISKAV1=PARAM(1); % risk aversion
ELS1=PARAM(2); % elasticity of labor supply
set_param_value('RISKAV',RISKAV1);
set_param_value('ELS',ELS1);
[dr,info,M2_,options2_,oo2_] = resol(0,M_,options_,oo_);
//UNFORTUNATELY using k_order_pert here does NOT work
//[dr,info] = k_order_pert(oo_.dr,M_,options_);
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
II. CODE (simplified ) THAT WORKS FOR (SECOND AND) THIRD ORDER MODELS, BUT IS MUCH SLOWER. IS THERE A MORE EFFICIENT SET-UP?
1) MATLAB script file
clear all;
fminsearch(MODEL_LL,x0)
2) MODEL_RBC.mod
load PARAM1
set_param_value('RISKAV',RISKAV1);
set_param_value('ELS',ELS1);
stoch_simul(periods=0,order=3,pruning,noprint,nograph,nocorr,…
nofunctions,nomoments,IRF=0);
3)
function [L]=MODEL_L(PARAM,DATA)
global oo_ M_ options_
RISKAV1=PARAM(1); % risk aversion
ELS1=PARAM(2); % elasticity of labor supply
save PARAM1 RISKAV1 ELS1;
dynare MODEL_RBC.mod noclearall