%
% Status : main Dynare file
%
% Warning : this file is generated automatically by Dynare
%           from model file (.mod)

if isoctave || matlab_ver_less_than('8.6')
    clear all
else
    clearvars -global
    clear_persistent_variables(fileparts(which('dynare')), false)
end
tic0 = tic;
% Define global variables.
global M_ options_ oo_ estim_params_ bayestopt_ dataset_ dataset_info estimation_info ys0_ ex0_
options_ = [];
M_.fname = 'ex1dsg';
M_.dynare_version = '5.0';
oo_.dynare_version = '5.0';
options_.dynare_version = '5.0';
%
% Some global variables initialization
%
global_initialization;
M_.exo_names = cell(3,1);
M_.exo_names_tex = cell(3,1);
M_.exo_names_long = cell(3,1);
M_.exo_names(1) = {'em'};
M_.exo_names_tex(1) = {'em'};
M_.exo_names_long(1) = {'em'};
M_.exo_names(2) = {'piestar'};
M_.exo_names_tex(2) = {'piestar'};
M_.exo_names_long(2) = {'piestar'};
M_.exo_names(3) = {'Rw'};
M_.exo_names_tex(3) = {'Rw'};
M_.exo_names_long(3) = {'Rw'};
M_.endo_names = cell(22,1);
M_.endo_names_tex = cell(22,1);
M_.endo_names_long = cell(22,1);
M_.endo_names(1) = {'c'};
M_.endo_names_tex(1) = {'c'};
M_.endo_names_long(1) = {'c'};
M_.endo_names(2) = {'lambtil'};
M_.endo_names_tex(2) = {'lambtil'};
M_.endo_names_long(2) = {'lambtil'};
M_.endo_names(3) = {'l'};
M_.endo_names_tex(3) = {'l'};
M_.endo_names_long(3) = {'l'};
M_.endo_names(4) = {'w'};
M_.endo_names_tex(4) = {'w'};
M_.endo_names_long(4) = {'w'};
M_.endo_names(5) = {'rstar'};
M_.endo_names_tex(5) = {'rstar'};
M_.endo_names_long(5) = {'rstar'};
M_.endo_names(6) = {'pies'};
M_.endo_names_tex(6) = {'pies'};
M_.endo_names_long(6) = {'pies'};
M_.endo_names(7) = {'pie'};
M_.endo_names_tex(7) = {'pie'};
M_.endo_names_long(7) = {'pie'};
M_.endo_names(8) = {'r'};
M_.endo_names_tex(8) = {'r'};
M_.endo_names_long(8) = {'r'};
M_.endo_names(9) = {'cn'};
M_.endo_names_tex(9) = {'cn'};
M_.endo_names_long(9) = {'cn'};
M_.endo_names(10) = {'ct'};
M_.endo_names_tex(10) = {'ct'};
M_.endo_names_long(10) = {'ct'};
M_.endo_names(11) = {'pn'};
M_.endo_names_tex(11) = {'pn'};
M_.endo_names_long(11) = {'pn'};
M_.endo_names(12) = {'pt'};
M_.endo_names_tex(12) = {'pt'};
M_.endo_names_long(12) = {'pt'};
M_.endo_names(13) = {'delnl'};
M_.endo_names_tex(13) = {'delnl'};
M_.endo_names_long(13) = {'delnl'};
M_.endo_names(14) = {'yn'};
M_.endo_names_tex(14) = {'yn'};
M_.endo_names_long(14) = {'yn'};
M_.endo_names(15) = {'pnstar'};
M_.endo_names_tex(15) = {'pnstar'};
M_.endo_names_long(15) = {'pnstar'};
M_.endo_names(16) = {'pien'};
M_.endo_names_tex(16) = {'pien'};
M_.endo_names_long(16) = {'pien'};
M_.endo_names(17) = {'fbarn'};
M_.endo_names_tex(17) = {'fbarn'};
M_.endo_names_long(17) = {'fbarn'};
M_.endo_names(18) = {'gdp'};
M_.endo_names_tex(18) = {'gdp'};
M_.endo_names_long(18) = {'gdp'};
M_.endo_names(19) = {'bstar'};
M_.endo_names_tex(19) = {'bstar'};
M_.endo_names_long(19) = {'bstar'};
M_.endo_names(20) = {'delta'};
M_.endo_names_tex(20) = {'delta'};
M_.endo_names_long(20) = {'delta'};
M_.endo_names(21) = {'py'};
M_.endo_names_tex(21) = {'py'};
M_.endo_names_long(21) = {'py'};
M_.endo_names(22) = {'tb'};
M_.endo_names_tex(22) = {'tb'};
M_.endo_names_long(22) = {'tb'};
M_.endo_partitions = struct();
M_.param_names = cell(16,1);
M_.param_names_tex = cell(16,1);
M_.param_names_long = cell(16,1);
M_.param_names(1) = {'beta'};
M_.param_names_tex(1) = {'beta'};
M_.param_names_long(1) = {'beta'};
M_.param_names(2) = {'sigma'};
M_.param_names_tex(2) = {'sigma'};
M_.param_names_long(2) = {'sigma'};
M_.param_names(3) = {'psi'};
M_.param_names_tex(3) = {'psi'};
M_.param_names_long(3) = {'psi'};
M_.param_names(4) = {'theta'};
M_.param_names_tex(4) = {'theta'};
M_.param_names_long(4) = {'theta'};
M_.param_names(5) = {'gamma'};
M_.param_names_tex(5) = {'gamma'};
M_.param_names_long(5) = {'gamma'};
M_.param_names(6) = {'alphan'};
M_.param_names_tex(6) = {'alphan'};
M_.param_names_long(6) = {'alphan'};
M_.param_names(7) = {'epsilon'};
M_.param_names_tex(7) = {'epsilon'};
M_.param_names_long(7) = {'epsilon'};
M_.param_names(8) = {'zeta'};
M_.param_names_tex(8) = {'zeta'};
M_.param_names_long(8) = {'zeta'};
M_.param_names(9) = {'rho'};
M_.param_names_tex(9) = {'rho'};
M_.param_names_long(9) = {'rho'};
M_.param_names(10) = {'alphapie'};
M_.param_names_tex(10) = {'alphapie'};
M_.param_names_long(10) = {'alphapie'};
M_.param_names(11) = {'alphay'};
M_.param_names_tex(11) = {'alphay'};
M_.param_names_long(11) = {'alphay'};
M_.param_names(12) = {'phi'};
M_.param_names_tex(12) = {'phi'};
M_.param_names_long(12) = {'phi'};
M_.param_names(13) = {'piebar'};
M_.param_names_tex(13) = {'piebar'};
M_.param_names_long(13) = {'piebar'};
M_.param_names(14) = {'pT'};
M_.param_names_tex(14) = {'pT'};
M_.param_names_long(14) = {'pT'};
M_.param_names(15) = {'L'};
M_.param_names_tex(15) = {'L'};
M_.param_names_long(15) = {'L'};
M_.param_names(16) = {'stb'};
M_.param_names_tex(16) = {'stb'};
M_.param_names_long(16) = {'stb'};
M_.param_partitions = struct();
M_.exo_det_nbr = 0;
M_.exo_nbr = 3;
M_.endo_nbr = 22;
M_.param_nbr = 16;
M_.orig_endo_nbr = 22;
M_.aux_vars = [];
M_ = setup_solvers(M_);
M_.Sigma_e = zeros(3, 3);
M_.Correlation_matrix = eye(3, 3);
M_.H = 0;
M_.Correlation_matrix_ME = 1;
M_.sigma_e_is_diagonal = true;
M_.det_shocks = [];
M_.surprise_shocks = [];
M_.heteroskedastic_shocks.Qvalue_orig = [];
M_.heteroskedastic_shocks.Qscale_orig = [];
options_.linear = false;
options_.block = false;
options_.bytecode = false;
options_.use_dll = false;
M_.nonzero_hessian_eqs = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22];
M_.hessian_eq_zero = isempty(M_.nonzero_hessian_eqs);
M_.orig_eq_nbr = 22;
M_.eq_nbr = 22;
M_.ramsey_eq_nbr = 0;
M_.set_auxiliary_variables = exist(['./+' M_.fname '/set_auxiliary_variables.m'], 'file') == 2;
M_.epilogue_names = {};
M_.epilogue_var_list_ = {};
M_.orig_maximum_endo_lag = 1;
M_.orig_maximum_endo_lead = 1;
M_.orig_maximum_exo_lag = 0;
M_.orig_maximum_exo_lead = 0;
M_.orig_maximum_exo_det_lag = 0;
M_.orig_maximum_exo_det_lead = 0;
M_.orig_maximum_lag = 1;
M_.orig_maximum_lead = 1;
M_.orig_maximum_lag_with_diffs_expanded = 1;
M_.lead_lag_incidence = [
 0 7 0;
 0 8 29;
 0 9 0;
 0 10 0;
 1 11 0;
 0 12 30;
 2 13 31;
 0 14 0;
 0 15 0;
 0 16 0;
 3 17 0;
 4 18 0;
 5 19 0;
 0 20 0;
 0 21 32;
 0 22 33;
 0 23 34;
 0 24 0;
 6 25 0;
 0 26 0;
 0 27 0;
 0 28 0;]';
