%
% 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 = 'FiscalRE16022017_correct_tax';
M_.dynare_version = '5.1';
oo_.dynare_version = '5.1';
options_.dynare_version = '5.1';
%
% Some global variables initialization
%
global_initialization;
M_.exo_names = cell(2,1);
M_.exo_names_tex = cell(2,1);
M_.exo_names_long = cell(2,1);
M_.exo_names(1) = {'gama_x'};
M_.exo_names_tex(1) = {'gama\_x'};
M_.exo_names_long(1) = {'gama_x'};
M_.exo_names(2) = {'gama_g'};
M_.exo_names_tex(2) = {'gama\_g'};
M_.exo_names_long(2) = {'gama_g'};
M_.endo_names = cell(15,1);
M_.endo_names_tex = cell(15,1);
M_.endo_names_long = cell(15,1);
M_.endo_names(1) = {'y'};
M_.endo_names_tex(1) = {'y'};
M_.endo_names_long(1) = {'y'};
M_.endo_names(2) = {'c'};
M_.endo_names_tex(2) = {'c'};
M_.endo_names_long(2) = {'c'};
M_.endo_names(3) = {'H'};
M_.endo_names_tex(3) = {'H'};
M_.endo_names_long(3) = {'H'};
M_.endo_names(4) = {'k'};
M_.endo_names_tex(4) = {'k'};
M_.endo_names_long(4) = {'k'};
M_.endo_names(5) = {'inv'};
M_.endo_names_tex(5) = {'inv'};
M_.endo_names_long(5) = {'inv'};
M_.endo_names(6) = {'rk'};
M_.endo_names_tex(6) = {'rk'};
M_.endo_names_long(6) = {'rk'};
M_.endo_names(7) = {'w'};
M_.endo_names_tex(7) = {'w'};
M_.endo_names_long(7) = {'w'};
M_.endo_names(8) = {'y_H'};
M_.endo_names_tex(8) = {'y\_H'};
M_.endo_names_long(8) = {'y_H'};
M_.endo_names(9) = {'r'};
M_.endo_names_tex(9) = {'r'};
M_.endo_names_long(9) = {'r'};
M_.endo_names(10) = {'U'};
M_.endo_names_tex(10) = {'U'};
M_.endo_names_long(10) = {'U'};
M_.endo_names(11) = {'a'};
M_.endo_names_tex(11) = {'a'};
M_.endo_names_long(11) = {'a'};
M_.endo_names(12) = {'b'};
M_.endo_names_tex(12) = {'b'};
M_.endo_names_long(12) = {'b'};
M_.endo_names(13) = {'g'};
M_.endo_names_tex(13) = {'g'};
M_.endo_names_long(13) = {'g'};
M_.endo_names(14) = {'gy'};
M_.endo_names_tex(14) = {'gy'};
M_.endo_names_long(14) = {'gy'};
M_.endo_names(15) = {'by'};
M_.endo_names_tex(15) = {'by'};
M_.endo_names_long(15) = {'by'};
M_.endo_partitions = struct();
M_.param_names = cell(23,1);
M_.param_names_tex = cell(23,1);
M_.param_names_long = cell(23,1);
M_.param_names(1) = {'eps_H'};
M_.param_names_tex(1) = {'eps\_H'};
M_.param_names_long(1) = {'eps_H'};
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) = {'cy_ratio'};
M_.param_names_tex(4) = {'cy\_ratio'};
M_.param_names_long(4) = {'cy_ratio'};
M_.param_names(5) = {'iy_ratio'};
M_.param_names_tex(5) = {'iy\_ratio'};
M_.param_names_long(5) = {'iy_ratio'};
M_.param_names(6) = {'gy_ratio'};
M_.param_names_tex(6) = {'gy\_ratio'};
M_.param_names_long(6) = {'gy_ratio'};
M_.param_names(7) = {'alpha'};
M_.param_names_tex(7) = {'alpha'};
M_.param_names_long(7) = {'alpha'};
M_.param_names(8) = {'delta'};
M_.param_names_tex(8) = {'delta'};
M_.param_names_long(8) = {'delta'};
M_.param_names(9) = {'theta'};
M_.param_names_tex(9) = {'theta'};
M_.param_names_long(9) = {'theta'};
M_.param_names(10) = {'gama'};
M_.param_names_tex(10) = {'gama'};
M_.param_names_long(10) = {'gama'};
M_.param_names(11) = {'ik_ratio'};
M_.param_names_tex(11) = {'ik\_ratio'};
M_.param_names_long(11) = {'ik_ratio'};
M_.param_names(12) = {'beta'};
M_.param_names_tex(12) = {'beta'};
M_.param_names_long(12) = {'beta'};
M_.param_names(13) = {'Rbar'};
M_.param_names_tex(13) = {'Rbar'};
M_.param_names_long(13) = {'Rbar'};
M_.param_names(14) = {'ay_ratio'};
M_.param_names_tex(14) = {'ay\_ratio'};
M_.param_names_long(14) = {'ay_ratio'};
M_.param_names(15) = {'by_ratio'};
M_.param_names_tex(15) = {'by\_ratio'};
M_.param_names_long(15) = {'by_ratio'};
M_.param_names(16) = {'tauk'};
M_.param_names_tex(16) = {'tauk'};
M_.param_names_long(16) = {'tauk'};
M_.param_names(17) = {'ky_ratio'};
M_.param_names_tex(17) = {'ky\_ratio'};
M_.param_names_long(17) = {'ky_ratio'};
M_.param_names(18) = {'tauH'};
M_.param_names_tex(18) = {'tauH'};
M_.param_names_long(18) = {'tauH'};
M_.param_names(19) = {'tauC'};
M_.param_names_tex(19) = {'tauC'};
M_.param_names_long(19) = {'tauC'};
M_.param_names(20) = {'lam1'};
M_.param_names_tex(20) = {'lam1'};
M_.param_names_long(20) = {'lam1'};
M_.param_names(21) = {'lam2'};
M_.param_names_tex(21) = {'lam2'};
M_.param_names_long(21) = {'lam2'};
M_.param_names(22) = {'sigma_x'};
M_.param_names_tex(22) = {'sigma\_x'};
M_.param_names_long(22) = {'sigma_x'};
M_.param_names(23) = {'sigma_g'};
M_.param_names_tex(23) = {'sigma\_g'};
M_.param_names_long(23) = {'sigma_g'};
M_.param_partitions = struct();
M_.exo_det_nbr = 0;
M_.exo_nbr = 2;
M_.endo_nbr = 15;
M_.param_nbr = 23;
M_.orig_endo_nbr = 15;
M_.aux_vars = [];
M_ = setup_solvers(M_);
M_.Sigma_e = zeros(2, 2);
M_.Correlation_matrix = eye(2, 2);
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 = true;
options_.block = false;
options_.bytecode = false;
options_.use_dll = false;
M_.nonzero_hessian_eqs = [];
M_.hessian_eq_zero = isempty(M_.nonzero_hessian_eqs);
M_.orig_eq_nbr = 15;
M_.eq_nbr = 15;
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 3 0;
 0 4 18;
 0 5 19;
 1 6 0;
 0 7 0;
 0 8 20;
 0 9 0;
 0 10 0;
 0 11 0;
 0 12 0;
 0 13 0;
 2 14 0;
 0 15 0;
 0 16 0;
 0 17 0;]';
