by macroresearch123 » Thu Jul 02, 2015 7:51 pm
Hi Johannes,
I spent some additional time looking at this, but I might still be misunderstanding; I added:
global moments_model oo_ M_ options_
in both matlab files. What do you mean "use the same statement within your objective function" -- what statement, the global? My objective function is:
gmm=(moments_data - moments_model)'*weight*(moments_data - moments_model)
which is assembled after calling dynare to get the simulated moments.
Just to make sure we both are talking about the same problem -- feel free to skip this if you know we're talking about the same thing -- the issue that I was running into was that I had computed all my empirical moments with the code for doing smm, and then call the dynare file; but, after I call the file and introduce the objective function (moments_data - moments_simulated), the dynare simulations dont show up. It's odd to explain -- the dynare simulations show up after I let it run, but while it's running the dynare produced simulations dont show, and thus the program doesnt work since the simulations dont show up "in time".
I was hoping to get this working in my original format since I don't understand yours entirely in your paper -- although you did nice job documenting it, excellent compared the the vast majority of paper documentation! Just to better understand your lines of code, maybe I could clarify a few additional things:
The line below feeds in the simulated data and computes the relevant moments?
[moments_short]=get_quarterly_moments(out_withshock(:,:,1:200),ergodicmean_no_shocks,M_,oo_);
What's the difference with the below (is it that there are only a subset of moments here?)
// moments_short(9,:)=[nx_y_share nx_y_share];
[moments_long, row_names, column_names, std_nx]=get_quarterly_moments(out_withshock,ergodicmean_no_shocks,M_,oo_);
Related to mharding's point:
Are sigma_x, phipar,D_bar,exp(phi) the only parameters you are trying to calibrate? This code below is where you're actually calling the optimizer to do smm? (in my case, I have a separate matlab file.)
@#if estimation == 1
x_start=[sigma_x,phipar,D_bar,exp(Phi)]; //use calibration as starting point
target=[moments_emp(1:3);moments_emp(8)]'; //define target moments
//optimizer options
H0 = 1e-2*eye(length(x_start)); //Initial Hessian
crit = 1e-7; //Tolerance
nit = 1000; //Number of iterations
//make sure Dynare does not print out stuff during runs
options_.nocorr=1;
options_.noprint=1;
options_.verbosity=0;
//options_.qz_criterium = 1+1e-6; //required because it is empty by default, leading to a crash in k_order_pert
[fhat,xhat] = csminwel(@smm_diff_function,x_start,H0,[],crit,nit,target,estimation_replications,shock_mat(:,:,1:estimation_replications));
@# endif
Again, excellent advice and appreciate your sharing all your expertise!