
%***************************************************************************
% DYNARE Model II in levels                   			                   * 
%                                                                          *
% This version has consumers optimising intertemporally                    *
% The steady state of the model is calculated in levels.                   *
%                                                                          *               
%***************************************************************************

%Comments 
%-----------------
%NB Labour supply is FIXED.
%No aggregate measure of output, Ytot or Yagg. Profits excluded. 
%All exogenous variables are put in as parameters. 
%12 endogenous variables

%List of variables
%-----------------
%Cn consumption of nontradables, Ct consumption of tradables, Cagg consumption
%index, Pn price of nontradables, Pagg price index, D portfolio of riskless
%bonds, Yn production of nontradables, Yt production of tradables, 
%BoP balance of payments.

%-----------------------------------------------------
% 0. Housekeeping (close graphics windows)
%-----------------------------------------------------

close all;

%-----------------------------------------------------
% 1. Define variables
% Endogenous (var) and exogenous (varexo)
%-----------------------------------------------------

%Define endogenous variables-------
var
Cn, Ct, Cagg, Pn, Pagg, D, BoP, 
Yn, Yt,
W, Ln, Lt;


%-----------------------------------------------------
% 2. Define parameters and assign parameter values 
%-----------------------------------------------------

parameters

gamma, alphat, epsilon, 
Lbar,             
REM, Pt, An, At, expAn, expAt, rglob, rprem, rdom;			                       

%1. Basic model parameters
%2. Fixed labour supply
%3. Exogenous variables held fixed


% Setting parameters----------- 

gamma = 0.50;			%T-NT elasticity of subn in consumption
alphat = 0.65; 			%Cobb-Douglas parameter for T production
epsilon = 11;	 		%Price elasticity of demand for NT goods (value from Gali 2001)

Lbar = 1;			    %Fixed labour supply, normalised to 1

rglob = 0.05;           %World interest rate
rprem = 0.03;           %Risk premium
rdom = rglob+rprem;     %Domestic interest rate (assuming fixed exchange rate)                     
Pt = 1;                 %Price of tradables (normalised to 1)
At = 0;
An = 0;
expAn = exp(An);              
expAt = exp(At);  
REM = 0.124;


%-----------------------------------------------------
% 3. Defining the model (Model II in levels)
%-----------------------------------------------------
model;

Cagg=(Cn^(1-gamma)*Ct^gamma)/(gamma^gamma*(1-gamma)^(1-gamma));
Pagg=Pt^gamma*Pn^(1-gamma);
Pagg*Cagg + D(+1)/(1+rdom)= D + W*Lbar+REM;
Cn=((1-gamma)*Pagg*Cagg)/Pn;
Ct=gamma*Pagg*Cagg/Pt;
Yt=expAt*(Lt^alphat);
Yn=expAn*Ln;
W=alphat*Yt*Pt*(1/Lt);
Pn=(epsilon/(epsilon-1))*W/expAn;
Yn=Cn;
Lt+Ln=Lbar;
#prof_n = Yn*Pn - W*Ln;
#prof_t = Yt*Pt - W*Lt;
BoP=Yt*Pt+REM-Ct*Pt-prof_n-prof_t;

end;

%Setting initial values for numerical analysis	

initval;
BoP=0;
Yn=0.6164;
Cn=0.6164;
Ln=0.6164;
Lt=0.3836;
Pn=1;
Pagg=1;
Yt=0.5364;
W=0.9091;
Ct=0.6164;
Cagg=0.8; 
D=0;
end;

%Solving the model to find the steady state

steady (solve_algo=1);

check;


%END OF PROGRAM
