Skip to content
Snippets Groups Projects
Commit b81f6395 authored by sebastien's avatar sebastien
Browse files

trunk: updates to the macroprocessor slides

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2462 ac1d8469-bf42-47a9-8791-bf33cf982152
parent c346135d
Branches
Tags
No related merge requests found
...@@ -16,10 +16,9 @@ ...@@ -16,10 +16,9 @@
} }
\title{The Dynare Macro-processor} \title{The Dynare Macro-processor}
\subtitle{Dynare Summer School 2008}
\author{Sébastien Villemot} \author{Sébastien Villemot}
\institute[BoFrance - PSE]{Bank of France - Paris School of Economics} \institute[BoFrance - PSE]{Bank of France - Paris School of Economics}
\date{July 3, 2008} \date{February 2, 2009}
\AtBeginSection[] \AtBeginSection[]
{ {
...@@ -70,7 +69,7 @@ ...@@ -70,7 +69,7 @@
\item conditional inclusion (if/then/else structures) \item conditional inclusion (if/then/else structures)
\item expression substitution \item expression substitution
\end{itemize} \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 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) \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} \end{itemize}
...@@ -159,6 +158,7 @@ ...@@ -159,6 +158,7 @@
\item concatenation: \texttt{+} \item concatenation: \texttt{+}
\item difference \texttt{-}: returns the first operand from which the elements of the second operand have been removed \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 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{itemize}
\end{block} \end{block}
...@@ -310,6 +310,7 @@ end; ...@@ -310,6 +310,7 @@ end;
% \item Useful to understand how the macro-processor works % \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 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 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{itemize}
\end{frame} \end{frame}
...@@ -406,7 +407,7 @@ end; ...@@ -406,7 +407,7 @@ end;
\end{frame} \end{frame}
\begin{frame} \begin{frame}
\frametitle{Endogeneizing parameters (1/3)} \frametitle{Endogeneizing parameters (1/4)}
\begin{itemize} \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 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: \item Example:
...@@ -414,16 +415,36 @@ end; ...@@ -414,16 +415,36 @@ 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}} \\ 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} lab\_rat = \frac{w \ell}{p y}
\end{gather*} \end{gather*}
\item During simulation or estimation, the share parameter $\alpha$ is a parameter, and $lab\_rat$ is an endogenous variable \item In the model, $\alpha$ is a (share) 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$ \\ \item We observe that:
$\Rightarrow$ during calibration, $\alpha$ is endogenous and $lab\_rat$ is a parameter \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/4)}
\begin{itemize}
\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{itemize}
\end{frame} \end{frame}
\begin{frame}[fragile=singleslide] \begin{frame}[fragile=singleslide]
\frametitle{Endogeneizing parameters (2/3)} \frametitle{Endogeneizing parameters (3/4)}
\framesubtitle{Example implementation}
\begin{itemize}
\item File \texttt{modeqs.mod}:
\begin{itemize} \begin{itemize}
\item Create \texttt{modeqs.mod} with variable declarations and model equations \item contains variable declarations and model equations
\item For declaration of \texttt{alpha} and \texttt{lab\_rat}: \item For declaration of \texttt{alpha} and \texttt{lab\_rat}:
\footnotesize \footnotesize
\begin{verbatim} \begin{verbatim}
...@@ -436,28 +457,30 @@ end; ...@@ -436,28 +457,30 @@ end;
@#endif @#endif
\end{verbatim} \end{verbatim}
\normalsize \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{itemize} \end{itemize}
\end{frame} \end{frame}
\begin{frame}[fragile=singleslide] \begin{frame}[fragile=singleslide]
\frametitle{Endogeneizing parameters (3/3)} \frametitle{Endogeneizing parameters (4/4)}
\framesubtitle{Example implementation}
\begin{itemize} \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} \begin{itemize}
\item begins with \verb+@#define steady = 0+ \item begins with \verb+@#define steady = 0+
\item then with \verb+@#include "modeqs.mod"+ \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 \item computes simulations
\end{itemize} \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{itemize}
\end{frame} \end{frame}
...@@ -507,7 +530,7 @@ end; ...@@ -507,7 +530,7 @@ end;
\item Small adjustments have been made in recent versions of Dynare to make it run on Octave \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 This makes Dynare 100\% free software
\item If you're interested in using Dynare for Octave, go to: \\ \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 \\ \item Adapting Dynare for Octave is still a work in progress \\
$\Rightarrow$ feedback is welcome $\Rightarrow$ feedback is welcome
\end{itemize} \end{itemize}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment