trunk: updates to the macroprocessor slides

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2462 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
sebastien 2009-03-13 16:34:56 +00:00
parent 70b870ef74
commit 6e13e905b4
1 changed files with 45 additions and 22 deletions

View File

@ -16,10 +16,9 @@
}
\title{The Dynare Macro-processor}
\subtitle{Dynare Summer School 2008}
\author{Sébastien Villemot}
\institute[BoFrance - PSE]{Bank of France - Paris School of Economics}
\date{July 3, 2008}
\date{February 2, 2009}
\AtBeginSection[]
{
@ -70,7 +69,7 @@
\item conditional inclusion (if/then/else structures)
\item expression substitution
\end{itemize}
% \item Technically, this language is independent of the basic Dynare language, and is processed by a separate component of the Dynare pre-processor, called the \textbf{macro-processor}
\item Implemented in Dynare starting from 4.0 version
\item The macro-processor transforms a MOD file with macro-commands into a MOD file without macro-commands (doing text expansions/inclusions) and then feeds it to the Dynare parser
\item The key point to understand is that the macro-processor only does \textbf{text substitution} (like the C preprocessor or the PHP language)
\end{itemize}
@ -159,6 +158,7 @@
\item concatenation: \texttt{+}
\item difference \texttt{-}: returns the first operand from which the elements of the second operand have been removed
\item extraction of sub-arrays: \textit{e.g.} \texttt{v[4:6]}
\item testing membership of an array: \texttt{in} operator (only in unstable version of Dynare)
\end{itemize}
\end{block}
@ -310,6 +310,7 @@ end;
% \item Useful to understand how the macro-processor works
\item Just add the \texttt{savemacro} option on the Dynare command line (after the name of your MOD-file)
\item If MOD file is \texttt{filename.mod}, then the macro-expanded version will be saved in \texttt{filename-macroexp.mod}
\item With the unstable version of Dynare, you can specify the filename for the macro-expanded version with the syntax \texttt{savemacro=mymacroexp.mod}
\end{itemize}
\end{frame}
@ -406,7 +407,7 @@ end;
\end{frame}
\begin{frame}
\frametitle{Endogeneizing parameters (1/3)}
\frametitle{Endogeneizing parameters (1/4)}
\begin{itemize}
\item When doing the steady-state calibration of the model, it may be useful to consider a parameter as an endogenous (and vice-versa)
\item Example:
@ -414,17 +415,37 @@ end;
y = \left(\alpha^{\frac{1}{\xi}} \ell^{1-\frac{1}{\xi}} + (1-\alpha)^{\frac{1}{\xi}}k^{1-\frac{1}{\xi}}\right)^{\frac{\xi}{\xi - 1}} \\
lab\_rat = \frac{w \ell}{p y}
\end{gather*}
\item During simulation or estimation, the share parameter $\alpha$ is a parameter, and $lab\_rat$ is an endogenous variable
\item But for steady-state calibration, we may want to impose an economically relevant value for $lab\_rat$, and deduce the implied value for $\alpha$ \\
$\Rightarrow$ during calibration, $\alpha$ is endogenous and $lab\_rat$ is a parameter
\item In the model, $\alpha$ is a (share) parameter, and $lab\_rat$ is an endogenous variable
\item We observe that:
\begin{itemize}
\item calibrating $\alpha$ is not straigthforward!
\item on the contrary, we have real world data for $lab\_rat$
\item it is clear that these two variables are economically linked
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{Endogeneizing parameters (2/3)}
\frametitle{Endogeneizing parameters (2/4)}
\begin{itemize}
\item Create \texttt{modeqs.mod} with variable declarations and model equations
\item For declaration of \texttt{alpha} and \texttt{lab\_rat}:
\item Therefore, when computing the steady state:
\begin{itemize}
\item we make $\alpha$ an endogenous variable and $lab\_rat$ a parameter
\item we impose an economically relevant value for $lab\_rat$
\item the solution algorithm deduces the implied value for $\alpha$
\end{itemize}
\item We call this method ``variable flipping''
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{Endogeneizing parameters (3/4)}
\framesubtitle{Example implementation}
\begin{itemize}
\item File \texttt{modeqs.mod}:
\begin{itemize}
\item contains variable declarations and model equations
\item For declaration of \texttt{alpha} and \texttt{lab\_rat}:
\footnotesize
\begin{verbatim}
@#if steady
@ -436,28 +457,30 @@ end;
@#endif
\end{verbatim}
\normalsize
\item Create \texttt{steady.mod}:
\begin{itemize}
\item begins with \verb+@#define steady = 1+
\item then with \verb+@#include "modeqs.mod"+
\item initializes parameters (including \texttt{lab\_rat}, excluding \texttt{alpha})
\item computes steady state (using hints for endogenous, including \texttt{alpha})
\item saves values of parameters and endogenous at steady-state to a file
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile=singleslide]
\frametitle{Endogeneizing parameters (3/3)}
\frametitle{Endogeneizing parameters (4/4)}
\framesubtitle{Example implementation}
\begin{itemize}
\item Create \texttt{simul.mod}:
\item File \texttt{steady.mod}:
\begin{itemize}
\item begins with \verb+@#define steady = 1+
\item then with \verb+@#include "modeqs.mod"+
\item initializes parameters (including \texttt{lab\_rat}, excluding \texttt{alpha})
\item computes steady state (using guess values for endogenous, including \texttt{alpha})
\item saves values of parameters and endogenous at steady-state in a file, using the \texttt{load\_params\_and\_steady\_state} command
\end{itemize}
\item File \texttt{simul.mod}:
\begin{itemize}
\item begins with \verb+@#define steady = 0+
\item then with \verb+@#include "modeqs.mod"+
\item loads values of parameters and endogenous at steady-state from file
\item loads values of parameters and endogenous at steady-state from file, using the \texttt{save\_params\_and\_steady\_state} command
\item computes simulations
\end{itemize}
\item \textit{Note:} functions for saving and loading parameters and endogenous are not yet in Dynare distribution (they should be soon, ask me if you're interested)
\end{itemize}
\end{frame}
@ -507,7 +530,7 @@ end;
\item Small adjustments have been made in recent versions of Dynare to make it run on Octave
\item This makes Dynare 100\% free software
\item If you're interested in using Dynare for Octave, go to: \\
\url{http://www.cepremap.cnrs.fr/DynareWiki/DynareOctave}
\url{http://www.dynare.org/DynareWiki/DynareOctave}
\item Adapting Dynare for Octave is still a work in progress \\
$\Rightarrow$ feedback is welcome
\end{itemize}