Page 1 of 1

Estimation Error

PostPosted: Tue Jul 26, 2016 1:45 am
by Lexes9
Hello,

I am trying to estimate the following model.

Code: Select all
//Small Open Economy with Imperfect pt

var pih pif mc pi Psif x y z c q ystar s pistar i istar  istarobs iobs sobs piobs pistarobs pihobs ystarobs yobs;

varexo eps_pih eps_pif eps_q eps_i eps_z eps_pistar eps_istar eps_ystar;

parameters BETA THETAd THETAf PSI GAMMA SIGMA H ETA RHO_R RHO_Z PSI_PI PSI_Y PSI_E OMEGA_YSTAR OMEGA_PISTAR OMEGA_ISTAR ;

BETA=0.99;

model(linear);

#Kh=((1-THETAd)*(1-(BETA*THETAd)))/THETAd;
#Kf=((1-THETAf)*(1-(BETA*THETAf)))/THETAf;


istarobs=istar;
iobs=i;
sobs=s;
piobs=pi;
pistarobs=pistar;
pihobs=pih;
ystarobs=ystar;
yobs=y;


pih=BETA*pih(+1)+Kh*mc + eps_pih ;                            //1.- Domestic Pi // pih

pif=BETA*pif(+1)+Kf*Psif + eps_pif ;                         //2.- Imported Inflation // pif

pi=pih+GAMMA*(x-x(-1)) ;                                      //3.- CPI Inflation // pi

mc=PSI*y-(1+PSI)*z+GAMMA*x+SIGMA/(1-H)*(c-H*c(-1)) ;         //4.- Marginal Cost // mc

q=(1-GAMMA)*x+Psif ;                                        //5.- Real Exchange Rate // q               

(c-H*c(-1))=(ystar-H*ystar(-1))+(1/SIGMA)*(1-H)*
((1-GAMMA)*x+Psif) ;                                        //6.- Link risk sharing // c

(Psif-Psif(-1))=(s-s(-1))+pistar-pif ;                       //7.- LOP Gap //Psif

(x-x(-1))=pif-pih ;                                         //8.- Terms of Trade //x

(i-pi(+1))-(istar-pistar(+1))=(q(+1)-q)+eps_q;               //9.- UIP //s

(1-GAMMA)*c=y-GAMMA*ETA*Psif-GAMMA*ystar;                     //10.- Market Clearing //y

i=RHO_R*i(-1)+(1-RHO_R)*(PSI_PI*pi+PSI_Y*y+PSI_E*s)+eps_i ;  //11.- Taylor Rule //i

z=RHO_Z*z(-1)+eps_z;                                        //12.- Productivity Shock //z

ystar=OMEGA_YSTAR* ystar(-1) + eps_ystar;

pistar=OMEGA_PISTAR* pistar(-1) + eps_pistar;

istar=OMEGA_ISTAR* istar(-1) + eps_istar;


end;

varobs istarobs iobs sobs piobs pistarobs pihobs ystarobs yobs;

estimated_params;

THETAd, beta_pdf, 0.75, 0.05;
THETAf, beta_pdf, 0.75, 0.05;
PSI, normal_pdf, 1.5, 0.1;
GAMMA, normal_pdf, 0.4, 0.1;
SIGMA, normal_pdf, 3, 0.1;
H, beta_pdf, 0.25, 0.1;
ETA, normal_pdf, 0.7, 0;
RHO_R, beta_pdf, 0.8, 0.1;
RHO_Z, beta_pdf, 0.8, 0.1;
PSI_PI, normal_pdf, 1.5, 0.25;
PSI_Y, normal_pdf, 0.5, 0.25;
PSI_E, uniform_pdf, 0, 1.5;
OMEGA_PISTAR, beta_pdf, 0.8, 0.1;
OMEGA_ISTAR, beta_pdf, 0.8, 0.1;
OMEGA_YSTAR, beta_pdf, 0.8, 0.1;