M_.nstatic = 10;
M_.nfwrd   = 3;
M_.npred   = 2;
M_.nboth   = 0;
M_.nsfwrd   = 3;
M_.nspred   = 2;
M_.ndynamic   = 5;
M_.dynamic_tmp_nbr = [5; 0; 0; 0; ];
M_.model_local_variables_dynamic_tt_idxs = {
};
M_.equations_tags = {
  1 , 'name' , '1' ;
  2 , 'name' , 'w' ;
  3 , 'name' , 'gy' ;
  4 , 'name' , 'by' ;
  5 , 'name' , 'rk' ;
  6 , 'name' , 'y' ;
  7 , 'name' , '7' ;
  8 , 'name' , '8' ;
  9 , 'name' , '9' ;
  10 , 'name' , 'y_H' ;
  11 , 'name' , '11' ;
  12 , 'name' , 'r' ;
  13 , 'name' , '13' ;
  14 , 'name' , '14' ;
  15 , 'name' , '15' ;
};
M_.mapping.y.eqidx = [2 3 4 5 6 7 10 15 ];
M_.mapping.c.eqidx = [1 6 11 14 ];
M_.mapping.H.eqidx = [1 2 7 10 11 14 ];
M_.mapping.k.eqidx = [5 7 8 13 14 ];
M_.mapping.inv.eqidx = [6 8 ];
M_.mapping.rk.eqidx = [5 9 11 12 14 ];
M_.mapping.w.eqidx = [1 2 14 ];
M_.mapping.y_H.eqidx = [10 ];
M_.mapping.r.eqidx = [12 14 ];
M_.mapping.U.eqidx = [5 7 8 9 ];
M_.mapping.a.eqidx = [13 ];
M_.mapping.b.eqidx = [4 13 14 15 ];
M_.mapping.g.eqidx = [3 6 14 15 ];
M_.mapping.gy.eqidx = [3 ];
M_.mapping.by.eqidx = [4 ];
M_.mapping.gama_x.eqidx = [5 7 8 14 15 ];
M_.mapping.gama_g.eqidx = [15 ];
M_.static_and_dynamic_models_differ = false;
M_.has_external_function = false;
M_.state_var = [4 12 ];
M_.exo_names_orig_ord = [1:2];
M_.maximum_lag = 1;
M_.maximum_lead = 1;
M_.maximum_endo_lag = 1;
M_.maximum_endo_lead = 1;
oo_.steady_state = zeros(15, 1);
M_.maximum_exo_lag = 0;
M_.maximum_exo_lead = 0;
oo_.exo_steady_state = zeros(2, 1);
M_.params = NaN(23, 1);
M_.endo_trends = struct('deflator', cell(15, 1), 'log_deflator', cell(15, 1), 'growth_factor', cell(15, 1), 'log_growth_factor', cell(15, 1));
M_.NNZDerivatives = [61; 0; -1; ];
M_.static_tmp_nbr = [3; 0; 0; 0; ];
M_.model_local_variables_static_tt_idxs = {
};
beta_tilda = 0.995;
M_.params(10) = 1.00275378471853;
gama = M_.params(10);
M_.params(13) = M_.params(10)/beta_tilda;
Rbar = M_.params(13);
M_.params(8) = 0.0245;
delta = M_.params(8);
M_.params(7) = 0.39;
alpha = M_.params(7);
M_.params(1) = 0.1;
eps_H = M_.params(1);
M_.params(2) = 2;
sigma = M_.params(2);
M_.params(16) = 0.23;
tauk = M_.params(16);
M_.params(18) = 0.31;
tauH = M_.params(18);
M_.params(19) = 0.21;
tauC = M_.params(19);
M_.params(6) = 0.23;
gy_ratio = M_.params(6);
M_.params(9) = 1+(M_.params(13)-1)/(1-M_.params(16))/M_.params(8);
theta = M_.params(9);
M_.params(17) = M_.params(10)*M_.params(7)/((M_.params(13)-1)/(1-M_.params(16))+M_.params(8));
ky_ratio = M_.params(17);
M_.params(11) = 1-(1-M_.params(8))/M_.params(10);
ik_ratio = M_.params(11);
M_.params(5) = M_.params(17)*M_.params(11);
iy_ratio = M_.params(5);
M_.params(15) = 0.95;
by_ratio = M_.params(15);
M_.params(4) = 1-M_.params(5)-M_.params(6);
cy_ratio = M_.params(4);
M_.params(3) = (1-M_.params(7))/M_.params(4)*(1-M_.params(18))/(1+M_.params(19));
psi = M_.params(3);
M_.params(14) = M_.params(17)+M_.params(15);
ay_ratio = M_.params(14);
M_.params(20) = 0;
lam1 = M_.params(20);
M_.params(21) = (-0.02);
lam2 = M_.params(21);
M_.params(12) = M_.params(10)^M_.params(2)/M_.params(13);
beta = M_.params(12);
M_.params(22) = 0.003;
sigma_x = M_.params(22);
M_.params(23) = 0.003;
sigma_g = M_.params(23);
%
% SHOCKS instructions
%
M_.exo_det_length = 0;
M_.Sigma_e(1, 1) = M_.params(22)^2;
M_.Sigma_e(2, 2) = M_.params(23)^2;
options_.hp_filter = 1600;
options_.irf = 60;
options_.order = 1;
var_list_ = {};
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);
coeff_k = oo_.dr.ghx;
coeff_u = oo_.dr.ghu;
save('coeff_k','coeff_k');
save('coeff_u','coeff_u');


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 'FiscalRE16022017_correct_tax_results.mat'], 'oo_', 'M_', 'options_');
if exist('estim_params_', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'FiscalRE16022017_correct_tax_results.mat'], 'estim_params_', '-append');
end
if exist('bayestopt_', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'FiscalRE16022017_correct_tax_results.mat'], 'bayestopt_', '-append');
end
if exist('dataset_', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'FiscalRE16022017_correct_tax_results.mat'], 'dataset_', '-append');
end
if exist('estimation_info', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'FiscalRE16022017_correct_tax_results.mat'], 'estimation_info', '-append');
end
if exist('dataset_info', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'FiscalRE16022017_correct_tax_results.mat'], 'dataset_info', '-append');
end
if exist('oo_recursive_', 'var') == 1
  save([M_.dname filesep 'Output' filesep 'FiscalRE16022017_correct_tax_results.mat'], 'oo_recursive_', '-append');
end
if ~isempty(lastwarn)
  disp('Note: warning(s) encountered in MATLAB/Octave code')
end
