# Problem with estimation_params

Hi,

I’m running a simple RBC model with monopolistic competition and Stone-Geary preferences and try to estimate parameter b (subsistence consumption) using US data for consumption. Here is the code

%preliminary data

cons = xlsread (‘consumption’, 1, ‘A1:A154’);

nobs = 154;
cr = ones(nobs,1);
tr = (1:nobs)’;
for i=1:nobs
tr2(i) = tr(i)^2;
end;

log_cons=log(cons)
const = FOLS(log_cons,[cr tr tr2’]);
c = log_cons-const.beta(2)*tr-const.beta(3)*tr2’; % eliminate quadratic trend
save rawdata_US_1977Q1_2016q3 c;

var c, k, L, A, Y ;

varexo zz ;

parameters alpha, beta, delta, teta, phi, vi, b, niz, n ;

alpha = 0.333; %capital share to match labor share of 2/3 in US KR, 1999 is 0.333;
teta = 6; %elasticity of substitution for goods
phi = 2; %Frisch elasticity, in KR and BGM 4, in villaverde-ramirez 0.85
beta = 0.99; %in KR 0.984
delta = 0.025;
niz = 0.979;
b = 1.19;
vi = 8.15;
n = 2.015;

model;

k=(1-delta)k(-1)+exp(A)k(-1)^alphaL^(1-alpha)-nc;

% L=(((1-alpha)exp(A)k(-1)^alpha)/((c-b)vi))^(phi/(1+alphaphi)); %perf comp
L=(((1-alpha)exp(A)(k(-1)^alpha))
((teta-1)c-bteta)/((c-b)^2
vi))^(phi/(1+alpha*phi)); %mon comp

%(c-b)^(-1)=beta*(1+alphaexp(A(+1))k^(alpha-1)L(+1)^(1-alpha)-delta)((c(+1)-b)^(-1)); %perf comp
((teta-1)c-bteta)
(c-b)^(-2)=beta
(1+alpha*exp(A(+1))k^(alpha-1)L(+1)^(1-alpha)-delta)(((teta-1)c(+1)-bteta)(c(+1)-b)^(-2)); %mon comp

A=niz*A(-1)+zz;

Y=exp(A)*L^(1-alpha)*k^alpha;
end;

initval;

c = 2.1914529;
L = 0.0608807939;
k = 91.041666655;
A = 0;
Y = 0.0608;

end;

shocks;
var zz = 0.0072^2;
end;

estimated_params ;
b, normal_pdf, 1.19, 0.375;
end;

varobs c;

%estimated_params_init(use_calibration);
%end;

estimation(datafile=rawdata_US_1977Q1_2016q3, first_obs=1,nobs=70,mode_compute=5,mode_check,mh_replic=10000,mh_nblocks=2,mh_jscale=0.65,mh_init_scale=0.5,bayesian_irf,moments_varendo) c ;

%estimated_params_init(use_calibration);
%end;

The following error appears:
**Error using schur
First input must be square.
**

I have tried other options for computing the mode. When I run the same code on an earlier version of dynare, it works!

many thanks for any help

ok, here they are. thanks
code.zip (20.9 KB)

I get

that is preliminary work on data, just skip with %, data are saved in dat files

I can run the code. Please try the unstable version and please post the full error message, i.e. including line numbers and the caller stack.

Hi,

This is the message I get

ESTIMATION_CHECKS: There was an error in computing the likelihood for initial parameter values.
ESTIMATION_CHECKS: You should try using the calibrated version of the model as starting values. To do
ESTIMATION_CHECKS: this, add an empty estimated_params_init-block with use_calibration option immediately before the estimation
ESTIMATION_CHECKS: command (and after the estimated_params-block so that it does not get overwritten):

Error using schur
First input must be square.
Error in lyapunov_symm (line 120)
= schur(a);
Error in dsge_likelihood (line 374)
Pstar = lyapunov_symm(T,RQR’,DynareOptions.qz_criterium,DynareOptions.lyapunov_complex_threshold);
Error in initial_estimation_checks (line 47)
[fval,junk1,junk2,a,b,c,d] = feval(objective_function,xparam1,DynareDataset,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults);
Error in dynare_estimation_1 (line 180)
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 Stone_Geary_moments_test (line 186)
dynare_estimation(var_list_);
Error in dynare (line 180)
evalin(‘base’,fname) ;

I’ve installed the latest unstable version in a new directory and could not add the new path to Matlab. should I disinstall the stable version first?

Yes, try that.

this is what I get now

Error using save
Unable to write file Stone_Geary_moments_test/metropolis\Stone_Geary_moments_test_mh_tmp_blck1.mat: Invalid argument.

Error in posterior_sampler_core (line 190)
save([BaseName ‘_mh_tmp_blck’ int2str(curr_block) ‘.mat’],‘x2’,‘logpo2’,‘LastSeeds’);

Error in posterior_sampler (line 121)
fout = posterior_sampler_core(localVars, fblck, nblck, 0);

Error in dynare_estimation_1 (line 418)
posterior_sampler(objective_function,posterior_sampler_options.proposal_distribution,xparam1,posterior_sampler_options,bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_);

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

Error in Stone_Geary_moments_test (line 202)
oo_recursive_=dynare_estimation(var_list_);

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

it got stacked in the MH algorithm

That is strange. Could you please try try a new folder with a short filename.
If that does not work, go to

and set

in line 51 for

many thanks for the precious help! I have tried both options and the second works.

It is strange that the problem had arisen with this code/model. I had tried a similar code for a linear model, using both the stable and the unstable version, and everything was ok. may it depend on the non-linearity of the model?

No, it is not related to linear vs. nonlinear. Something triggers unexpected side effects with Matlab.

Thanks a lot!

something strange happens with this model, the posterior distribution has zero variance:

ESTIMATION RESULTS

Log data density is -2999.101860.

parameters
prior mean post. mean 90% HPD interval prior pstdev

b 0.800 0.8562 0.8562 0.8562 norm 0.0500

Do the mode_check-plots look ok?

It does not, the plot is attached as pdf
mode.zip (20.2 KB)

Then you need to find out what is going on. Did you try a different mode-finder?

I did and the plot is always weird. May it depend on the model being unstable under some parameters configurations? Thanks for your help
Lilia

Something here seems to be fundamentally wrong. Could you please upload a zip-file with the most recent version of the mod-file, the data, and the mode-file you found.

me too, I think something must be wrong but I do not see what. the model is correct. what I’m not completely sure about is the relation between the theoretical and the observed variables. I’ve tried with both per capita consumption and aggregate consumption together with different methods for making these variables stationary. the results are always the same…

thanks a lot, I do appreciate your help
test.zip (97.8 KB)

There is clearly an issue with the mean here. I would recommend using demeaned growth rates for estimation if possible. Related to this, Dynare has a hard time finding the steady state during MCMC. That is where the red dots come from. If the steady state exists for those values of b and Dynare is not able to find them, you might move to a more analytical approach of steady state finding.