stderr eps_pih, inv_gamma_pdf, 0.01, inf;
stderr eps_pif, inv_gamma_pdf, 0.01, inf;
stderr eps_q, inv_gamma_pdf, 0.01, inf;
stderr eps_i, inv_gamma_pdf, 0.01, inf;
stderr eps_z, inv_gamma_pdf, 0.01, inf;
stderr eps_pistar, inv_gamma_pdf, 0.01, inf;
stderr eps_istar, inv_gamma_pdf, 0.01, inf;
stderr eps_ystar, inv_gamma_pdf, 0.01, inf;

                                 
end;

estimation(datafile=muestra,mh_nblocks=5,mh_drop=0.45,mh_jscale=0.4,bayesian_irf,irf=20,mode_compute=4);



I also attach the dataset. However, I get the following error:

Error in computing likelihood for initial parameter values
Error using print_info (line 102)
Prior density is not a number (NaN)
Error in print_info (line 102)
error('Prior density is not a number (NaN)');
Error in initial_estimation_checks (line 69)
print_info(info, DynareOptions.noprint, DynareOptions)
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)
dynare_estimation_1(var_list,dname);
Error in estimando (line 274)
dynare_estimation(var_list_);
Error in dynare (line 180)
evalin('base',fname) ;
>>

I don't know what could be causing it. When I simulate the model with calibrated parameters it works.
I appreciate the help.

Thanks in advance.

Re: Estimation Error

PostPosted: Tue Jul 26, 2016 8:26 am
by jpfeifer
The unstable version says:
Error using set_prior (line 160)
Error in prior for ETA: you cannot use a point prior in estimation. Either increase the prior standard deviation or fix the parameter completely.

Choose a standard deviation that is not 0.

Re: Estimation Error

PostPosted: Tue Jul 26, 2016 9:27 am
by Lexes9
Thanks a lot.

Code: Select all
//Small Open Economy with Imperfect pass-through

var pih pif mc pi Psif x y z c q ystar s pistar i istar  istarobs iobs sobs piobs pistarobs pihobs ystarobs yobs;

varexo eps_pih eps_pif eps_q eps_i eps_z eps_pistar eps_istar eps_ystar;

parameters BETA THETAd THETAf PSI GAMMA SIGMA H ETA RHO_R RHO_Z PSI_PI PSI_Y PSI_E OMEGA_YSTAR OMEGA_PISTAR OMEGA_ISTAR ;

BETA=0.99;

model(linear);

#Kh=((1-THETAd)*(1-(BETA*THETAd)))/THETAd;
#Kf=((1-THETAf)*(1-(BETA*THETAf)))/THETAf;


istarobs=istar;
iobs=i;
sobs=s;
piobs=pi;
pistarobs=pistar;
pihobs=pih;
ystarobs=ystar;
yobs=y;


pih=BETA*pih(+1)+Kh*mc + eps_pih ;                            //1.- Domestic Pi // pih

pif=BETA*pif(+1)+Kf*Psif + eps_pif ;                         //2.- Imported Inflation // pif

pi=pih+GAMMA*(x-x(-1)) ;                                      //3.- CPI Inflation // pi

mc=PSI*y-(1+PSI)*z+GAMMA*x+SIGMA/(1-H)*(c-H*c(-1)) ;         //4.- Marginal Cost // mc

q=(1-GAMMA)*x+Psif ;                                        //5.- Real Exchange Rate // q               

(c-H*c(-1))=(ystar-H*ystar(-1))+(1/SIGMA)*(1-H)*
((1-GAMMA)*x+Psif) ;                                        //6.- Link risk sharing // c

(Psif-Psif(-1))=(s-s(-1))+pistar-pif ;                       //7.- LOP Gap //Psif

(x-x(-1))=pif-pih ;                                         //8.- Terms of Trade //x

(i-pi(+1))-(istar-pistar(+1))=(q(+1)-q)+eps_q;               //9.- UIP //s