M_.nstatic = 11;
M_.nfwrd   = 5;
M_.npred   = 5;
M_.nboth   = 1;
M_.nsfwrd   = 6;
M_.nspred   = 6;
M_.ndynamic   = 11;
M_.dynamic_tmp_nbr = [31; 41; 14; 0; ];
M_.model_local_variables_dynamic_tt_idxs = {
};
M_.equations_tags = {
  1 , 'name' , '1' ;
  2 , 'name' , '2' ;
  3 , 'name' , 'lambtil' ;
  4 , 'name' , '4' ;
  5 , 'name' , 'cn' ;
  6 , 'name' , 'ct' ;
  7 , 'name' , '7' ;
  8 , 'name' , 'L' ;
  9 , 'name' , 'delnl' ;
  10 , 'name' , 'fbarn' ;
  11 , 'name' , '11' ;
  12 , 'name' , 'pien' ;
  13 , 'name' , '13' ;
  14 , 'name' , '14' ;
  15 , 'name' , '15' ;
  16 , 'name' , 'rstar' ;
  17 , 'name' , 'yn' ;
  18 , 'name' , 'delta' ;
  19 , 'name' , 'tb' ;
  20 , 'name' , '20' ;
  21 , 'name' , 'gdp' ;
  22 , 'name' , '22' ;
};
M_.mapping.c.eqidx = [1 5 6 21 22 ];
M_.mapping.lambtil.eqidx = [1 2 3 4 10 11 ];
M_.mapping.l.eqidx = [2 ];
M_.mapping.w.eqidx = [2 11 ];
M_.mapping.rstar.eqidx = [3 16 20 ];
M_.mapping.pies.eqidx = [3 15 ];
M_.mapping.pie.eqidx = [3 4 9 10 11 12 13 14 15 18 ];
M_.mapping.r.eqidx = [4 14 ];
M_.mapping.cn.eqidx = [5 17 ];
M_.mapping.ct.eqidx = [6 19 21 ];
M_.mapping.pn.eqidx = [5 7 11 12 ];
M_.mapping.pt.eqidx = [1 6 7 15 19 20 ];
M_.mapping.delnl.eqidx = [8 9 18 ];
M_.mapping.yn.eqidx = [8 10 11 17 ];
M_.mapping.pnstar.eqidx = [9 10 11 13 18 ];
M_.mapping.pien.eqidx = [9 10 11 12 13 18 ];
M_.mapping.fbarn.eqidx = [10 11 ];
M_.mapping.gdp.eqidx = [14 21 22 ];
M_.mapping.bstar.eqidx = [16 20 ];
M_.mapping.delta.eqidx = [17 18 ];
M_.mapping.py.eqidx = [22 ];
M_.mapping.tb.eqidx = [19 20 22 ];
M_.mapping.em.eqidx = [14 ];
M_.mapping.piestar.eqidx = [15 20 ];
M_.mapping.Rw.eqidx = [16 ];
M_.static_and_dynamic_models_differ = false;
M_.has_external_function = false;
M_.state_var = [5 7 11 12 13 19 ];
M_.exo_names_orig_ord = [1:3];
M_.maximum_lag = 1;
M_.maximum_lead = 1;
M_.maximum_endo_lag = 1;
M_.maximum_endo_lead = 1;
oo_.steady_state = zeros(22, 1);
M_.maximum_exo_lag = 0;
M_.maximum_exo_lead = 0;
oo_.exo_steady_state = zeros(3, 1);
M_.params = NaN(16, 1);
M_.endo_trends = struct('deflator', cell(22, 1), 'log_deflator', cell(22, 1), 'growth_factor', cell(22, 1), 'log_growth_factor', cell(22, 1));
M_.NNZDerivatives = [95; 236; -1; ];
M_.static_tmp_nbr = [31; 9; 0; 0; ];
M_.model_local_variables_static_tt_idxs = {
};
M_.params(1) = 0.9823;
beta = M_.params(1);
M_.params(2) = 1.99;
sigma = M_.params(2);
M_.params(3) = 3;
psi = M_.params(3);
M_.params(4) = 1.5;
theta = M_.params(4);
M_.params(5) = 0.46;
gamma = M_.params(5);
M_.params(6) = 0.34;
alphan = M_.params(6);
M_.params(7) = (-0.97);
epsilon = M_.params(7);
M_.params(8) = 1;
zeta = M_.params(8);
M_.params(9) = 0.75;
rho = M_.params(9);
M_.params(10) = 1.1;
alphapie = M_.params(10);
M_.params(11) = 0.4;
alphay = M_.params(11);
M_.params(12) = 0.233;
phi = M_.params(12);
M_.params(13) = 0.04;
piebar = M_.params(13);
M_.params(14) = 1;
pT = M_.params(14);
M_.params(15) = 0.56;
L = M_.params(15);
M_.params(16) = (-0.092);
stb = M_.params(16);
%
% INITVAL instructions
%
options_.initval_file = false;
oo_.steady_state(5) = 0.0244;
oo_.steady_state(7) = 0.02439;
oo_.steady_state(8) = 0.025;
oo_.steady_state(6) = 1.025;
oo_.steady_state(16) = 0.02439;
oo_.steady_state(15) = 1;
oo_.steady_state(13) = 1;
oo_.steady_state(20) = 1;
oo_.exo_steady_state(2) = 0.0238;
oo_.steady_state(11) = 1;
oo_.steady_state(14) = 0.68;
oo_.steady_state(17) = (-2.91);
oo_.steady_state(4) = 1.623;
oo_.steady_state(9) = 0.68;
oo_.steady_state(1) = 0.68;
oo_.steady_state(10) = 0.54;
oo_.steady_state(2) = 2.154;
oo_.steady_state(22) = (-1286948);
oo_.steady_state(19) = 252342;
oo_.steady_state(18) = (-12869472);
oo_.steady_state(21) = pygdp/oo_.steady_state(18);
if M_.exo_nbr > 0
	oo_.exo_simul = ones(M_.maximum_lag,1)*oo_.exo_steady_state';
