I use the code below to generate time series in Dynare. My shock matrix "Model.Sigma_e" is iid, (diagonal). But when I use this code I don't get the same standard deviations for the observed variables. std_sim=std(Yt(DynareOptions.varobs_id,:)') is not equal to when I calculate the standard deviations after I run stoch_simul(order=1, periods=110000, nograph) dY dC dinvestment dW n_obs inflation R_fed
in Dynare. So I basically wonder how are the times series (more specifically) in Dynare created when using stochsimul?
YSS=DynareResults.dr.ys;
A=DynareResults.dr.ghx;
B=DynareResults.dr.ghu;
Yt(:,1)=YSS;
% shock_vec=zeros(size(B,2),1);
% shock_vec(2)=1;
klockan=clock;
randn('seed',klockan(end)*1000);
shock_mat=mvnrnd(zeros(size(Model.Sigma_e,1),1),sqrt(Model.Sigma_e),100000)';
for i=1:size(shock_mat,2)
Yt(DynareResults.dr.order_var,1+i)= YSS(DynareResults.dr.order_var) + A*(Yt(DynareResults.dr.state_var,i)-YSS(DynareResults.dr.state_var))+B*shock_mat(:,i);
end