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

clear all
tic;
global M_ oo_ options_ ys0_ ex0_
options_ = [];
M_.fname = 'sw4';
%
% Some global variables initialization
%
global_initialization;
diary off;
logname_ = 'sw4.log';
if exist(logname_, 'file')
    delete(logname_)
end
diary(logname_)
M_.exo_names = 'ea';
M_.exo_names_tex = 'ea';
M_.exo_names = strvcat(M_.exo_names, 'eg');
M_.exo_names_tex = strvcat(M_.exo_names_tex, 'eg');
M_.exo_names = strvcat(M_.exo_names, 'eqs');
M_.exo_names_tex = strvcat(M_.exo_names_tex, 'eqs');
M_.exo_names = strvcat(M_.exo_names, 'em');
M_.exo_names_tex = strvcat(M_.exo_names_tex, 'em');
M_.endo_names = 'zcapf';
M_.endo_names_tex = 'zcapf';
M_.endo_names = strvcat(M_.endo_names, 'rkf');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'rkf');
M_.endo_names = strvcat(M_.endo_names, 'kf');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'kf');
M_.endo_names = strvcat(M_.endo_names, 'pkf');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'pkf');
M_.endo_names = strvcat(M_.endo_names, 'cf');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'cf');
M_.endo_names = strvcat(M_.endo_names, 'invef');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'invef');
M_.endo_names = strvcat(M_.endo_names, 'yf');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'yf');
M_.endo_names = strvcat(M_.endo_names, 'labf');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'labf');
M_.endo_names = strvcat(M_.endo_names, 'wf');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'wf');
M_.endo_names = strvcat(M_.endo_names, 'rrf');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'rrf');
M_.endo_names = strvcat(M_.endo_names, 'mc');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'mc');
M_.endo_names = strvcat(M_.endo_names, 'zcap');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'zcap');
M_.endo_names = strvcat(M_.endo_names, 'rk');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'rk');
M_.endo_names = strvcat(M_.endo_names, 'k');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'k');
M_.endo_names = strvcat(M_.endo_names, 'pk');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'pk');
M_.endo_names = strvcat(M_.endo_names, 'c');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'c');
M_.endo_names = strvcat(M_.endo_names, 'inve');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'inve');
M_.endo_names = strvcat(M_.endo_names, 'y');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'y');
M_.endo_names = strvcat(M_.endo_names, 'lab');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'lab');
M_.endo_names = strvcat(M_.endo_names, 'pinf');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'pinf');
M_.endo_names = strvcat(M_.endo_names, 'w');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'w');
M_.endo_names = strvcat(M_.endo_names, 'r');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'r');
M_.endo_names = strvcat(M_.endo_names, 'a');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'a');
M_.endo_names = strvcat(M_.endo_names, 'g');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'g');
M_.endo_names = strvcat(M_.endo_names, 'qs');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'qs');
M_.endo_names = strvcat(M_.endo_names, 'kpf');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'kpf');
M_.endo_names = strvcat(M_.endo_names, 'kp');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'kp');
M_.endo_names = strvcat(M_.endo_names, 'rtil');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'rtil');
M_.endo_names = strvcat(M_.endo_names, 'y_o');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'y\_o');
M_.endo_names = strvcat(M_.endo_names, 'c_o');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'c\_o');
M_.endo_names = strvcat(M_.endo_names, 'i_o');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'i\_o');
M_.endo_names = strvcat(M_.endo_names, 'w_o');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'w\_o');
M_.endo_names = strvcat(M_.endo_names, 'pi_o');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'pi\_o');
M_.endo_names = strvcat(M_.endo_names, 'r_o');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'r\_o');
M_.endo_names = strvcat(M_.endo_names, 'h_o');
M_.endo_names_tex = strvcat(M_.endo_names_tex, 'h\_o');
M_.param_names = 'curvw';
M_.param_names_tex = 'curvw';
M_.param_names = strvcat(M_.param_names, 'curvp');
M_.param_names_tex = strvcat(M_.param_names_tex, 'curvp');
M_.param_names = strvcat(M_.param_names, 'cgy');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cgy');
M_.param_names = strvcat(M_.param_names, 'calfa');
M_.param_names_tex = strvcat(M_.param_names_tex, 'calfa');
M_.param_names = strvcat(M_.param_names, 'czcap');
M_.param_names_tex = strvcat(M_.param_names_tex, 'czcap');
M_.param_names = strvcat(M_.param_names, 'cbeta');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cbeta');
M_.param_names = strvcat(M_.param_names, 'csadjcost');
M_.param_names_tex = strvcat(M_.param_names_tex, 'csadjcost');
M_.param_names = strvcat(M_.param_names, 'ctou');
M_.param_names_tex = strvcat(M_.param_names_tex, 'ctou');
M_.param_names = strvcat(M_.param_names, 'csigma');
M_.param_names_tex = strvcat(M_.param_names_tex, 'csigma');
M_.param_names = strvcat(M_.param_names, 'chabb');
M_.param_names_tex = strvcat(M_.param_names_tex, 'chabb');
M_.param_names = strvcat(M_.param_names, 'cfc');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cfc');
M_.param_names = strvcat(M_.param_names, 'cindw');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cindw');
M_.param_names = strvcat(M_.param_names, 'cprobw');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cprobw');
M_.param_names = strvcat(M_.param_names, 'cindp');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cindp');
M_.param_names = strvcat(M_.param_names, 'cprobp');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cprobp');
M_.param_names = strvcat(M_.param_names, 'csigl');
M_.param_names_tex = strvcat(M_.param_names_tex, 'csigl');
M_.param_names = strvcat(M_.param_names, 'clandaw');
M_.param_names_tex = strvcat(M_.param_names_tex, 'clandaw');
M_.param_names = strvcat(M_.param_names, 'crpi');
M_.param_names_tex = strvcat(M_.param_names_tex, 'crpi');
M_.param_names = strvcat(M_.param_names, 'crdy');
M_.param_names_tex = strvcat(M_.param_names_tex, 'crdy');
M_.param_names = strvcat(M_.param_names, 'cry');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cry');
M_.param_names = strvcat(M_.param_names, 'crr');
M_.param_names_tex = strvcat(M_.param_names_tex, 'crr');
M_.param_names = strvcat(M_.param_names, 'crhoa');
M_.param_names_tex = strvcat(M_.param_names_tex, 'crhoa');
M_.param_names = strvcat(M_.param_names, 'crhog');
M_.param_names_tex = strvcat(M_.param_names_tex, 'crhog');
M_.param_names = strvcat(M_.param_names, 'crhoqs');
M_.param_names_tex = strvcat(M_.param_names_tex, 'crhoqs');
M_.param_names = strvcat(M_.param_names, 'cg');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cg');
M_.param_names = strvcat(M_.param_names, 'cgamma');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cgamma');
M_.param_names = strvcat(M_.param_names, 'clandap');
M_.param_names_tex = strvcat(M_.param_names_tex, 'clandap');
M_.param_names = strvcat(M_.param_names, 'cbetabar');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cbetabar');
M_.param_names = strvcat(M_.param_names, 'crk');
M_.param_names_tex = strvcat(M_.param_names_tex, 'crk');
M_.param_names = strvcat(M_.param_names, 'cw');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cw');
M_.param_names = strvcat(M_.param_names, 'cikbar');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cikbar');
M_.param_names = strvcat(M_.param_names, 'cik');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cik');
M_.param_names = strvcat(M_.param_names, 'clk');
M_.param_names_tex = strvcat(M_.param_names_tex, 'clk');
M_.param_names = strvcat(M_.param_names, 'cky');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cky');
M_.param_names = strvcat(M_.param_names, 'ciy');
M_.param_names_tex = strvcat(M_.param_names_tex, 'ciy');
M_.param_names = strvcat(M_.param_names, 'ccy');
M_.param_names_tex = strvcat(M_.param_names_tex, 'ccy');
M_.param_names = strvcat(M_.param_names, 'crkky');
M_.param_names_tex = strvcat(M_.param_names_tex, 'crkky');
M_.param_names = strvcat(M_.param_names, 'cwhlc');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cwhlc');
M_.param_names = strvcat(M_.param_names, 'cwly');
M_.param_names_tex = strvcat(M_.param_names_tex, 'cwly');
M_.param_names = strvcat(M_.param_names, 'y_ss');
M_.param_names_tex = strvcat(M_.param_names_tex, 'y\_ss');
M_.param_names = strvcat(M_.param_names, 'c_ss');
M_.param_names_tex = strvcat(M_.param_names_tex, 'c\_ss');
M_.param_names = strvcat(M_.param_names, 'i_ss');
M_.param_names_tex = strvcat(M_.param_names_tex, 'i\_ss');
M_.param_names = strvcat(M_.param_names, 'w_ss');
M_.param_names_tex = strvcat(M_.param_names_tex, 'w\_ss');
M_.param_names = strvcat(M_.param_names, 'pi_ss');
M_.param_names_tex = strvcat(M_.param_names_tex, 'pi\_ss');
M_.param_names = strvcat(M_.param_names, 'r_ss');
M_.param_names_tex = strvcat(M_.param_names_tex, 'r\_ss');
M_.param_names = strvcat(M_.param_names, 'h_ss');
M_.param_names_tex = strvcat(M_.param_names_tex, 'h\_ss');
M_.exo_det_nbr = 0;
M_.exo_nbr = 4;
M_.endo_nbr = 35;
M_.param_nbr = 46;
M_.Sigma_e = zeros(4, 4);
M_.orig_endo_nbr = 35;
M_.aux_vars = [];
options_.linear = 1;
options_.block=0;
options_.bytecode=0;
options_.use_dll=0;
erase_compiled_function('sw4_dynamic');
M_.lead_lag_incidence = [
 0 13 0;
 0 14 48;
 0 15 0;
 0 16 49;
 1 17 50;
 2 18 51;
 0 19 0;
 0 20 52;
 0 21 0;
 0 22 0;
 0 23 0;
 0 24 0;
 0 25 53;
 0 26 0;
 0 27 54;
 3 28 55;
 4 29 56;
 0 30 0;
 0 31 57;
 5 32 58;
 6 33 59;
 0 34 0;
 7 35 0;
 8 36 0;
 9 37 0;
 10 38 0;
 11 39 0;
 12 40 0;
 0 41 0;
 0 42 0;
 0 43 0;
 0 44 0;
 0 45 0;
 0 46 0;
 0 47 0;]';