end
if M_.exo_det_nbr > 0
	oo_.exo_det_simul = ones(M_.maximum_lag,1)*oo_.exo_det_steady_state';
end
steady;
%
% SHOCKS instructions
%
M_.exo_det_length = 0;
M_.Sigma_e(1, 1) = sigmaem^(-2);
M_.Sigma_e(2, 2) = sigmapiestar^(-2);
M_.Sigma_e(3, 3) = sigmaRw^(-2);
stoch simul(order=20, irf=40);


oo_.time = toc(tic0);
disp(['Total computing time : ' dynsec2hms(oo_.time) ]);
if ~exist([M_.dname filesep 'Output'],'dir')
    mkdir(M_.dname,'Output');
end
save([M_.dname filesep 'Output' filesep 'ex1dsg_results.mat'], 'oo_', 'M_', 'options_');
if exist('estim_params_', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'ex1dsg_results.mat'], 'estim_params_', '-append');
end
if exist('bayestopt_', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'ex1dsg_results.mat'], 'bayestopt_', '-append');
end
if exist('dataset_', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'ex1dsg_results.mat'], 'dataset_', '-append');
end
if exist('estimation_info', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'ex1dsg_results.mat'], 'estimation_info', '-append');
end
if exist('dataset_info', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'ex1dsg_results.mat'], 'dataset_info', '-append');
end
if exist('oo_recursive_', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'ex1dsg_results.mat'], 'oo_recursive_', '-append');
end
if ~isempty(lastwarn)
  disp('Note: warning(s) encountered in MATLAB/Octave code')
end
