method_of_moments.m: Octave compatibility fix

Octave does not support randstream; related to https://git.dynare.org/Dynare/dynare/-/issues/1749
time-shift
Johannes Pfeifer 2020-11-19 10:07:35 +01:00
parent 68f60bc411
commit e42654b812
1 changed files with 11 additions and 3 deletions

View File

@ -632,9 +632,17 @@ if strcmp(options_mom_.mom.mom_method,'SMM')
options_mom_.mom.long = round(options_mom_.mom.simulation_multiple*options_mom_.nobs);
options_mom_.mom.variance_correction_factor = (1+1/options_mom_.mom.simulation_multiple);
% draw shocks for SMM
smmstream = RandStream('mt19937ar','Seed',options_mom_.mom.seed);
temp_shocks = randn(smmstream,options_mom_.mom.long+options_mom_.mom.burnin,M_.exo_nbr);
temp_shocks_ME = randn(smmstream,options_mom_.mom.long,length(M_.H));
if ~isoctave
smmstream = RandStream('mt19937ar','Seed',options_mom_.mom.seed);
temp_shocks = randn(smmstream,options_mom_.mom.long+options_mom_.mom.burnin,M_.exo_nbr);
temp_shocks_ME = randn(smmstream,options_mom_.mom.long,length(M_.H));
else
[state_u,state_n] = get_dynare_random_generator_state; %get state for later resetting
set_dynare_random_generator_state(options_mom_.mom.seed,options_mom_.mom.seed);
temp_shocks = randn(options_mom_.mom.long+options_mom_.mom.burnin,M_.exo_nbr);
temp_shocks_ME = randn(options_mom_.mom.long,length(M_.H));
set_dynare_random_generator_state(state_u,state_n); %reset state for later resetting
end
if options_mom_.mom.bounded_shock_support == 1
temp_shocks(temp_shocks>2) = 2;
temp_shocks(temp_shocks<-2) = -2;