
clear all;
close all;

% Set the option for plots
set(0, 'DefaultAxesFontSize',      5);
set(0, 'DefaultTextFontSize',      5);
set(0, 'DefaultUicontrolFontSize', 5);
set(0, 'DefaultAxesLinewidth',   1.5);
set(0, 'DefaultLineLinewidth',   1.5);
set(0, 'DefaultPatchLinewidth',  1.5);


% Declare the calibrated value of each parameter
BETA  = 0.99;                 % subjective discount rate
SIGMA = 2.00;                 % inverse of elasticity of intertemporal substitution
PHI   = 2.00;                 % inverse of Frisch elasticity of substitution %1.00
CHI   = 37.3415;                 % weight of disutility of labor % 11.5524

GAMMA      = 0.40;            % degree of openness for consumption goods   
GAMMA_STAR = 0.3970;            % degree of openness for consumption goods of the Foreign %0.3985

THETA      = 3.00;            % elasticity of substitution between home and foreign goods % 2.00;
EPSILON    = 10.00;           % elasticity of subsitution between domestic goods % 2.00
ALPHA      = 0.33;            % capital share in production function %0.60
DELTA      = 0.02;            % depreciation rate of capital

XI_I       = 2.48;            % charge of investment installation
XI_P       = 50.00;            % degree of price sluggishness %0.01
XI_B       = 0.01;            % magnitude of portfolio adjustment cost

RHO_A      = 0.9;             % autocorrelation of productivity shock
RHO_R      = 0.0;             % autocorrelation of monetary policy shock
RHO_RF     = 0.9;             % autocorrelation of foreign interest rate shock
RHO_YF     = 0.9;             % autocorrelation of foreign productivity shock
RHO_P      = 1.5;             % monetary policy response to inflation
RHO_Y      = 0.5;             % monetary policy response to outputs
RHO_E      = 0.0;             % monetary policy response to exchange rate

BF_GDP     = 0.49;            % external-bond-to-GDP ratio at SS % 0.25



save params ...
BETA SIGMA PHI CHI GAMMA GAMMA_STAR THETA EPSILON ALPHA DELTA ...
XI_I XI_P XI_B ...
RHO_A RHO_R RHO_RF RHO_YF RHO_P RHO_Y RHO_E...
BF_GDP;

%[Qss, YHss, val] = find_QYH(R); %  to experiment beforehand


%% Run Dynare using the parameters
%% The option noclearall avoid loosing all data in memory after the code
dynare RamSOE.mod noclearall

% Welf_pos     = find(strcmp('Welf', M_.endo_names));
% % Unconditional welfare
% WelfunRamSOE  = oo_.mean(Welf_pos);
% % Conditional welfare
% WelfconRamSOE = oo_.dr.ys(Welf_pos) ...
%                + 0.5*oo_.dr.ghs2(oo_.dr.inv_order_var(Welf_pos));
% % Consumption Equivalence
% WelfCE_RamSOE =(((WelfconRamSOE-Welf_base)*(1-SIGMA)*(1-BETA)*Css^(SIGMA-1)+1)...
% ^(1/(1-SIGMA))-1)*100;
% save WelfunRamSOE WelfconRamSOE WelfCE_RamSOE;
% 
% 
outputsRamSOE = oo_;
save outputsRamSOE;

volRamSOE  = [outputsRamSOE.var(1,1), outputsRamSOE.var(2,2), ...
              outputsRamSOE.var(3,3), outputsRamSOE.var(4,4), ...
              outputsRamSOE.var(5,5), outputsRamSOE.var(6,6), ...
              outputsRamSOE.var(7,7), outputsRamSOE.var(8,8)];  
% variances of RealGDP Inflation Consumption  Investment 
% ForeignBonds TradeBalance TermsOfTrade  InterestRate 
save  volRamSOE;


