Home > matlab > global_initialization.m

global_initialization

PURPOSE ^

function global_initialization()

SYNOPSIS ^

function global_initialization()

DESCRIPTION ^

function global_initialization()
 initializes global variables and options for DYNARE

 INPUTS
    none

 OUTPUTS
    none

 SPECIAL REQUIREMENTS
    none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function global_initialization()
0002 %function global_initialization()
0003 % initializes global variables and options for DYNARE
0004 %
0005 % INPUTS
0006 %    none
0007 %
0008 % OUTPUTS
0009 %    none
0010 %
0011 % SPECIAL REQUIREMENTS
0012 %    none
0013 
0014 % Copyright (C) 2003-2012 Dynare Team
0015 %
0016 % This file is part of Dynare.
0017 %
0018 % Dynare is free software: you can redistribute it and/or modify
0019 % it under the terms of the GNU General Public License as published by
0020 % the Free Software Foundation, either version 3 of the License, or
0021 % (at your option) any later version.
0022 %
0023 % Dynare is distributed in the hope that it will be useful,
0024 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0026 % GNU General Public License for more details.
0027 %
0028 % You should have received a copy of the GNU General Public License
0029 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0030 
0031 global oo_ M_ options_ estim_params_ bayestopt_ estimation_info ex0_ ys0_ ...
0032     ex_det0_
0033 
0034 estim_params_ = [];
0035 bayestopt_ = [];
0036 
0037 options_.console_mode = 0;
0038 
0039 options_.verbosity = 1;
0040 
0041 options_.terminal_condition = 0;
0042 options_.rplottype = 0;
0043 options_.smpl = 0;
0044 options_.dynatol.f = 1e-5;
0045 options_.dynatol.x = 1e-5;
0046 options_.maxit_ = 10;
0047 options_.slowc = 1;
0048 options_.timing = 0;
0049 options_.gstep = ones(2,1);
0050 options_.gstep(1) = 1e-2;
0051 options_.gstep(2) = 1.0;
0052 options_.scalv = 1;
0053 options_.debug = 0;
0054 options_.initval_file = 0;
0055 options_.Schur_vec_tol = 1e-11; % used to find nonstationary variables in Schur decomposition of the
0056                                 % transition matrix
0057 options_.qz_criterium = [];
0058 options_.lyapunov_complex_threshold = 1e-15;
0059 options_.solve_tolf = eps^(1/3);
0060 options_.solve_tolx = eps^(2/3);
0061 options_.solve_maxit = 500;
0062 
0063 options_.mode_check_neighbourhood_size = 0.5;
0064 
0065 % Default number of threads for parallelized mex files.
0066 options_.threads.kronecker.A_times_B_kronecker_C = 1;
0067 options_.threads.kronecker.sparse_hessian_times_B_kronecker_C = 1;
0068 options_.threads.local_state_space_iteration_2 = 1;
0069 
0070 % steady state
0071 options_.jacobian_flag = 1;
0072 
0073 % steady state file
0074 if exist([M_.fname '_steadystate2.m'],'file')
0075     options_.steadystate_flag = 2;
0076 elseif exist([M_.fname '_steadystate.m'],'file')
0077     options_.steadystate_flag = 1;
0078 else
0079     options_.steadystate_flag = 0;
0080 end
0081 options_.steadystate_partial = [];
0082 options_.steadystate.nocheck = 0;
0083 
0084 % subset of the estimated deep parameters
0085 options_.ParamSubSet = 'None';
0086 
0087 % bvar-dsge
0088 M_.bvar = [];
0089 options_.dsge_var = 0;
0090 options_.dsge_varlag = 4;
0091 
0092 % BVAR a la Sims
0093 options_.bvar_replic = 2000;
0094 options_.bvar_prior_tau = 3;
0095 options_.bvar_prior_decay = 0.5;
0096 options_.bvar_prior_lambda = 5;
0097 options_.bvar_prior_mu = 2;
0098 options_.bvar_prior_omega = 1;
0099 options_.bvar_prior_flat = 0;
0100 options_.bvar_prior_train = 0;
0101 
0102 % Optimization algorithm [6] gmhmaxlik
0103 options_.Opt6Iter = 2;
0104 options_.Opt6Numb = 5000;
0105 
0106 % Graphics
0107 options_.graphics.nrows = 3;
0108 options_.graphics.ncols = 3;
0109 options_.graphics.line_types = {'b-'};
0110 options_.graphics.line_width = 1;
0111 options_.graph_format = 'eps';
0112 options_.nodisplay = 0;
0113 options_.nograph = 0;
0114 options_.XTick = [];
0115 options_.XTickLabel = [];
0116 
0117 % IRFs & other stoch_simul output
0118 options_.irf = 40;
0119 options_.relative_irf = 0;
0120 options_.ar = 5;
0121 options_.hp_filter = 0;
0122 options_.hp_ngrid = 512;
0123 options_.nomoments = 0;
0124 options_.nocorr = 0;
0125 options_.periods = 0;
0126 options_.noprint = 0;
0127 options_.SpectralDensity.trigger = 0;
0128 options_.SpectralDensity.plot  = 1; 
0129 options_.SpectralDensity.cutoff  = 150; 
0130 options_.SpectralDensity.sdl = 0.01; 
0131 
0132 % Extended path options
0133 %
0134 % Set debug flag
0135 ep.debug = 0;
0136 % Set memory flag
0137 ep.memory = 0;
0138 % Set verbose mode
0139 ep.verbosity = 0;
0140 % Set bytecode flag
0141 ep.use_bytecode = 0;
0142 % Initialization of the perfect foresight equilibrium paths
0143 % * init=0, previous solution is used.
0144 % * init=1, a path generated with the first order reduced form is used.
0145 % * init=2, mix of cases 0 and 1.
0146 ep.init = 0;
0147 % Maximum number of iterations for the deterministic solver.
0148 ep.maxit = 500;
0149 % Number of periods for the perfect foresight model.
0150 ep.periods = 200;
0151 % Default step for increasing the number of periods if needed
0152 ep.step = 50;
0153 % Set check_stability flag
0154 ep.check_stability = 0;
0155 % Define last periods used to test if the solution is stable with respect to an increase in the number of periods.
0156 ep.lp = 5;
0157 % Define first periods used to test if the solution is stable with respect to an increase in the number of periods.
0158 ep.fp = 2;
0159 % Define the distribution for the structural innovations.
0160 ep.innovation_distribution = 'gaussian';
0161 % Set flag for the seed
0162 ep.set_dynare_seed_to_default = 1;
0163 % Set algorithm for the perfect foresight solver
0164 ep.stack_solve_algo = 4;
0165 % Stochastic extended path related options.
0166 ep.stochastic.method = 'tensor';
0167 ep.stochastic.ortpol = 'hermite';
0168 ep.stochastic.order = 0;
0169 ep.stochastic.nodes = 5;
0170 ep.stochastic.pruned.status = 0;
0171 ep.stochastic.pruned.relative = 1e-5;
0172 ep.stochastic.pruned.level = 1e-5;
0173 % Copy ep structure in options_ global structure
0174 options_.ep = ep;
0175 
0176 
0177 % Particle filter
0178 %
0179 % Default is that we do not use the non linear kalman filter
0180 particle.status = 0;
0181 % How do we initialize the states?
0182 particle.initialization = 1;
0183 particle.initial_state_prior_std = .0001;
0184 % Set the default order of approximation of the model (perturbation).
0185 particle.perturbation = 2;
0186 % Set the default number of particles.
0187 particle.number_of_particles = 500;
0188 % Set the default approximation order (Smolyak)
0189 particle.smolyak_accuracy = 3;
0190 % By default we don't use pruning
0191 particle.pruning = 0;
0192 % Set default algorithm
0193 particle.algorithm = 'sequential_importance_particle_filter';
0194 % Set the Gaussian approximation method
0195 particle.approximation_method = 'unscented';
0196 % Set unscented parameters alpha, beta and kappa for gaussian approximation
0197 particle.unscented.alpha = 1;
0198 particle.unscented.beta = 2;
0199 particle.unscented.kappa = 1;
0200 % Configuration of resampling in case of particles
0201 particle.resampling.status = 'systematic'; % 'none', 'generic', 'smoothed'
0202 particle.resampling.neff_threshold = .5;
0203 % Choice of the resampling method
0204 particle.resampling.method1 = 'traditional' ;
0205 particle.resampling.method2 = 'kitagawa';
0206 % Number of partitions for the smoothed resampling method
0207 DynareOptions.particle.resampling.number_of_partitions = 200;
0208 % Configuration of the mixture filters
0209 particle.mixture_method = 'particles' ;
0210 % Size of the different mixtures
0211 particle.mixture_state_variables = 5 ;
0212 particle.mixture_structural_shocks = 1 ;
0213 particle.mixture_measurement_shocks = 1 ;
0214 % Copy ep structure in options_ global structure
0215 options_.particle = particle;
0216 
0217 % TeX output
0218 options_.TeX = 0;
0219 
0220 % Exel
0221 options_.xls_sheet = '';
0222 options_.xls_range = '';
0223 
0224 % Prior draws
0225 options_.forecast = 0;
0226 
0227 % Model
0228 options_.linear = 0;
0229 
0230 % Deterministic simulation
0231 options_.stack_solve_algo = 0;
0232 options_.markowitz = 0.5;
0233 options_.minimal_solving_periods = 1;
0234 
0235 % Solution
0236 options_.order = 2;
0237 options_.pruning = 0;
0238 options_.solve_algo = 2;
0239 options_.linear = 0;
0240 options_.replic = 50;
0241 options_.drop = 100;
0242 % if mjdgges.dll (or .mexw32 or ....) doesn't exist, matlab/qz is added to the path.
0243 % There exists now qz/mjdgges.m that contains the calls to the old Sims code
0244 % Hence, if mjdgges.m is visible exist(...)==2,
0245 % this means that the DLL isn't avaiable and use_qzdiv is set to 1
0246 if exist('mjdgges','file')==2
0247     options_.use_qzdiv = 1;
0248 else
0249     options_.use_qzdiv = 0;
0250 end
0251 options_.aim_solver = 0; % i.e. by default do not use G.Anderson's AIM solver, use mjdgges instead
0252 options_.k_order_solver=0; % by default do not use k_order_perturbation but mjdgges
0253 options_.partial_information = 0;
0254 options_.ACES_solver = 0;
0255 options_.conditional_variance_decomposition = [];
0256 
0257 % Ramsey policy
0258 options_.ramsey_policy = 0;
0259 options_.timeless = 0;
0260 
0261 % estimation
0262 estimation_info.empty_prior = struct(...
0263     'domain', [], 'interval', [], 'mean', [], ...
0264     'median', [], 'mode', [], 'shape', [], ...
0265     'shift', [], 'stdev', [], 'truncate', [], 'variance', []);
0266 estimation_info.empty_options = struct(...
0267     'bounds',[], 'init', [], 'jscale', []);
0268 estimation_info.subsamples.range = struct('date1', [], 'date2', []);
0269 estimation_info.parameter.prior = estimation_info.empty_prior;
0270 estimation_info.parameter.subsample_prior = estimation_info.empty_prior;
0271 estimation_info.parameter.options = estimation_info.empty_options;
0272 estimation_info.parameter.subsample_options = estimation_info.empty_options;
0273 estimation_info.structural_innovation.prior = estimation_info.empty_prior;
0274 estimation_info.structural_innovation.subsample_prior = estimation_info.empty_prior;
0275 estimation_info.structural_innovation.options = estimation_info.empty_options;
0276 estimation_info.structural_innovation.subsample_options = estimation_info.empty_options;
0277 estimation_info.structural_innovation_corr.prior = estimation_info.empty_prior;
0278 estimation_info.structural_innovation_corr.subsample_prior = estimation_info.empty_prior;
0279 estimation_info.structural_innovation_corr.options = estimation_info.empty_options;
0280 estimation_info.structural_innovation_corr.subsample_options = estimation_info.empty_options;
0281 estimation_info.measurement_error.prior = estimation_info.empty_prior;
0282 estimation_info.measurement_error.subsample_prior = estimation_info.empty_prior;
0283 estimation_info.measurement_error.options = estimation_info.empty_options;
0284 estimation_info.measurement_error.subsample_options = estimation_info.empty_options;
0285 estimation_info.measurement_error_corr.prior = estimation_info.empty_prior;
0286 estimation_info.measurement_error_corr.subsample_prior = estimation_info.empty_prior;
0287 estimation_info.measurement_error_corr.options = estimation_info.empty_options;
0288 estimation_info.measurement_error_corr.subsample_options = estimation_info.empty_options;
0289 estimation_info.subsamples_index = {};
0290 estimation_info.subsamples.range_index = {};
0291 estimation_info.parameter_prior_index = {};
0292 estimation_info.parameter_options_index = {};
0293 estimation_info.parameter.range_index = {};
0294 estimation_info.measurement_error_prior_index = {};
0295 estimation_info.measurement_error_options_index = {};
0296 estimation_info.measurement_error.range_index = {};
0297 estimation_info.structural_innovation_prior_index = {};
0298 estimation_info.structural_innovation_options_index = {};
0299 estimation_info.structural_innovation.range_index = {};
0300 estimation_info.measurement_error_corr_prior_index = {};
0301 estimation_info.measurement_error_corr_options_index = {};
0302 estimation_info.measurement_error_corr.range_index = {};
0303 estimation_info.structural_innovation_corr_prior_index = {};
0304 estimation_info.structural_innovation_corr_options_index = {};
0305 estimation_info.structural_innovation_corr.range_index = {};
0306 options_.initial_period = dynDate(1);
0307 options_.dataset.firstobs = options_.initial_period;
0308 options_.dataset.lastobs = NaN;
0309 options_.dataset.nobs = NaN;
0310 options_.dataset.xls_sheet = NaN;
0311 options_.dataset.xls_range = NaN;
0312 options_.Harvey_scale_factor = 10;
0313 options_.MaxNumberOfBytes = 1e6;
0314 options_.MaximumNumberOfMegaBytes = 111;
0315 options_.PosteriorSampleSize = 1000;
0316 options_.analytic_derivation = 0;
0317 options_.bayesian_irf = 0;
0318 options_.bayesian_th_moments = 0;
0319 options_.diffuse_filter = 0;
0320 options_.filter_step_ahead = [];
0321 options_.filtered_vars = 0;
0322 options_.first_obs = 1;
0323 options_.kalman_algo = 0;
0324 options_.kalman_tol = 1e-10;
0325 options_.riccati_tol = 1e-6;
0326 options_.lik_algo = 1;
0327 options_.lik_init = 1;
0328 options_.load_mh_file = 0;
0329 options_.logdata = 0;
0330 options_.loglinear = 0;
0331 options_.mh_conf_sig = 0.90;
0332 options_.prior_interval = 0.90;
0333 options_.mh_drop = 0.5;
0334 options_.mh_jscale = 0.2;
0335 options_.mh_init_scale = 2*options_.mh_jscale;
0336 options_.mh_mode = 1;
0337 options_.mh_nblck = 2;
0338 options_.mh_recover = 0;
0339 options_.mh_replic = 20000;
0340 options_.mode_check = 0;
0341 options_.mode_check_nolik = 0;
0342 options_.mode_compute = 4;
0343 options_.mode_file = '';
0344 options_.moments_varendo = 0;
0345 options_.nk = 1;
0346 options_.noconstant = 0;
0347 options_.nodiagnostic = 0;
0348 options_.mh_posterior_mode_estimation = 0;
0349 options_.prefilter = 0;
0350 options_.presample = 0;
0351 options_.prior_trunc = 1e-10;
0352 options_.smoother = 0;
0353 options_.student_degrees_of_freedom = 3;
0354 options_.sub_draws = [];
0355 options_.use_mh_covariance_matrix = 0;
0356 options_.gradient_method = 2;
0357 options_.gradient_epsilon = 1e-6;
0358 options_.posterior_sampling_method = 'random_walk_metropolis_hastings';
0359 options_.proposal_distribution = 'rand_multivariate_normal';
0360 options_.student_degrees_of_freedom = 3;
0361 options_.trace_plot_ma = 200;
0362 options_.mh_autocorrelation_function_size = 30;
0363 options_.plot_priors = 1;
0364 options_.cova_compute = 1;
0365 options_.parallel = 0;
0366 options_.parallel_info.leaveSlaveOpen = 0;
0367 options_.parallel_info.RemoteTmpFolder = '';
0368 options_.number_of_grid_points_for_kde = 2^9;
0369 quarter = 1;
0370 years = [1 2 3 4 5 10 20 30 40 50];
0371 options_.conditional_variance_decomposition_dates = zeros(1,length(years));
0372 for i=1:length(years)
0373     options_.conditional_variance_decomposition_dates(i) = ...
0374         (years(i)-1)*4+quarter;
0375 end
0376 options_.filter_covariance = 0;
0377 options_.filter_decomposition = 0;
0378 options_.selected_variables_only = 0;
0379 options_.initialize_estimated_parameters_with_the_prior_mode = 0;
0380 options_.estimation_dll = 0;
0381 % Misc
0382 options_.conf_sig = 0.6;
0383 oo_.exo_simul = [];
0384 oo_.endo_simul = [];
0385 ys0_ = [];
0386 ex0_ = [];
0387 ex_det0_ = [];
0388 oo_.dr = [];
0389 oo_.exo_steady_state = [];
0390 oo_.exo_det_steady_state = [];
0391 oo_.exo_det_simul = [];
0392 
0393 M_.params = [];
0394 M_.endo_histval = [];
0395 
0396 % homotopy
0397 options_.homotopy_mode = 0;
0398 options_.homotopy_steps = 1;
0399 options_.homotopy_force_continue = 0;
0400 
0401 % Simplex optimization routine (variation on Nelder Mead algorithm).
0402 options_.simplex = [];
0403 
0404 % CMAES optimization routine.
0405 cmaes.SaveVariables='off';
0406 cmaes.DispFinal='on';
0407 cmaes.WarnOnEqualFunctionValues='no';
0408 cmaes.DispModulo='10';
0409 cmaes.LogModulo='0';
0410 cmaes.LogTime='0';
0411 options_.cmaes = cmaes;
0412 
0413 
0414 % prior analysis
0415 options_.prior_mc = 20000;
0416 options_.prior_analysis_endo_var_list = [];
0417 
0418 % did model undergo block decomposition + minimum feedback set computation ?
0419 options_.block = 0;
0420 
0421 % model evaluated using a compiled MEX
0422 options_.use_dll = 0;
0423 
0424 % model evaluated using bytecode.dll
0425 options_.bytecode = 0;
0426 
0427 % if equal to 1 use a fixed point method to solve Sylvester equation (for large scale models)
0428 options_.sylvester_fp = 0;
0429 
0430 % convergence criteria to solve iteratively a sylvester equations
0431 options_.sylvester_fixed_point_tol = 1e-12;
0432 
0433 % if 1 use a fixed point method to solve Lyapunov equation (for large scale models)
0434 options_.lyapunov_fp = 0;
0435 % if 1 use a doubling algorithm to solve Lyapunov equation (for large scale models)
0436 options_.lyapunov_db = 0;
0437 % if 1 use a squre root solver to solve Lyapunov equation (for large scale models)
0438 options_.lyapunov_srs = 0;
0439 
0440 % convergence criterion for iteratives methods to solve lyapunov equations
0441 options_.lyapunov_fixed_point_tol = 1e-10;
0442 options_.lyapunov_doubling_tol = 1e-16;
0443 
0444 % dates for historical time series
0445 options_.initial_date.freq = 1;
0446 options_.initial_date.period = 1;
0447 options_.initial_date.subperiod = 0;
0448 
0449 % discretionary policy
0450 options_.discretionary_policy = 0;
0451 options_.discretionary_tol = 1e-7;
0452 
0453 % Shock decomposition
0454 options_.parameter_set = [];
0455 
0456 % Nonlinearfilters
0457 options_.nonlinear_filter = [];
0458 
0459 % SBVAR & MS SBVAR initializations:
0460 % SBVAR
0461 options_.ms.vlistlog = [];
0462 options_.ms.restriction_fname = 0;
0463 options_.ms.cross_restrictions = 0;
0464 options_.ms.contemp_reduced_form = 0;
0465 options_.ms.real_pseudo_forecast = 0;
0466 options_.ms.dummy_obs = 0;
0467 options_.ms.ncsk = 0;
0468 options_.ms.indxgforhat = 1;
0469 options_.ms.indxgimfhat = 1;
0470 options_.ms.indxestima = 1;
0471 options_.ms.indxgdls = 1;
0472 options_.ms.cms =0;
0473 options_.ms.ncms = 0;
0474 options_.ms.eq_cms = 1;
0475 options_.ms.banact = 1;
0476 options_.ms.log_var = [];
0477 options_.ms.Qi = [];
0478 options_.ms.Ri = [];
0479 options_.ms.lower_cholesky = 0;
0480 options_.ms.upper_cholesky = 0;
0481 options_.ms.constants_exclusion = 0;
0482 %options_.ms.nstates = 2;
0483 %options_.ms.indxscalesstates = 0;
0484 %options_.ms.q_diag = 0.85;
0485 %options_.ms.flat_prior = 0;
0486 %options_.ms.nstd = 6;
0487 %options_.ms.ninv = 1000;
0488 %options_.ms.indxparr = 1;
0489 %options_.ms.indxovr = 0;
0490 %options_.ms.aband = 1;
0491 %options_.ms.indxap = 1;
0492 %options_.ms.apband = 1;
0493 %options_.ms.indximf = 1;
0494 %options_.ms.imfband = 1;
0495 %options_.ms.indxfore = 0;
0496 %options_.ms.foreband = 0;
0497 %options_.ms.cnum = 0;
0498 
0499 % MS SBVAR (and some SBVAR)
0500 options_ = initialize_ms_sbvar_options(M_, options_);
0501 
0502 % saved graph formats
0503 options_.graph_save_formats.eps = 1;
0504 options_.graph_save_formats.pdf = 0;
0505 options_.graph_save_formats.fig = 0;
0506 
0507 options_.risky_steadystate = 0;
0508 
0509 % initialize persistent variables in priordens()
0510 priordens([],[],[],[],[],[],1);
0511 
0512 % Set dynare random generator and seed.
0513 set_dynare_seed('default');
0514 
0515 % Create directories
0516 [junk,junk]=mkdir(M_.fname);
0517 [junk,junk]=mkdir([M_.fname '/Output']);
0518 
0519 % Load user configuration file.
0520 if isunix
0521     origin = pwd;
0522     cd('~/')
0523     if exist('dynare_configuration.m')
0524         dynare_configuration;
0525     end
0526     cd(origin)
0527 end

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005