Commit 2b441fe5 authored by Sébastien Villemot's avatar Sébastien Villemot

Material for the Dynare Summer School 2018

parents
block.png

55.5 KB

// Endogenous variables: consumption and capital
var c k;
// Exogenous variable: technology level
varexo A;
// Parameters declaration and calibration
parameters alpha beta gamma delta;
alpha=0.5;
beta=0.95;
gamma=0.5;
delta=0.02;
// Equilibrium conditions
model;
c + k = A*k(-1)^alpha + (1-delta)*k(-1); // Resource constraint
c^(-gamma) = beta*c(+1)^(-gamma)*(alpha*A(+1)*k^(alpha-1) + 1 - delta); // Euler equation
end;
// Steady state (analytically solved)
initval;
A = 1;
k = ((1-beta*(1-delta))/(beta*alpha*A))^(1/(alpha-1));
c = A*k^alpha-delta*k;
end;
// Check that this is indeed the steady state
steady;
// Declare a positive technological shock in period 1
shocks;
var A;
periods 1;
values 1.2;
end;
// Prepare the deterministic simulation of the model over 100 periods
perfect_foresight_setup(periods=100);
// Perform the simulation
perfect_foresight_solver;
// Display the path of consumption
rplot c;
var k, y, L, c, A, a;
varexo epsilon;
parameters beta, theta, tau, alpha, psi, delta, rho, Astar;
beta = 0.9900;
theta = 0.3570;
tau = 2.0000;
alpha = 0.4500;
psi = -0.1000;
delta = 0.0200;
rho = 0.8000;
Astar = 1.0000;
model;
a = rho*a(-1) + epsilon;
A = Astar*exp(a);
y = A*(alpha*k(-1)^psi+(1-alpha)*L^psi)^(1/psi);
k = y-c + (1-delta)*k(-1);
(1-theta)/theta*c/(1-L) - (1-alpha)*(y/L)^(1-psi);
(c^theta*(1-L)^(1-theta))^(1-tau)/c = beta*(c(+1)^theta*(1-L(+1))^(1-theta))^(1-tau)/c(+1)*(alpha*(y(+1)/k)^(1-psi)+1-delta);
end;
steady_state_model;
a = epsilon/(1-rho);
A = Astar*exp(a);
Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi));
Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta;
Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/A)^psi-alpha)/(1-alpha))^(1/psi);
Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital;
Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital/Labour_per_unit_of_Capital;
% Compute steady state of the endogenous variables.
L=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)*Output_per_unit_of_Labour^(1-psi)));
c=Consumption_per_unit_of_Labour*L;
k=L/Labour_per_unit_of_Capital;
y=Output_per_unit_of_Capital*k;
end;
steady;
ik = varlist_indices('k',M_.endo_names);
kstar = oo_.steady_state(ik);
histval;
k(0) = kstar/2;
end;
perfect_foresight_setup(periods=300);
perfect_foresight_solver;
rplot c;
rplot k;
var k, y, L, c, A, a;
varexo epsilon;
parameters beta, theta, tau, alpha, psi, delta, rho, Astar;
beta = 0.9900;
theta = 0.3570;
tau = 2.0000;
alpha = 0.4500;
psi = -0.1000;
delta = 0.0200;
rho = 0.8000;
Astar = 1.0000;
model;
a = rho*a(-1) + epsilon;
A = Astar*exp(a);
y = A*(alpha*k(-1)^psi+(1-alpha)*L^psi)^(1/psi);
k = y-c + (1-delta)*k(-1);
(1-theta)/theta*c/(1-L) - (1-alpha)*(y/L)^(1-psi);
(c^theta*(1-L)^(1-theta))^(1-tau)/c = beta*(c(+1)^theta*(1-L(+1))^(1-theta))^(1-tau)/c(+1)*(alpha*(y(+1)/k)^(1-psi)+1-delta);
end;
steady_state_model;
a = epsilon/(1-rho);
A = Astar*exp(a);
Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi));
Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta;
Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/A)^psi-alpha)/(1-alpha))^(1/psi);
Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital;
Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital/Labour_per_unit_of_Capital;
% Compute steady state of the endogenous variables.
L=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)*Output_per_unit_of_Labour^(1-psi)));
c=Consumption_per_unit_of_Labour*L;
k=L/Labour_per_unit_of_Capital;
y=Output_per_unit_of_Capital*k;
end;
steady;
shocks;
var epsilon;
periods 1;
values -0.1;
end;
perfect_foresight_setup(periods=300);
perfect_foresight_solver;
rplot c;
rplot k;
var k, y, L, c, A, a;
varexo epsilon;
parameters beta, theta, tau, alpha, psi, delta, rho, Astar;
beta = 0.9900;
theta = 0.3570;
tau = 2.0000;
alpha = 0.4500;
psi = -0.1000;
delta = 0.0200;
rho = 0.8000;
Astar = 1.0000;
model;
a = rho*a(-1) + epsilon;
A = Astar*exp(a);
y = A*(alpha*k(-1)^psi+(1-alpha)*L^psi)^(1/psi);
k = y-c + (1-delta)*k(-1);
(1-theta)/theta*c/(1-L) - (1-alpha)*(y/L)^(1-psi);
(c^theta*(1-L)^(1-theta))^(1-tau)/c = beta*(c(+1)^theta*(1-L(+1))^(1-theta))^(1-tau)/c(+1)*(alpha*(y(+1)/k)^(1-psi)+1-delta);
end;
steady_state_model;
a = epsilon/(1-rho);
A = Astar*exp(a);
Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi));
Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta;
Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/A)^psi-alpha)/(1-alpha))^(1/psi);
Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital;
Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital/Labour_per_unit_of_Capital;
% Compute steady state of the endogenous variables.
L=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)*Output_per_unit_of_Labour^(1-psi)));
c=Consumption_per_unit_of_Labour*L;
k=L/Labour_per_unit_of_Capital;
y=Output_per_unit_of_Capital*k;
end;
steady;
shocks;
var epsilon;
periods 4, 5:8;
values 0.04, 0.01;
end;
perfect_foresight_setup(periods=300);
perfect_foresight_solver;
rplot c;
rplot k;
var k, y, L, c, A, a;
varexo epsilon;
parameters beta, theta, tau, alpha, psi, delta, rho, Astar;
beta = 0.9900;
theta = 0.3570;
tau = 2.0000;
alpha = 0.4500;
psi = -0.1000;
delta = 0.0200;
rho = 0.8000;
Astar = 1.0000;
model;
a = rho*a(-1) + epsilon;
A = Astar*exp(a);
y = A*(alpha*k(-1)^psi+(1-alpha)*L^psi)^(1/psi);
k = y-c + (1-delta)*k(-1);
(1-theta)/theta*c/(1-L) - (1-alpha)*(y/L)^(1-psi);
(c^theta*(1-L)^(1-theta))^(1-tau)/c = beta*(c(+1)^theta*(1-L(+1))^(1-theta))^(1-tau)/c(+1)*(alpha*(y(+1)/k)^(1-psi)+1-delta);
end;
steady_state_model;
a = epsilon/(1-rho);
A = Astar*exp(a);
Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi));
Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta;
Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/A)^psi-alpha)/(1-alpha))^(1/psi);
Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital;
Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital/Labour_per_unit_of_Capital;
% Compute steady state of the endogenous variables.
L=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)*Output_per_unit_of_Labour^(1-psi)));
c=Consumption_per_unit_of_Labour*L;
k=L/Labour_per_unit_of_Capital;
y=Output_per_unit_of_Capital*k;
end;
initval;
epsilon = 0;
end;
steady;
endval;
epsilon = (1-rho)*log(1.05);
end;
steady;
perfect_foresight_setup(periods=300);
perfect_foresight_solver;
rplot c;
rplot k;
var k, y, L, c, A, a;
varexo epsilon;
parameters beta, theta, tau, alpha, psi, delta, rho, Astar;
beta = 0.9900;
theta = 0.3570;
tau = 2.0000;
alpha = 0.4500;
psi = -0.1000;
delta = 0.0200;
rho = 0.8000;
Astar = 1.0000;
model;
a = rho*a(-1) + epsilon;
A = Astar*exp(a);
y = A*(alpha*k(-1)^psi+(1-alpha)*L^psi)^(1/psi);
k = y-c + (1-delta)*k(-1);
(1-theta)/theta*c/(1-L) - (1-alpha)*(y/L)^(1-psi);
(c^theta*(1-L)^(1-theta))^(1-tau)/c = beta*(c(+1)^theta*(1-L(+1))^(1-theta))^(1-tau)/c(+1)*(alpha*(y(+1)/k)^(1-psi)+1-delta);
end;
steady_state_model;
a = epsilon/(1-rho);
A = Astar*exp(a);
Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi));
Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta;
Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/A)^psi-alpha)/(1-alpha))^(1/psi);
Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital;
Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital/Labour_per_unit_of_Capital;
% Compute steady state of the endogenous variables.
L=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)*Output_per_unit_of_Labour^(1-psi)));
c=Consumption_per_unit_of_Labour*L;
k=L/Labour_per_unit_of_Capital;
y=Output_per_unit_of_Capital*k;
end;
initval;
epsilon = 0;
end;
steady;
endval;
epsilon = (1-rho)*log(1.05);
end;
steady;
shocks;
var epsilon;
periods 1:5;
values 0;
end;
perfect_foresight_setup(periods=300);
perfect_foresight_solver;
rplot c;
rplot k;
var k, y, L, c, A, a;
varexo epsilon;
parameters beta, theta, tau, alpha, psi, delta, rho, Astar;
beta = 0.9900;
theta = 0.3570;
tau = 2.0000;
alpha = 0.4500;
psi = -0.1000;
delta = 0.0200;
rho = 0.8000;
Astar = 1.0000;
model;
a = rho*a(-1) + epsilon;
A = Astar*exp(a);
y = A*(alpha*k(-1)^psi+(1-alpha)*L^psi)^(1/psi);
k = y-c + (1-delta)*k(-1);
(1-theta)/theta*c/(1-L) - (1-alpha)*(y/L)^(1-psi);
(c^theta*(1-L)^(1-theta))^(1-tau)/c = beta*(c(+1)^theta*(1-L(+1))^(1-theta))^(1-tau)/c(+1)*(alpha*(y(+1)/k)^(1-psi)+1-delta);
end;
steady_state_model;
a = epsilon/(1-rho);
A = Astar*exp(a);
Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi));
Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta;
Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/A)^psi-alpha)/(1-alpha))^(1/psi);
Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital;
Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital/Labour_per_unit_of_Capital;
% Compute steady state of the endogenous variables.
L=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)*Output_per_unit_of_Labour^(1-psi)));
c=Consumption_per_unit_of_Labour*L;
k=L/Labour_per_unit_of_Capital;
y=Output_per_unit_of_Capital*k;
end;
steady;
// Declare shocks as in a stochastic setup
shocks;
var epsilon;
stderr 0.02;
end;
extended_path(periods=300);
// Plot 20 first periods of consumption
ic = varlist_indices('c',M_.endo_names);
plot(oo_.endo_simul(ic, 1:21));
var k, y, L, c, A, a;
varexo epsilon;
parameters beta, theta, tau, alpha, psi, delta, rho, Astar;
beta = 0.9900;
theta = 0.3570;
tau = 2.0000;
alpha = 0.4500;
psi = -0.1000;
delta = 0.0200;
rho = 0.8000;
Astar = 1.0000;
model;
a = rho*a(-1) + epsilon;
A = Astar*exp(a);
y = A*(alpha*k(-1)^psi+(1-alpha)*L^psi)^(1/psi);
k = y-c + (1-delta)*k(-1);
(1-theta)/theta*c/(1-L) - (1-alpha)*(y/L)^(1-psi);
(c^theta*(1-L)^(1-theta))^(1-tau)/c = beta*(c(+1)^theta*(1-L(+1))^(1-theta))^(1-tau)/c(+1)*(alpha*(y(+1)/k)^(1-psi)+1-delta);
end;
steady_state_model;
a = epsilon/(1-rho);
A = Astar*exp(a);
Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi));
Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta;
Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/A)^psi-alpha)/(1-alpha))^(1/psi);
Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital;
Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital/Labour_per_unit_of_Capital;
% Compute steady state of the endogenous variables.
L=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)*Output_per_unit_of_Labour^(1-psi)));
c=Consumption_per_unit_of_Labour*L;
k=L/Labour_per_unit_of_Capital;
y=Output_per_unit_of_Capital*k;
end;
steady;
// Declare pre-announced shocks
shocks;
var epsilon;
periods 5, 15;
values -0.1, -0.1;
end;
perfect_foresight_setup(periods=300);
perfect_foresight_solver;
// Declare unexpected shock (after first simulation!)
oo_.exo_simul(11, 1) = 0.1; // Period 10 has index 11!
saved_endo = oo_.endo_simul(:, 1:9); // Save periods 0 to 8
saved_exo = oo_.exo_simul(1:9, :);
oo_.endo_simul = oo_.endo_simul(:, 10:end); // Keep periods 9 to 301
oo_.exo_simul = oo_.exo_simul(10:end, :);
periods 291;
perfect_foresight_solver;
// Combine the two simulations
oo_.endo_simul = [ saved_endo oo_.endo_simul ];
oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
rplot epsilon;
rplot c;
var k, y, L, c, i, A, a, mu;
varexo epsilon;
parameters beta, theta, tau, alpha, psi, delta, rho, Astar, sigma;
beta = 0.990;
theta = 0.357;
tau = 2.000;
alpha = 0.450;
psi = -2.500;
delta = 0.020;
rho = 0.998;
Astar = 1.000;
sigma = 0.100;
model;
a = rho*a(-1) + sigma*epsilon;
A = Astar*exp(a);
(c^theta*(1-L)^(1-theta))^(1-tau)/c - mu = beta*((c(+1)^theta*(1-L(+1))^(1-theta))^(1-tau)/c(+1)*(alpha*(y(+1)/k)^(1-psi)+1-delta)-mu(+1)*(1-delta));
((1-theta)/theta)*(c/(1-L)) - (1-alpha)*(y/L)^(1-psi);
y = A*(alpha*(k(-1)^psi)+(1-alpha)*(L^psi))^(1/psi);
k = y-c+(1-delta)*k(-1);
i = k-(1-delta)*k(-1);
[ mcp = 'i > 0' ]
mu = 0;
end;
steady_state_model;
a=0;
mu=0;
A=Astar;
// Steady state ratios
Output_per_unit_of_Capital=((1/beta-1+delta)/alpha)^(1/(1-psi));
Consumption_per_unit_of_Capital=Output_per_unit_of_Capital-delta;
Labour_per_unit_of_Capital=(((Output_per_unit_of_Capital/A)^psi-alpha)/(1-alpha))^(1/psi);
Output_per_unit_of_Labour=Output_per_unit_of_Capital/Labour_per_unit_of_Capital;
Consumption_per_unit_of_Labour=Consumption_per_unit_of_Capital/Labour_per_unit_of_Capital;
L=1/(1+Consumption_per_unit_of_Labour/((1-alpha)*theta/(1-theta)*Output_per_unit_of_Labour^(1-psi)));
c=Consumption_per_unit_of_Labour*L;
k=L/Labour_per_unit_of_Capital;
y=Output_per_unit_of_Capital*k;
i=delta*k;
end;
shocks;
var epsilon;
periods 10;
values -1;
end;
steady;
perfect_foresight_setup(periods=400);
perfect_foresight_solver(lmmcp, maxit=200);
n = 40;
figure(2);
subplot(3,2,1); plot(1:n,A(1:n)); title('A');
subplot(3,2,2); plot(2:n,y(2:n)); title('y');
subplot(3,2,3); plot(2:n,L(2:n)); title('L');
subplot(3,2,4); plot(1:n,k(1:n)); title('k');
subplot(3,2,5); plot(2:n,c(2:n)); title('c');
subplot(3,2,6); plot(2:n, y(2:n)-c(2:n)); title('i');
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage[copyright]{ccicons}
\usepackage{pstricks}
\usetheme{Boadilla}
\title{Deterministic Models}
\subtitle{Perfect foresight, nonlinearities and occasionally binding constraints}
\author{Sébastien Villemot}
\pgfdeclareimage[height=0.6cm]{logo}{cepremap}
\institute[CEPREMAP]{\pgfuseimage{logo}}
\date{June 12, 2018}
\AtBeginSection[]
{
\begin{frame}
\frametitle{Outline}
\tableofcontents[currentsection]
\end{frame}
}
\AtBeginSubsection[]
{
\begin{frame}
\frametitle{Outline}
\tableofcontents[currentsection,currentsubsection]
\end{frame}
}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Introduction}
\begin{itemize}
\item Perfect foresight = agents perfectly anticipate all future shocks
\item Concretely, at period 1:
\begin{itemize}
\item agents learn the value of all future shocks;
\item since there is shared knowledge of the model and of future shocks,
agents can compute their optimal plans for all future periods;
\item optimal plans are not adjusted in periods 2 and later \\
$\Rightarrow$ the model behaves as if it was deterministic.
\end{itemize}
\item Cost of this approach: the effect of future uncertainty is not taken
into account (\textit{e.g.} no precautionary motive)
\item Advantage: numerical solution can be computed exactly (up to rounding
errors), contrarily to perturbation or global solution methods for rational
expectations models
\item In particular, nonlinearities fully taken into account (\textit{e.g.}
occasionally binding constraints)
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Outline}
\tableofcontents
\end{frame}
\section{Presentation of the problem}
\begin{frame}
\frametitle{The (deterministic) neoclassical growth model}
\begin{equation*}
\max_{\{c_t\}_{t=1}^\infty}\sum_{t=1}^\infty \beta^{t-1}\frac{c_t^{1-\sigma}}{1-\sigma}
\end{equation*}
s.t.
\begin{equation*}
c_t+k_t = A_t k_{t-1}^\alpha + (1-\delta)k_{t-1}
\end{equation*}
First order conditions:
\begin{align*}
c_t^{-\sigma} &= \beta c_{t+1}^{-\sigma}\left(\alpha A_{t+1}k_t^{\alpha-1}+1-\delta\right)\\
c_t+k_t &= A_t k_{t-1}^\alpha + (1-\delta)k_{t-1}
\end{align*}
Steady state:
\begin{align*}
\bar k &= \left(\frac{1-\beta(1-\delta)}{\beta\alpha\bar A}\right)^{\frac{1}{\alpha-1}}\\
\bar c &= \bar A \bar k^\alpha -\delta\bar k
\end{align*}
Note the absence of stochastic elements! \\
No expectancy term, no probability distribution
\end{frame}
\begin{frame}[fragile]
\frametitle{Dynare code (1/3)}
\framesubtitle{\texttt{rcb\_basic.mod}}
\begin{verbatim}
var c k;
varexo A;
parameters alpha beta gamma delta;
alpha=0.5;
beta=0.95;
gamma=0.5;
delta=0.02;
model;
c + k = A*k(-1)^alpha + (1-delta)*k(-1);
c^(-gamma) = beta*c(+1)^(-gamma)*(alpha*A(+1)*k^(alpha-1) +
1 - delta);
end;
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\frametitle{Dynare code (2/3)}
\framesubtitle{\texttt{rcb\_basic.mod}}
\begin{verbatim}
// Steady state (analytically solved)
initval;
A = 1;
k = ((1-beta*(1-delta))/(beta*alpha*A))^(1/(alpha-1));
c = A*k^alpha-delta*k;
end;
// Check that this is indeed the steady state
steady;
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\frametitle{Dynare code (3/3)}
\framesubtitle{\texttt{rcb\_basic.mod}}
\begin{verbatim}
// Declare a positive technological shock in period 1
shocks;
var A;
periods 1;
values 1.2;
end;
// Prepare the deterministic simulation over 100 periods
perfect_foresight_setup(periods=100);
// Perform the simulation
perfect_foresight_solver;
// Display the path of consumption
rplot c;
\end{verbatim}
\end{frame}
\begin{frame}
\frametitle{Simulated consumption path}
\includegraphics[width=16cm]{rplot_c.pdf}
\end{frame}
\begin{frame}
\frametitle{The general problem}
Deterministic, perfect foresight, case:
\begin{equation*}
f(y_{t+1},y_t,y_{t-1},u_t)=0
\end{equation*}
\begin{description}
\item[$y$]: vector of endogenous variables
\item[$u$]: vector of exogenous shocks
\end{description}
\bigskip
Identification rule: as many endogenous ($y$) as equations ($f$)
\end{frame}
\begin{frame}
\frametitle{Return to the neoclassical growth model}
\begin{center}
$$y_t = \left(\begin{array}{c}
c_t \\
k_t
\end{array}
\right)$$
$$u_t = A_t$$
\bigskip
$$f(y_{t+1}, y_t, y_{t-1}, u_t) = \left(\begin{array}{l}
c_t^{-\sigma} - \beta c_{t+1}^{-\sigma}\left(\alpha A_{t+1}k_t^{\alpha-1}+1-\delta\right)\\
c_t+k_t - A_t