clear all
 ...
global scalv_ ex_ ex_det_ recur_ recurs_ ys_ y_ exe_ exe_det_ lgy_ lgx_ lgx_det_ lgr_ dsmpl_ endval_
 ...
global endo_nbr exo_nbr exo_det_nbr iy_  ykmin_  ykmax_  xkmin_  xkmax_ zkmin_ zkmax_ iter_
 ...
global dynatol_ slowc_ maxit_ valf_ ys0_ recurs0_ ex0_ timing_ ct_ gstep_ Sigma_e_ fname_ lgx_orig_ord_ iter_ options_ dr_ oo_ trend_coeff_ eigenvalues_
global M_
M_.ex_det_length = 0;
M_.dname = 'soe1';
endo_nbr=0;exo_nbr=0;exo_det_nbr=0;
dsmpl_=0;
dynatol_=0.00001;
maxit_=10;
slowc_=1;
timing_=0;
ct_=0;
gstep_=1e-2;
endval_=0;rplottype_=0;
valf_=0;
y_=[];
ex_=[];
ex_det_=[];
fname_ = 'soe1';
logname_ = 'soe1.log';
diary off;
warning off;
delete soe1.log;
warning on;
warning backtrace;
diary soe1.log;
options_ = [];


lgy_ = 'E1_Y_US';
lgy_ = str2mat(lgy_,'G_US');
lgy_ = str2mat(lgy_,'GROWTH4_US');
lgy_ = str2mat(lgy_,'GROWTH4_US_BAR');
lgy_ = str2mat(lgy_,'GROWTH_US');
lgy_ = str2mat(lgy_,'LGDP_US');
lgy_ = str2mat(lgy_,'LGDP_US_BAR');
lgy_ = str2mat(lgy_,'Y_US');
endo_nbr = 8;

lgx_ = 'RES_G_US';
lgx_ = str2mat(lgx_,'RES_LGDP_US_BAR');
lgx_ = str2mat(lgx_,'RES_Y_US');
lgx_orig_ord_ = [3 2 1];
exo_nbr = 3;



global beta_us1 growth_us_ss tau_us 


alpha_us1    = 0.5;
alpha_us2    = 0.3;
beta_us1     = 0.75;
tau_us       = 0.1;
growth_us_ss = 2.5;



iy_ = [ 0 0 0 0 0 1 2 0];
temp = [ 0 0 0 0 0 0 0 0];
iy_ = [ iy_ ; temp ];
temp = [ 0 0 0 0 0 0 0 0];
iy_ = [ iy_ ; temp ];
temp = [ 0 3 0 0 0 4 5 6];
iy_ = [ iy_ ; temp ];
temp = [ 7 8 9 10 11 12 13 14];
iy_ = [ iy_ ; temp ];
temp = [ 0 0 0 0 0 0 0 15];
iy_ = [ iy_ ; temp ];
ykmin_ = 4;
ykmax_ = 1;
xkmin_ = 0;
xkmax_ = 0;
zkmin_ = 0;
zkmax_ = 0;
ys_ = zeros(8,1);
exe_ = zeros(3,1);



% (M)SHOCKS 
make_ex_;
shocks_file(0);
Sigma_e_ = zeros(3,3);
Sigma_e_(3,3) = (0.30)^2;
Sigma_e_(2,2) = (0.20)^2;
Sigma_e_(1,1) = (0.05)^2;


options_.unit_root_vars = {'LGDP_US'; 'LGDP_US_BAR'};


steady(0);


check;



global estim_params_
estim_params_.var_exo = [];
estim_params_.var_endo = [];
estim_params_.corrx = [];
estim_params_.corrn = [];
estim_params_.param_names = [];
estim_params_.param_vals = [];
estim_params_.param_names = strvcat(estim_params_.param_names,'beta_us1');
estim_params_.param_vals = [estim_params_.param_vals; NaN, -Inf, Inf, 2 ...
, 0.75, 0.10, NaN, NaN, NaN];
 ...
estim_params_.param_names = strvcat(estim_params_.param_names,'growth_us_ss');
estim_params_.param_vals = [estim_params_.param_vals; NaN, -Inf, Inf, 3 ...
, 2.5, 0.10, NaN, NaN, NaN];
estim_params_.var_exo = [estim_params_.var_exo;  3, NaN, -Inf, Inf, 4, 0.25 ...
, inf, NaN, NaN, NaN];
estim_params_.var_exo = [estim_params_.var_exo;  2, NaN, -Inf, Inf, 4, 0.10 ...
, inf, NaN, NaN, NaN];
estim_params_.var_exo = [estim_params_.var_exo;  1, NaN, -Inf, Inf, 4, 0.10 ...
, inf, NaN, NaN, NaN];


options_.varobs = [];
options_.varobs = strvcat(options_.varobs,'LGDP_US');


trend_coeff_ = {};
tmp1 = strmatch('LGDP_US',options_.varobs,'exact');
trend_coeff_{tmp1} = sprintf('growth_us_ss/4');









M_.exo_names_tex = 'RES\_Y\_US';
M_.exo_names_tex = strvcat(M_.exo_names_tex, 'RES\_LGDP\_US\_BAR');
M_.exo_names_tex = strvcat(M_.exo_names_tex, 'RES\_G\_US');




M_.endo_names_tex = 'Y\_US';
M_.endo_names_tex = strvcat(M_.endo_names_tex,'LGDP\_US');
M_.endo_names_tex = strvcat(M_.endo_names_tex,'LGDP\_US\_BAR');
M_.endo_names_tex = strvcat(M_.endo_names_tex,'G\_US');
M_.endo_names_tex = strvcat(M_.endo_names_tex,'E1\_Y\_US');
M_.endo_names_tex = strvcat(M_.endo_names_tex,'GROWTH\_US');
M_.endo_names_tex = strvcat(M_.endo_names_tex,'GROWTH4\_US');
M_.endo_names_tex = strvcat(M_.endo_names_tex,'GROWTH4\_US\_BAR');




M_.param_names_tex = '\beta_{us1}';
M_.param_names_tex = strvcat(M_.param_names_tex,'\tau_{us}');
M_.param_names_tex = strvcat(M_.param_names_tex,'growth\_us\_ss');





estim_params_.tex = '\beta_{us1}';
estim_params_.tex = strvcat(estim_params_.tex,'growth\_us_ss');

estim_params_.tex = strvcat(estim_params_.tex,'RES\_Y\_US');
estim_params_.tex = strvcat(estim_params_.tex,'RES\_LGDP\_US\_BAR');
estim_params_.tex = strvcat(estim_params_.tex,'RES\_G\_US');



options_.kalman_algo = 5;
options_.datafile='data';
options_.nobs=56;
options_.mode_check=1;
options_.mh_replic=0;
options_.mh_nblck=1;
options_.filtered_vars=1;