M_.equations_tags = {
};
M_.exo_names_orig_ord = [1:4];
M_.maximum_lag = 1;
M_.maximum_lead = 1;
M_.maximum_endo_lag = 1;
M_.maximum_endo_lead = 1;
oo_.steady_state = zeros(35, 1);
M_.maximum_exo_lag = 0;
M_.maximum_exo_lead = 0;
oo_.exo_steady_state = zeros(4, 1);
M_.params = repmat(NaN,46, 1);
M_.NNZDerivatives = zeros(3, 1);
M_.NNZDerivatives(1) = 134;
M_.NNZDerivatives(2) = 0;
M_.NNZDerivatives(3) = -1;
M_.params( 8 ) = 0.025;
ctou = M_.params( 8 );
M_.params( 2 ) = 10;
curvp = M_.params( 2 );
M_.params( 1 ) = 10;
curvw = M_.params( 1 );
M_.params( 17 ) = 1.5;
clandaw = M_.params( 17 );
M_.params( 25 ) = 0.18;
cg = M_.params( 25 );
M_.params( 6 ) = 0.99;
cbeta = M_.params( 6 );
M_.params( 11 ) = 1.61;
cfc = M_.params( 11 );
M_.params( 7 ) = 5.48;
csadjcost = M_.params( 7 );
M_.params( 4 ) = 0.20;
calfa = M_.params( 4 );
M_.params( 10 ) = 0.71;
chabb = M_.params( 10 );
M_.params( 13 ) = 0.73;
cprobw = M_.params( 13 );
M_.params( 15 ) = 0.65;
cprobp = M_.params( 15 );
M_.params( 12 ) = 0.59;
cindw = M_.params( 12 );
M_.params( 14 ) = 0.47;
cindp = M_.params( 14 );
M_.params( 16 ) = 1.92;
csigl = M_.params( 16 );
M_.params( 9 ) = 1.39;
csigma = M_.params( 9 );
M_.params( 5 ) = 0.26;
czcap = M_.params( 5 );
M_.params( 18 ) = 2.03;
crpi = M_.params( 18 );
M_.params( 21 ) = 0.87;
crr = M_.params( 21 );
M_.params( 20 ) = 0.08;
cry = M_.params( 20 );
M_.params( 19 ) = 0.22;
crdy = M_.params( 19 );
M_.params( 26 ) = 1.000;
cgamma = M_.params( 26 );
M_.params( 22 ) = 0.95;
crhoa = M_.params( 22 );
M_.params( 23 ) = 0.97;
crhog = M_.params( 23 );
M_.params( 24 ) = 0.71;
crhoqs = M_.params( 24 );
M_.params( 3 ) = 0.51;
cgy = M_.params( 3 );
M_.params( 27 ) = M_.params(11);
clandap = M_.params( 27 );
M_.params( 28 ) = M_.params(6)*M_.params(26)^(-M_.params(9));
cbetabar = M_.params( 28 );
M_.params( 29 ) = M_.params(6)^(-1)*M_.params(26)^M_.params(9)-(1-M_.params(8));
crk = M_.params( 29 );
M_.params( 30 ) = (M_.params(4)^M_.params(4)*(1-M_.params(4))^(1-M_.params(4))/(M_.params(27)*M_.params(29)^M_.params(4)))^(1/(1-M_.params(4)));
cw = M_.params( 30 );
M_.params( 31 ) = 1-(1-M_.params(8))/M_.params(26);
cikbar = M_.params( 31 );
M_.params( 32 ) = M_.params(26)*(1-(1-M_.params(8))/M_.params(26));
cik = M_.params( 32 );
M_.params( 33 ) = (1-M_.params(4))/M_.params(4)*M_.params(29)/M_.params(30);
clk = M_.params( 33 );
M_.params( 34 ) = M_.params(11)*M_.params(33)^(M_.params(4)-1);
cky = M_.params( 34 );
M_.params( 35 ) = M_.params(32)*M_.params(34);
ciy = M_.params( 35 );
M_.params( 36 ) = 1-M_.params(25)-M_.params(32)*M_.params(34);
ccy = M_.params( 36 );
M_.params( 37 ) = M_.params(29)*M_.params(34);
crkky = M_.params( 37 );
M_.params( 38 ) = M_.params(34)*M_.params(29)*(1-M_.params(4))*1/M_.params(17)/M_.params(4)/M_.params(36);
cwhlc = M_.params( 38 );
M_.params( 39 ) = 1-M_.params(29)*M_.params(34);
cwly = M_.params( 39 );
M_.params( 44 ) = 1;
pi_ss = M_.params( 44 );
M_.params( 45 ) = M_.params(44)/M_.params(28);
r_ss = M_.params( 45 );
M_.params( 43 ) = (M_.params(29)^M_.params(4)*M_.params(4)^M_.params(4)*(1-M_.params(4))^(1-M_.params(4))/(1+M_.params(17)))^(1/(1-M_.params(4)));
w_ss = M_.params( 43 );
kh_ss  = calfa / (1-calfa) * w_ss / crk ;
ky_ss  = csadjcost * (1/kh_ss)^(calfa-1);
ik_ss  = (cgamma - (1-ctou));
cy_ss  = 1 - cg - ik_ss * ky_ss;   
ch_ss  = cy_ss / ky_ss * kh_ss ;
M_.params( 46 ) = (M_.params(43)/(1+M_.params(17))/(1-M_.params(10)/M_.params(26))/ch_ss)^(1/(M_.params(16)-1));
h_ss = M_.params( 46 );
k_ss   = kh_ss * h_ss;
M_.params( 40 ) = k_ss/ky_ss;
y_ss = M_.params( 40 );
M_.params( 41 ) = M_.params(40)*cy_ss;
c_ss = M_.params( 41 );
M_.params( 42 ) = k_ss*ik_ss;
i_ss = M_.params( 42 );
%
% SHOCKS instructions
%
make_ex_;
M_.exo_det_length = 0;
M_.Sigma_e(1, 1) = (0.4618)^2;
M_.Sigma_e(2, 2) = (0.6090)^2;
M_.Sigma_e(4, 4) = (0.2513)^2;
M_.Sigma_e(3, 3) = (0.6017)^2;
M_.sigma_e_is_diagonal = 1;
check;
steady;
options_.nograph = 1;
options_.noprint = 1;
options_.order = 0;
options_.periods = 200;
var_list_=[];
info = stoch_simul(var_list_);
save('sw4_results.mat', 'oo_', 'M_', 'options_');
diary off

disp(['Total computing time : ' dynsec2hms(toc) ]);
