0001 function simul
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 global M_ options_ oo_
0033
0034 test_for_deep_parameters_calibration(M_);
0035
0036 if options_.stack_solve_algo < 0 || options_.stack_solve_algo > 5
0037 error('SIMUL: stack_solve_algo must be between 0 and 5')
0038 end
0039
0040 if ~options_.block && ~options_.bytecode && options_.stack_solve_algo ~= 0
0041 error('SIMUL: you must use stack_solve_algo=0 when not using block nor bytecode option')
0042 end
0043
0044 if options_.block && ~options_.bytecode && options_.stack_solve_algo == 5
0045 error('SIMUL: you can''t use stack_solve_algo = 5 without bytecode option')
0046 end
0047
0048 if exist('OCTAVE_VERSION') && options_.stack_solve_algo == 2
0049 error('SIMUL: you can''t use stack_solve_algo = 2 under Octave')
0050 end
0051
0052 if size(M_.lead_lag_incidence,2)-nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1,:)) > 0
0053 mess = ['SIMUL: error in model specification : variable ' M_.endo_names(find(M_.lead_lag_incidence(M_.maximum_lag+1,:)==0),:)] ;
0054 mess = [mess ' doesn''t appear as current variable.'] ;
0055 error (mess) ;
0056 end
0057
0058 if options_.periods == 0
0059 error('SIMUL: number of periods for the simulation isn''t specified')
0060 end
0061
0062 if ~ options_.initval_file
0063 if ~isfield(options_,'datafile')
0064 make_ex_;
0065 make_y_;
0066 else
0067 read_data_;
0068 end
0069 end
0070
0071 if isempty(options_.scalv) || options_.scalv == 0
0072 options_.scalv = oo_.steady_state ;
0073 end
0074
0075 options_.scalv= 1 ;
0076
0077 if(options_.block)
0078 if(options_.bytecode)
0079 [info, oo_.endo_simul] = bytecode('dynamic');
0080 mexErrCheck('bytecode', info);
0081 else
0082 eval([M_.fname '_dynamic']);
0083 end;
0084 else
0085 if(options_.bytecode)
0086 [info, oo_.endo_simul]=bytecode('dynamic');
0087 mexErrCheck('bytecode', info);
0088 else
0089 if M_.maximum_endo_lead == 0
0090 error('SIMUL: purely backward models are not supported')
0091 elseif M_.maximum_endo_lag == 1 && M_.maximum_endo_lead == 1
0092 sim1 ;
0093 else
0094 simk;
0095 end;
0096 end;
0097 end;
0098
0099 dyn2vec;