Slides for Ispra 2022 workshop.

master
Stéphane Adjemian (Argos) 2023-11-15 15:45:41 +01:00
parent a151225fb3
commit f38b87a8e5
Signed by: stepan
GPG Key ID: A6D44CB9C64CE77B
4 changed files with 119 additions and 127 deletions

36
.gitignore vendored
View File

@ -10,28 +10,23 @@
*_dynamic.mexmaci64
*_static.mexmaci64
*.fdb_latexmk
*.fls
matlab.mk
mod/rbc/rbc.m
mod/rbc/rbc_pea2.m
mod/rbc/locals.m
mod/rbc/*_set_auxiliary_variables.m
mod/rbc/*_dynamic.m
mod/rbc/*_static.m
mod/rbc/*_steadystate2.m
mod/rbc/+rbc/*
mod/rbc/rbc/*
mod/rbc/locals.m
mod/rbc/rbc_pea2/*
mod/rbc/rbc_pea3/*
mod/rbc/+rbc_pea2/*
mod/rbc/+rbc_pea3/*
mod/rbcii/rbc.m
mod/rbcii/rbc/*
mod/rbcii/rbc_set_auxiliary_variables.m
mod/rbcii/rbc_steadystate2.m
mod/rbcii/rbcii.m
mod/rbcii/+rbc/*
mod/rbcii/rbcii/*
mod/rbcii/rbcii_set_auxiliary_variables.m
mod/rbcii/rbcii_steadystate2.m
mod/rbcii/+rbcii/*
mod/rbc-simple/locals.m
mod/rbc-simple/results/*
@ -45,9 +40,10 @@ mod/rbcii-simple/*.txt
mod/rbcii-simple/*.mat
mod/rbcii-simple/*.log
slides/ep.aux
slides/ep.nav
slides/ep.out
slides/ep.snm
slides/ep.toc
slides/auto/
slides/slides.aux
slides/slides.nav
slides/slides.out
slides/slides.snm
slides/slides.toc
slides/slides.vrb

View File

@ -16,7 +16,7 @@ psi = -1.000;
delta = 0.100;
rho = 0.800;
effstar = 1.000;
sigma = 0.150;
sigma = 0.100;
model(use_dll);
@ -54,7 +54,7 @@ end;
// Write analytical steady state file (without globals)
options_.steadystate_flag = 2;
copyfile('rbcii_steady_state.m','rbcii_steadystate2.m');
copyfile('rbcii_steady_state.m','+rbcii/steadystate.m');
steady;
@ -64,12 +64,19 @@ shocks;
var EfficiencyInnovation = 1;
end;
ts = extended_path(oo_.steady_state, 1000, [], options_, M_, oo_);
ptions_.ep.stochastic.quadrature.nodes = 3;
extended_path(periods=200);
ts = Simulated_time_series;
ts.save('simulated-data-ep-0');
extended_path(periods=200, order=1);
ts = Simulated_time_series;
ts.save('simulated-data-ep-1');
return
extended_path(periods=100);
ts0 = Simulated_time_series;
transition;
regression;
distribution;

View File

@ -6,6 +6,7 @@ slides.pdf: slides.tex
while ($(LATEX) slides.tex ; \
grep -q "Rerun to get cross" slides.log ) do true ; \
done
clean:
rm -f *.aux *.log *.out *.nav *.rel *.toc *.snm *.synctex.gz *.vrb
rm -rf auto
@ -14,7 +15,7 @@ clean-all:
rm -f *.pdf
push: slides.pdf
scp ep.pdf ulysses:~/www/dynare.ithaca.fr/slides/sep.pdf
scp slides.pdf ryuk:~/home/www/dynare.adjemian.eu/prose/ispra-2022.pdf
.PHONY: push

View File

@ -5,6 +5,7 @@
\usepackage{nicefrac}
\usepackage{mathrsfs}
\usepackage{etex}
\usepackage{xcolor}
\usepackage{pgfplots,tikz}
\usepackage{tikz-qtree}
@ -19,13 +20,13 @@
\newlength\figureheight
\newlength\figurewidth
\definecolor{gray}{gray}{0.4}
\begin{document}
\title{The stochastic extended path approach}
\author{St\'ephane Adjemian\footnote{Universit\'e du Maine} and Michel Juillard\footnote{Banque de France}}
\date{June, 2016}
\title{(stochastic) Extended path}
\author{}
\date{}
\begin{frame}
\titlepage{}
@ -35,16 +36,15 @@
\frametitle{Motivations}
\begin{itemize}
\item Severe nonlinearities play sometimes an important role in
macroeconomics.
\item In particular occasionally binding constraints: irreversible
investment, borrowing constraint, ZLB.
\item Nonlinearity can play an important role in
macroeconomics.\newline
\item Large deviations w.r.t. the steady state or occasionally binding constraints: irreversible
investment, borrowing constraint, ZLB.\newline
\item Usual local approximation techniques don't work when there are
kinks.
\item Deterministic, perfect forward, models can be solved with much
greater accuracy than stochastic ones.
\item Deterministic models can be solved with arbitrary accuracy, unlike stochastic ones with perturbation.\newline
\item The extended path approach aims to keep the ability of
deterministic methods to provide accurate account of nonlinearities.
deterministic methods to provide accurate account of nonlinearities.
\end{itemize}
\end{frame}
@ -82,16 +82,16 @@ auxiliary variables.
\begin{itemize}
\item Perfect foresight models, after a shock economy returns asymptotically
to equilibirum.
to equilibirum.\newline
\item For a long enough simulation, one can consider that for all
practical purpose the system is back to equilibrium.
practical purpose the system is back to equilibrium.\newline
\item This suggests to solve a two value boundary problem with
initial conditions for some variables (backward looking) and
terminal conditions for others (forward looking).
terminal conditions for others (forward looking).\newline
\item In practice, one can use a Newton method to the equations of
the model stacked over all periods of the simulation.
the model stacked over all periods of the simulation.\newline
\item The Jacobian matrix of the stacked system is very sparse and
this characteristic must be used to write a practical algorithm.
this characteristic must be used to write a practical algorithm.
\end{itemize}
\end{frame}
@ -102,10 +102,10 @@ auxiliary variables.
\begin{itemize}
\item Already proposed by Fair and Taylor (1983).
\item Already proposed by Fair and Taylor (1983).\newline
\item The extended path approach creates a stochastic simulation as if only
the shocks of the current period were random.
the shocks of the current period were random.\newline
\item Substituting (\ref{eq:gmodel:1}) in (\ref{eq:gmodel:4}), define:
\[
@ -176,27 +176,20 @@ s_{t+H} &= \mathsf Q(s_{t+H-1},0)\\
\frametitle{Extended path algorithm (discussion)}
\begin{itemize}
\item This approach takes full account of the \emph{deterministic}
non linearities...
\medskip
non linearities...\newline
\item ... But neglects the Jensen inequality by setting future
innovations to zero (the expectation).
\bigskip
innovations to zero (the expectation).\newline
\item We do not solve the rational expectation model! We solve a
model where the agents believe that the economy will not be
perturbed in the future. They observe new realizations of the
innovations at each date but do not update this belief...
\bigskip
innovations in each period but do not update this belief...\newline
\item Uncertainty about the future does not matter here.
\item Uncertainty about the future does not matter here.\newline
\medskip
\item EP > First order perturbation (certainty equivalence)
\item EP > OccBin > First order perturbation\newline
\end{itemize}
\end{frame}
@ -206,9 +199,14 @@ s_{t+H} &= \mathsf Q(s_{t+H-1},0)\\
\frametitle{Stochastic extended path}
\begin{itemize}
\item The strong assumption about future uncertainty can be relaxed
by approximating the expected terms in the Euler
equations~(\ref{eq:gmodel:2})
equations~(\ref{eq:gmodel:2}):
\begin{equation*}\label{eq:gmodel:2}%\tag{Euler equations}
\mathsf F \left(y_t,x_t,s_t,\mathbb E_t \left[ \mathscr E_{t+1}\right]\right) = 0
\end{equation*}
\bigskip
@ -230,12 +228,11 @@ s_{t+H} &= \mathsf Q(s_{t+H-1},0)\\
\frametitle{Gaussian quadrature (univariate)}
\begin{itemize}
\item Let $X$ be a Gaussian random variable with mean zero and variance $\sigma^2_x>0$, and suppose that we need to evaluate
$\mathbb E [\varphi(X)]$, where $\varphi$ is a continuous function.
\item By definition we have:
$\mathbb E [\varphi(X)]$, where $\varphi$ is a continuous function:
{\small\[
\mathbb E [\varphi(X)] = \frac{1}{\sigma_x\sqrt{2\pi}}\int_{-\infty}^{\infty} \varphi(x)e^{-\frac{x^2}{2\sigma^2_x}}\mathrm dx
\]}
\item It can be shown that this integral can be approximated by a finite sum using the following result:
\item The integral can be approximated by a finite sum, using:
{\small\[
\int_{-\infty}^{\infty} \varphi(z)e^{-z^2}\mathrm dx = \sum_{i=1}^n\omega_i \varphi(z_i) {\gray + \frac{n!\sqrt{n}}{2^n}\frac{\varphi^{(2n)}(\xi)}{(2n)!}}
\]} where $z_i$ ($i=1,\dots,n$) are the roots of an order $n$
@ -254,39 +251,37 @@ s_{t+H} &= \mathsf Q(s_{t+H-1},0)\\
{\small\[
\mathbb E [\varphi(X)] = (2\pi)^{-\frac{p}{2}}\int_{\mathbb R^{p}} \varphi(\bm{x})e^{-\frac{1}{2} \bm{x}'\bm{x}}\mathrm d\bm{x}
\]}
\item Let $\{(\omega_i,z_i)\}_{i=1}^n$ be the weights and nodes of an order $n$ univariate Gaussian quadrature.
\item Let $\{(\omega_i,z_i)\}_{i=1}^n$ be the weights and nodes of an order $n$ univariate Gaussian quadrature.\newline
\item This integral can be approximated using a tensor grid:
{\small\[
\int_{\mathbb R^{p}} \varphi(\bm{z})e^{-\bm{z}'\bm{z}}\mathrm d\bm{z} \approx \sum_{i_1,\dots,i_p=1}^n\omega_{i_1}\dots\omega_{i_p} \varphi(z_{i_1},\dots,z_{i_p})
\]}
\item \textbf{Curse of dimensionality:} The number of terms in the sum grows exponentially with the number of shocks.
\item \textbf{Curse of dimensionality 1}: The number of terms in the sum grows exponentially with the number of shocks.
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Unscented transform}
\begin{frame}[fragile]
\frametitle{Other numerical integration rules}
\begin{itemize}
\item Let $X$ be a $p\times 1$ multivariate random variable with mean zero and variance $\Sigma_x$. We need to compute moments of $Y = \varphi(X)$.
\item Let $\mathscr S_p = \{\omega_i,\bm{x}_i\}_{i=1}^{2p+1}$ be a set of deterministic weights and points:
{\footnotesize
\[
\begin{array}{rclcrcl}
\bm{x}_0 &=& 0 && \omega_0 &=& \frac{\kappa}{p+\kappa} \\
\bm{x}_i &=& \left(\sqrt{(p+\kappa)\Sigma_x}\right)_i && \omega_i &=& \frac{1}{2(p+\kappa)}\text{, for i=1,\dots,p}\\
\bm{x}_i &=& -\left(\sqrt{(p+\kappa)\Sigma_x}\right)_{i-p} && \omega_i &=& \frac{1}{2(p+\kappa)}\text{, for i=p+1,\dots,2p}\\
\end{array}
\]}
where $\kappa$ is a real positive scaling parameter.
\item It can be shown that the weights are positive and summing-up to one and that the first and second order ``sample'' moments of $\mathscr S_p$ are matching those of $X$.
\item Compute the moments of $Y$ by applying the mapping $\varphi$ to $\mathscr S_p$.
\item Exact mean and variance of $Y$ for a second order Taylor approximation of $\varphi$.
\item By default Dynare uses multivariate Gaussian quadrature to approximate the expected terms.\newline
\item To cope with \textbf{curse of dimensionality 1} we can consider other numerical integration approaches:\newline
\begin{itemize}
\item[--] Cubature (ordre 3 or 5)\\
Set \verb+options_.ep.IntegrationAlgorithm+ to \verb+'Stroud-Cubature-3'+ or \verb+'Stroud-Cubature-5'+ \newline
\item[--] Unscented transform\\
Set \verb+options_.ep.IntegrationAlgorithm+ to \verb+'Unscented'+\newline
\end{itemize}
\item These alternatives rely on a smaller number of nodes, which do
not grow exponentially with the number of innovations.\newline
\item But there is another curse of dimensionality.
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Forward histories (one shock, three nodes, order two SEP)}
\framesubtitle{Curse of dimensionality 2}
\begin{tikzpicture}
\tikzset{grow'=right,level distance=80pt}
\tikzset{execute at begin node=\strut}
@ -311,11 +306,11 @@ s_{t+H} &= \mathsf Q(s_{t+H-1},0)\\
\begin{frame}
\frametitle{Fishbone integration}
\begin{itemize}
\item The curse of dimensionality can be overcome by pruning the tree of forward histories.
\item This can be done by considering that innovations, say, at time $t+1$ and $t+2$ are unrelated variables (even if they share the same name).
%\item Analogy with a good at different periods in an intertemporal general equilibrium model.
\item If we have $n_u$ innovations and if agents perceive uncertainty for the next $k$ following periods, we consider an integration problem involving $n_u \times k$ unrelated variables.
\item We use a two points Cubature rule to compute the integral (unscented transform with $\kappa=0$) $\rightarrow$ The complexity of the integration problem grows linearly with $n_u$ or $k$
\item We can prune the tree of forward histories by removing low probability branches...\newline
\item Or by considering that innovations, say, at time $t+1$ and $t+2$ are unrelated variables.\newline
\item {\color{gray} Analogy with a good at different periods in an intertemporal general equilibrium model.}\newline
\item If we have $n_u$ innovations and if agents perceive uncertainty for the next $k$ following periods, we consider an integration problem involving $n_u \times k$ unrelated variables.\newline
\item We use a two points Cubature rule to compute the integral (unscented transform with $\kappa=0$) $\rightarrow$ The complexity of the integration problem grows linearly with $n_u$ or $k$\newline
\end{itemize}
\end{frame}
@ -423,16 +418,14 @@ s_{t+H}^{i,j} &= \mathsf Q(s_{t+H-1}^{i,j},0)\\
\end{frame}
\begin{frame}
\frametitle{Stochastic extended path (discussion)}
\begin{itemize}
\item The extended path approach takes full account of the deterministic nonlinearities of the model.
\item It takes into account the nonlinear effects of future shocks $k$-period ahead.
\item It neglects the effects of uncertainty in the long run. In most models this effect declines with the discount factor.
\item The Stochastic Perfect Foresight model, that must be solved at each date, is very large.
\item Curse of dimensionality with respect with the number of innovations and the order of approximation but \emph{not with the number of state variables}!
\item The extended path approach takes full account of the deterministic nonlinearities of the model.\newline
\item It also takes into account the nonlinear effects of future shocks $k$-period ahead.\newline
\item It neglects the effects of uncertainty in the long run.\newline
\item The Stochastic Perfect Foresight model, that must be solved at each date, is huge.\newline
\item Curse of dimensionality with respect with the number of innovations \textbf{and} the order of approximation but \emph{not with the number of state variables}!
\end{itemize}
\end{frame}
@ -446,7 +439,7 @@ s_{t+H}^{i,j} &= \mathsf Q(s_{t+H-1}^{i,j},0)\\
\item Household's intertemporal utility is given by
\[
\mathbb E_t\left[\sum_{\tau = 0}^\infty
\beta^{-\tau}\frac{c^\theta_{t+\tau}}{\theta}\right]\quad\quad\mbox{with }
\beta^{t-\tau}\frac{c^\theta_{t+\tau}}{\theta}\right]\quad\quad\mbox{with }
\theta \in (-\infty,0) \cup (0,1]
\]
\item Budget constraint is
@ -521,6 +514,8 @@ and
\[
b_i = \frac{\theta\rho\left(1-\rho^i\right)}{1-\rho}
\]
\medskip
Note that we abstract from the accuracy errors introduced by the numerical approximation of the integrals.
\end{frame}
\begin{frame}
@ -546,33 +541,29 @@ is equal to 12.4812.
\end{frame}
\begin{frame}
\frametitle{Comparing expended path and closed-form solution}
Difference between expended path approximation, $\hat y_t$, and closed-form
solution, $y_t$.
\frametitle{Comparing extended path and closed-form solution}
Difference between extended path approximation, $\hat y_t$, and closed-form
solution, $y_t$.\newline
\begin{itemize}
\item Using 800 terms to approximate the infinite summation
\item Computing over 30000 periods
\item Using 800 terms to approximate the infinite summation\newline
\item Computing over 30000 periods\newline
\end{itemize}
\begin{align*}
\min\left(y_t-\hat y_t\right) &= 0.1726\\
\max\left(y_t-\hat y_t\right) &= 0.1820\\
\end{align*}
\begin{itemize}
\item The effect of future volatility isn't trivial
\[
\frac{\tilde y-\bar y}{\bar y} = 0.0144
\]
\item The effect of future volatility doesn't depend much on the state
of the economy.
\item The effect of future volatility is around 1\%, $\frac{\tilde y-\bar y}{\bar y} = 0.0144$, and doesn't depend much on the state of the economy.
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Stochastic extended path}
\begin{itemize}
\item A $k$-order stochastic expended path approach computes the conditional
\item A $k$-order stochastic extended path approach computes the conditional
expectation taking into accounts the shocks over the next $k$ periods.
\item The closed formula is
\item The closed formula is
\[
\check{y}_t = \sum_{i=1}^\infty \beta^i e^{a_i+b_i\hat x_t}
\]
@ -584,7 +575,7 @@ solution, $y_t$.
\frac{\theta^2\sigma^2}{2(1-\rho)^2}\left(i-2\rho\frac{1-\rho^i}{1-\rho}+\rho^2\frac{1-\rho^{2i}}{1-\rho^2}\right)
& \mbox{ for } & i\le k\\
\frac{\theta^2\sigma^2}{2(1-\rho)^2}\left(k-2\rho\frac{\rho^{i-k}-\rho^i}{1-\rho}+\rho^2\frac{\rho^{2(i-k)}-\rho^{2i}}{1-\rho^2}\right)
& \mbox{ for } & i > k
& \mbox{ for } & i > k
\end{array}
\right.
\]
@ -599,16 +590,16 @@ solution, $y_t$.
\begin{frame}
\frametitle{Quantitative evaluation}
\begin{itemize}
\item What is the ability of the stochastic extended path approach to
capture the effect of future volatility?
\item What part of the difference between the risky steady state and
deterministic steady state is captured by different values of $k$?
\item Deterministic steady state: 12.3035
\item Risky steady state: 12.4812
\item What is the ability of the stochastic extended path approach to capture
the effect of future volatility? What part of the difference between the risky
steady state and deterministic steady state is captured by different values of
$k$?\newline
\item Deterministic steady state: 12.3035\newline
\item Risky steady state: 12.4812\newline
\item The contribution of $k$ future periods
\begin{center}
\begin{tabular}{cc}
$k$ & Percentage\\
$k$ & Percentage\\
1 & 7.4\%\\
2 & 14.3\%\\
9 & 50.0\%\\
@ -616,8 +607,8 @@ capture the effect of future volatility?
60 & 99.0\%
\end{tabular}
\end{center}
\item In such a model, it is extremely costly to give full account of
the effects of future volatility with the stochastic extended path approach.
%\item In such a model, it is extremely costly to give full account of
% the effects of future volatility with the stochastic extended path approach.
\end{itemize}
\end{frame}
@ -628,11 +619,11 @@ capture the effect of future volatility?
\item A very large number of periods forward (the order of stochastic
extended path) is necessary to obtain an accurate figure of the
effects of future volatility.
effects of future volatility.\newline
\item However, even a local approximation with a Taylor expansion of
low order provides better information on this effect of future
volatility.
volatility.\newline
\item This suggests to combine the two approaches.
@ -684,7 +675,6 @@ s_{t+H}^i &= \mathsf Q(s_{t+H-1}^i,0)\\
\end{tabular}
\end{center}
\end{frame}
@ -782,14 +772,12 @@ where $\mu_t$ is the Lagrange multiplier associated with the constraint on inves
\begin{frame}
\frametitle{Conclusion and future work}
\begin{itemize}
\item The extended path approach takes into account effects of nonlinearities.
\item The stochastic extended path approach takes also partially into account nonlinear effects of future volatility.
\item Possible to use an hybrid approach, using the risky steady state as terminal condition.
\item The approach suffers from the curse of dimensionality but it can be mitigated by
\begin{itemize}
\item using monomial formulas for integration when there are several shocks
\item exploiting embarassingly parallel nature of the algorithm
\end{itemize}
\item The extended path approach takes into account effects of nonlinearities.\newline
\item The stochastic extended path approach takes also partially into account nonlinear effects of future volatility.\newline
\item Possible to use an hybrid approach.\newline
\item The approach suffers from the curse of dimensionality but it can be mitigated.\newline
\item Parallelization is possible if EP is used in estimation (SMM or PF) but not in the SEP solver.\newline
\item Improvements: produce IRFs with SEP, write a mex for building the stacked SEP nonlinear problem.
\end{itemize}
\end{frame}