Home > . > simult.m

simult

PURPOSE ^

Copyright (C) 2001 Michel Juillard

SYNOPSIS ^

function y_=simult(ys, dr)

DESCRIPTION ^

 Copyright (C) 2001 Michel Juillard

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Copyright (C) 2001 Michel Juillard
0002 %
0003 
0004 function y_=simult(ys, dr)
0005 global M_ options_ oo_
0006 global  it_ means_
0007 
0008 order = options_.order;
0009 replic = options_.replic;
0010 seed = options_.simul_seed;
0011 options_.periods = options_.periods;
0012 
0013 it_ = M_.maximum_lag + 1 ;
0014 
0015 if replic > 1
0016   fname = [M_.fname,'_simul'];
0017   fh = fopen(fname,'w+');
0018 end
0019 
0020 % eliminate shocks with 0 variance
0021 i_exo_var = setdiff([1:M_.exo_nbr],find(diag(M_.Sigma_e) == 0));
0022 nxs = length(i_exo_var);
0023 oo_.exo_simul = zeros(M_.maximum_lag+M_.maximum_lead+options_.periods,M_.exo_nbr);
0024 chol_S = chol(M_.Sigma_e(i_exo_var,i_exo_var));
0025 
0026 for i=1:replic
0027   if isempty(seed)
0028     randn('state',sum(100*clock));
0029   else
0030     randn('state',seed+i-1);
0031   end
0032   if ~isempty(M_.Sigma_e)
0033     oo_.exo_simul(:,i_exo_var) = randn(M_.maximum_lag+M_.maximum_lead+options_.periods,nxs)*chol_S;
0034   end
0035   y_ = simult_(ys,dr,oo_.exo_simul,order);
0036   if replic > 1
0037     fwrite(fh,oo_.y_simul(:,M_.maximum_lag+1:end),'float64');
0038   end
0039 end
0040 
0041 if replic > 1
0042   fclose(fh);
0043 end
0044 
0045 
0046 % 02/20/01 MJ replaced ys by dr.ys
0047 % 02/22/01 MJ removed commented out lines
0048 %             removed useless temps
0049 %             stderr_ replaced by M_.Sigma_e
0050 % 02/28/01 MJ changed expression for M_.Sigma_e
0051 % 02/18/03 MJ added ys in the calling sequence for arbitrary initial values
0052 %             suppressed useless calling parameter istoch
0053 % 05/10/03 MJ removed repmat() in call to simult_() for lag > 1
0054 % 05/29/03 MJ test for 0 variances

Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003