请教如何在dynare中做历史方差分解

参数估计应该会遇到历史方差分解吧?我给你发一个dynare的代码,运行后会自动生成一个excel文档。打开后把数据做成图表就是你说的历史方差分解吧?我也在了解细节,因为我不擅长参数估计,所以可能帮不了你。

var x ppi a ii v ppiact

varexo e u errppi

参数βγωφ_ piφ_ yρ_ Aρ_ v;

β= 0.99;

伽马= 1;

ω= 0.8;

phi _ pi = 0.5

phi _ y = 0.5

rho _ A = 0.9

rho _ v = 0.9

模型(线性);

#κ=(1-ω)*(1-ω*β)*(γ+1)/ω;

PPI = beta * PPI(+1)+kappa * x;

x = x(+1)-(ii-PPI(+1))+(rho _ A-1)* A;

ii =(phi _ pi+1)* PPI+phi _ y * x+v;

A = rho _ A * A(-1)+e;

v = rho _ v * v(-1)+u;

ppiact = PPI+err PPI;

结束;

冲击;

var e;stderr 0.5

var u;stderr 0.5

var errppistderr 0.5

结束;

稳;

检查;

estimated _ params

gamma,gamma_pdf,1,0.5;

ω,beta_pdf,0.8,0.1;

phi_pi,gamma_pdf,0.5,0.25;

phi_y,gamma_pdf,0.5,0.25;

rho_A,beta_pdf,0.8,0.05;

rho_v,beta_pdf,0.8,0.1;

stderr e,inv_gamma_pdf,0.5,0.5;

stderr u,inv_gamma_pdf,0.5,0.5;

stderr errppi,inv_gamma_pdf,0.5,0.5;

结束;

varobs x ppiact ii

估计(datafile=dset,mh_replic=125000,mh_drop = 0.25,mh_nblocks=2,mh_jscale=0.7,mode _ compute = 4);

休克_分解;

util _ CSV write(' histdocomp _ x . CSV ',shape(oo_。shock_decomposition(1,:,,5,76)',{'e ',' u ',' errppi ',' init ',' x ' });

util _ CSV write(' histdecop _ pi . CSV ',shape(oo_。shock_decomposition(2,:),5,76)',{'e ',' u ',' errppi ',' init ',' pi ' });

util _ CSV write(' histdocomp _ I . CSV ',shape(oo_。shock_decomposition(4,:),5,76)',{'e ',' u ',' errppi ',' init ',' I ' });

util _ CSV write(' histdecop _ piact . CSV ',shape(oo_。shock_decomposition(6,:),5,76)',{'e ',' u ',' errppi ',' init ',' piact ' });

chain 1 =[];

chain 2 =[];

因为i = 1:11

load(strcat('。/NK _ Linear _ EST/metropolis/NK _ Linear _ EST _ MH ',num2str(i),' _blck1.mat '))

chain 1 =[chain 1;x2];

load(strcat('。/NK _ Linear _ EST/metropolis/NK _ Linear _ EST _ MH ',num2str(i),' _blck2.mat '))

chain 2 =[chain 2;x2];

结束

varnames = {'gamma ',' omega ',' phi_pi ',' phi_y ',' rho_A ',' rho_v ',' stderr_e ',' stderr_u ',' stderr _ err PPI ' };

util _ CSV write(' chain1 . CSV ',chain 1,varnames);

util_csvwrite('chain2.csv ',chain2,varnames);