Calibration to match second moments of real data

Hi all

I want to calibrate parameters (eta & rho) to match the second moments of real data (variance and autocorrelation of output). But I have no idea how to calibrate in this way. I tried to follow this post, but I don’t know why my matlab can not resolve oo_.var (maybe I make a mistake here). Can someone give me some suggestions about the coding.

My mod file and m file are uploaded.

Thanks.
Ben
yy.mod (1.3 KB)
Untitled3.m (663 Bytes)

In Dynare 5.0,

eta_start=0.68;
target_moments=3.71;
var_list_={'y'};
dynare yy;
options_.noprint=1;
options_.nocorr=1;
options_.nofunctions=1;

eta_opt=fsolve(@(eta)moment_distance(eta,target_moments,M_, options_, oo_,var_list_),eta_start)


function V = moment_distance(eta,target_moments,M_, options_, oo_,var_list_)
M_.params(strmatch('eta',M_.param_names,'exact'))=eta;
[info, oo_] = stoch_simul(M_, options_, oo_, var_list_);
if info(1)==0
    V=oo_.var(1,1)-target_moments^2
end
end

should work. But be careful with parameter dependence in your mod-file.

Yes, thank you very much.