(1-GAMMA)*c=y-GAMMA*ETA*Psif-GAMMA*ystar;                     //10.- Market Clearing //y

i=RHO_R*i(-1)+(1-RHO_R)*(PSI_PI*pi+PSI_Y*y+PSI_E*s)+eps_i ;  //11.- Taylor Rule //i

z=RHO_Z*z(-1)+eps_z;                                        //12.- Productivity Shock //z

ystar=OMEGA_YSTAR* ystar(-1) + eps_ystar;

pistar=OMEGA_PISTAR* pistar(-1) + eps_pistar;

istar=OMEGA_ISTAR* istar(-1) + eps_istar;


end;

varobs istarobs iobs sobs piobs pistarobs pihobs ystarobs yobs;

estimated_params;

THETAd, beta_pdf, 0.75, 0.05;  //Calvo for domestic prices
THETAf, beta_pdf, 0.75, 0.05;  //Calvo for foreign prices
PSI, normal_pdf, 1.5, 0.1;     //Inverse Elasticity of Labor Supply
GAMMA, normal_pdf, 0.4, 0.1;   //Share of foreign goods in Consumption bundle
SIGMA, normal_pdf, 3, 0.1;     //Inverse of Intertemporal Elasticity of Subs
H, beta_pdf, 0.25, 0.01;       //Habit Formation
ETA, normal_pdf, 0.7, 0.1;     //Elasticity of subs between home and foreign
RHO_R, beta_pdf, 0.8, 0.1;     //Persistence parameters
RHO_Z, beta_pdf, 0.8, 0.1;

PSI_PI, normal_pdf, 1.5, 0.25;  //Policy params
PSI_Y, normal_pdf, 0.5, 0.25;
PSI_E, uniform_pdf, 0, 1.5;

OMEGA_PISTAR, beta_pdf, 0.8, 0.1; //Foreign shocks persistence parameters
OMEGA_ISTAR, beta_pdf, 0.8, 0.1;
OMEGA_YSTAR, beta_pdf, 0.8, 0.1;

stderr eps_pih, inv_gamma_pdf, 0.01, inf; //Shocks
stderr eps_pif, inv_gamma_pdf, 0.01, inf;
stderr eps_q, inv_gamma_pdf, 0.01, inf;
stderr eps_i, inv_gamma_pdf, 0.01, inf;
stderr eps_z, inv_gamma_pdf, 0.01, inf;
stderr eps_pistar, inv_gamma_pdf, 0.01, inf;
stderr eps_istar, inv_gamma_pdf, 0.01, inf;
stderr eps_ystar, inv_gamma_pdf, 0.01, inf;

                                 
end;

estimation(datafile=muestra,mh_nblocks=4,mh_drop=0.45,mh_jscale=0.4,bayesian_irf,irf=20,mode_compute=4);



Now having fixed that, I get this new error:


Error using chol
Matrix must be positive definite.
Error in metropolis_hastings_initialization (line 68)
d = chol(vv);
Error in random_walk_metropolis_hastings (line 63)
metropolis_hastings_initialization(TargetFun, xparam1, vv,
mh_bounds,dataset_,options_,M_,estim_params_,bayestopt_,oo_);
Error in dynare_estimation_1 (line 782)
feval(options_.posterior_sampling_method,objective_function,options_.proposal_distribution,xparam1,invhess,bounds,dataset_,options_,M_,estim_params_,bayestopt_,oo_);
Error in dynare_estimation (line 89)
dynare_estimation_1(var_list,dname);
Error in estimando2 (line 274)
dynare_estimation(var_list_);
Error in dynare (line 180)
evalin('base',fname) ;
Attempt to execute SCRIPT help as a function:
/Users/x/Documents/MATLAB/help.m
Error in matlab.internal.language.introspective.errorDocCallback (line 2)
if ~isempty(help(topic))


What can I do?

Thanks in advance.