


function y_=simult(y0, dr)
Recursive Monte Carlo simulations
INPUTS
y0: vector of variables in initial period of the simulation
dr: structure of decisions rules for stochastic simulations
OUTPUTS
y_: stochastic simulations results
SPECIAL REQUIREMENTS
none

0001 function y_=simult(y0, dr) 0002 % function y_=simult(y0, dr) 0003 % Recursive Monte Carlo simulations 0004 % 0005 % INPUTS 0006 % y0: vector of variables in initial period of the simulation 0007 % dr: structure of decisions rules for stochastic simulations 0008 % 0009 % OUTPUTS 0010 % y_: stochastic simulations results 0011 % 0012 % SPECIAL REQUIREMENTS 0013 % none 0014 % 0015 0016 % Copyright (C) 2001-2011 Dynare Team 0017 % 0018 % This file is part of Dynare. 0019 % 0020 % Dynare is free software: you can redistribute it and/or modify 0021 % it under the terms of the GNU General Public License as published by 0022 % the Free Software Foundation, either version 3 of the License, or 0023 % (at your option) any later version. 0024 % 0025 % Dynare is distributed in the hope that it will be useful, 0026 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0028 % GNU General Public License for more details. 0029 % 0030 % You should have received a copy of the GNU General Public License 0031 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0032 0033 global M_ options_ oo_ 0034 0035 order = options_.order; 0036 replic = options_.replic; 0037 0038 if replic == 0 0039 replic = 1; 0040 end 0041 0042 if replic > 1 0043 fname = [M_.fname,'_simul']; 0044 fh = fopen(fname,'w+'); 0045 end 0046 0047 % eliminate shocks with 0 variance 0048 i_exo_var = setdiff([1:M_.exo_nbr],find(diag(M_.Sigma_e) == 0)); 0049 nxs = length(i_exo_var); 0050 oo_.exo_simul = zeros(options_.periods,M_.exo_nbr); 0051 chol_S = chol(M_.Sigma_e(i_exo_var,i_exo_var)); 0052 0053 for i=1:replic 0054 if ~isempty(M_.Sigma_e) 0055 oo_.exo_simul(:,i_exo_var) = randn(options_.periods,nxs)*chol_S; 0056 end 0057 y_ = simult_(y0,dr,oo_.exo_simul,order); 0058 % elimninating initial value 0059 y_ = y_(:,2:end); 0060 if replic > 1 0061 fwrite(fh,y_,'float64'); 0062 end 0063 end 0064 0065 if replic > 1 0066 fclose(fh); 0067 end