% RBC in a Small Open Economy with an oil price shock
%
% Paloma Merodio y Marlene Guraieb
% Mexico D.F. 2008

%----------------------------------------------------------------
% 0. Housekeeping (close all graphic windows)
%----------------------------------------------------------------

close all;

%----------------------------------------------------------------
% 1. Defining variables
%----------------------------------------------------------------

var y c b k i l y_l p;
varexo m;

parameters beta ene ve ge delta alpha gamma yp phi bono rstar;

%----------------------------------------------------------------
% 2. Calibration
%----------------------------------------------------------------

alpha   = 0.4;
beta    = 0.99;
delta   = 0.085;
ene     =1.69;
ve      =2.98;
ge      =2.61;
gamma   = 0.94;
desvest = 0.23;
yp = 1.3;
phi = 1.1;
bono = -2;
rstar = 0.0654;
%----------------------------------------------------------------
% 3. Model
%----------------------------------------------------------------

model; 
  ((c-ve*(l^ene))^(-ge))*(1+phi*((k-k(-1))/(k(-1)^2)))= beta*((c(+1)-ve*(l(+1)^ene))^(-ge))*(1+alpha*(k^(alpha-1))*(l(+1))^(1-alpha)-delta)+phi*((k(+1)-k)/k)*(k(+1)/(k^2));
  ve*ene*(l^(ene-1)) = (1-alpha)*(k(-1)^alpha)*(l^(-alpha));
  c+i-b+(1+rstar)*b(-1) = y;
  (beta*((c(+1)-ve*(l(+1)^ene))^(-ge)))*(1+rstar)-(2*bono*b(-1))=((c-ve*(l^ene))^(-ge));
  y = (k(-1)^alpha)*(l)^(1-alpha)+(p*yp);
  i = k-(1-delta)*k(-1)+((phi/2)*(((k-k(-1))/k(-1))^2));
  y_l = y/l;
  p = gamma*p(-1)+m;
end;

%----------------------------------------------------------------
% 4. Computation
%----------------------------------------------------------------

initval;
  k = 9;
  c = 0.76;
  l = 0.3; 
  b = 1;
  m = 0;
  p = 0.2327;  
end;

shocks;
var m = desvest^2;
end;

steady;

stoch_simul(hp_filter = 1600, order = 1);

%----------------------------------------------------------------
% 5. Some Results
%----------------------------------------------------------------

statistic1 = 100*sqrt(diag(oo_.var(1:6,1:6)))./oo_.mean(1:6);
table('Relative standard deviations in %',strvcat('VARIABLE','REL. S.D.'),lgy_(1:6,:),statistic1,10,8,4);

