This document describes a model involving both endogenous and exogenous state variable. We first describe the theoretical model, before showing how the perturbation method is implemented in {\sc Dynare}.
We consider an economy that consists of a large number of dynastic households and a large number of firms. Firms are producing a homogeneous final product that can be either consumed or invested by means of capital and labor services. Firms own their capital stock and hire labor supplied by the households. Households own the firms. In each and every period three perfectly competitive markets open --- the markets for consumption goods, labor services, and financial capital in the form of firms' shares.
Household preferences are characterized by the lifetime utility function:
\noindent where $0<\beta^\star<1$ is a constant discount factor, $c_t$ is consumption in period
$t$, $h_t$ is the fraction of total available time devoted to productive activity in period $t$, $\theta>0$ and $\psi\geqslant0$. We assume that there exists a central planner that determines hours, consumption and capital accumulation maximizing the household's utility function subject to the following budget constraint
\begin{equation}
c_t+i_t=y_t
\label{eq:bud}
\end{equation}
\noindent where $i_t$ is investment and $y_t$ is output. Investment is used to form physical capital, which accumulates in the standard form as:
\begin{equation}
k_{t+1}=\exp(b_t) i_t+(1-\delta)k_t \mbox{ with } 0<\delta<1
\label{eq:acc}
\end{equation}
where $\delta$ is the constant physical depreciation rate. $b_t$ is a shock affecting incorporated technological progress, which properties will be defined later.
Output is produced by means of capital and labor services, relying on a constant returns to scale technology represented by the following Cobb--Douglas production function:
\begin{equation}
y_t=\exp(a_t) k_t^\alpha h_t^{1-\alpha}\mbox{ with }0<\alpha<1 \label{eq:prod}
\end{equation}
$a_t$ represents a stochastic shock to technology or Solow residual. We assume that the shocks to technology are distributed with zero mean, but display both persistence across time and correlation in the current period.
Let us consider the joint process $(a_t,b_t)$ defined as
\begin{equation}
\left(
\begin{array}{c}
a_t\\b_t
\end{array}
\right)=
\left(
\begin{array}{cc}
\rho&\tau\\
\tau&\rho\\
\end{array}
\right)\left(
\begin{array}{c}
a_{t-1}\\b_{t-1}
\end{array}
\right)
+\left(
\begin{array}{c}
\varepsilon_t\\\nu_t
\end{array}
\right) \label{eq:process}
\end{equation}
where $|\rho+\tau|<1$ and $|\rho-\tau|<1$ for sake of stationarity and
\begin{eqnarray*}
E(\varepsilon_t)&=& 0,\\
E(\nu_t)&=& 0,\\
E(\varepsilon_t\varepsilon_s)&=&\left\{
\begin{array}{lcl}
\sigma^2_\varepsilon&\mbox{ if }& t=s \\
0 &\mbox{ if }& t\neq s \\
\end{array}\right. \mbox{, }\\
E(\nu_t\nu_s)&=&\left\{
\begin{array}{lcl}
\sigma^2_\nu&\mbox{ if }& t=s \\
0 &\mbox{ if }& t\neq s \\
\end{array}\right. \mbox{, }\\
E(\varepsilon_t\nu_s)&=&\left\{
\begin{array}{lcl}
\varphi\sigma_\varepsilon\sigma_\nu&\mbox{ if }& t=s \\
0 &\mbox{ if }& t\neq s \\
\end{array}\right. \mbox{. }
\end{eqnarray*}
\section{Dynamic Equilibrium}
The dynamic equilibrium of this economy follows from the first order conditions for optimality:
The {\sc dynare} code is straightforward to write, as the equilibrium is written in the natural way. The whole code is reported at the end of the section. Before that we proceed step by step.
\item{\tt var y, c, k, h, a, b;} specifies the endogenous variables in the model since we have output ({\tt y}), consumption ({\tt c}), capital ({\tt k}), hours ({\tt h}) and the two shocks ({\tt a, b}).
\item{\tt varexo e, u;} specifies the exogenous variables in the model --- namely the innovations of the shocks, since we have the innovation of the non--incorporated shock ({\tt e}), and the innovation of the incorporated shock ({\tt u}).
{\tt alpha}& capital elasticity in the production function \\
{\tt delta}& depreciation rate \\
{\tt theta}& disutility of labor parameter \\
{\tt psi}& labor supply elasticity \\
{\tt rho}& persistence \\
{\tt tau}& cross--persistence \\
\hline
\hline
\end{tabular}
\item Assignment of parameter values. This is done the standard way in MATLAB. For example, we write
\begin{verbatim}
alpha = 0.36;
rho = 0.95;
tau = 0.025;
beta = 0.99;
delta = 0.025;
psi = 0;
theta = 2.95;
\end{verbatim}
\item Note that $\varphi$, the conditional correlation of the shocks, is not, strickly speaking, a parameter of the recursive equations and doesn't need to be listed in the {\tt parameters} instruction. It may however be convenient to express it as a parameter in the expression of the variance--covariance matrix of the shocks (see below) and one may simply write:
{\tt phi = 0.1; }
\end{enumerate}
\paragraph{Declaration of the model:}
This step is done in a straightforward way. It starts with the instruction {\tt model;} and ends with {\tt end;}, in between all equilibrium conditions are written exactly the way we write it ``by hand''. However, there is a simple rule that should be kept in mind when the model is written. Let us consider a variable $x$:
\begin{itemize}
\item If $x$ is decided in period $t$ then we simply write ${\tt x}$.
\item When the variable is decided in $t-1$, such as the capital stock in our simple model, we write ${\tt x(-1)}$. \item Finally, when a variable is decided in the next period, $t+1$, such as consumption in the Euler equation, we write ${\tt x(+1)}$.
so that the level of consumption is actually given by ${\tt exp(c)}$.
\paragraph{Solving the model}
\begin{enumerate}
\item Now we need to provide numerical initial conditions for the computation of the deterministic steady state. This is done with the sequence between {\tt initval;} and {\tt end;}. Each variable, endogenous or exogenous, should be initialized. In our example, we give the exact values of the deterministic equilibrium in absence of shocks. This takes the form
\begin{verbatim}
initval;
y = 1.08068253095672;
c = 0.80359242014163;
h = 0.29175631001732;
k = 11.08360443260358;
a = 0;
b = 0;
e = 0;
u = 0;
end;
\end{verbatim}
Alternatively, we could provide only approximated values. {\sc Dynare} would then automatically compute the exact values.
\item We then specify the innovations and their matrix of variance--covariance. This is done using a {\tt shocks;} and {\tt end;} block and declare only the nonzero elements of the covariance matrix:
\item The model is then solved and simulated using the {\tt stoch\_simul;} command. By default, the coefficients of the approximated decision rules are reported as well as the moments of the variables and impulse response functions for each exogenous shocks are ploted. In addition, the following options are available (out of many others):
If different from zero, the model will be simulated and empirical moments will be computed instead of theoretical moments. The value of the option specifies the number of periods to use in the simulations (default = 0)
{\sc Dynare} will compute simulated moments of variables. The simulated trajectories are returned in MATLAB vectors named as the variables (be careful not to use MATLAB reserved names such as INV for your variables \ldots).
Here is the model file for the model in logs. In this case, {\tt initval} only contains guessed values and {\tt steady} is used to compute and display the exact value of the deterministic equilibrium. The shocks are supposed to be uncorrelated. The model file can be found in {\tt example2.mod}.