

    \filetitle{simulate}{Simulate model}{model/simulate}

	\paragraph{Syntax}
 
 \begin{verbatim}
 S = simulate(M,D,RANGE,...)
 [S,FLAG,ADDF,DISCREP] = simulate(M,D,RANGE,...)
 \end{verbatim}
 \paragraph{Input arguments}
 
 \begin{itemize}
 \item
   \texttt{M} {[} model {]} - Solved model object.
 \item
   \texttt{D} {[} struct \textbar{} cell {]} - Input database or datapack
   from which the initial conditions and shocks from within the
   simulation range will be read.
 \item
   \texttt{RANGE} {[} numeric {]} - Simulation range.
 \end{itemize}
 \paragraph{Output arguments}
 
 \begin{itemize}
 \item
   \texttt{S} {[} struct \textbar{} cell {]} - Database with simulation
   results.
 \end{itemize}
 \paragraph{Output arguments in simulations with a non-linear plan}
 
 \begin{itemize}
 \item
   \texttt{FLAG} {[} cell {]} - Cell array with exit flags for
   non-linearised simulations.
 \item
   \texttt{ADDF} {[} cell {]} - Cell array of tseries with final
   add-factors added to first-order approximate equations to make
   non-linear equations hold.
 \item
   \texttt{DISCREP} {[} cell {]} - Cell array of tseries with final
   discrepancies between LHS and RHS in equations earmarked for
   non-linear simulations by a double-equal sign.
 \end{itemize}
 \paragraph{Options}
 
 \begin{itemize}
 \item
   \texttt{'anticipate='} {[} \emph{\texttt{true}} \textbar{}
   \texttt{false} {]} - If \texttt{true}, real future shocks are
   anticipated, imaginary are unanticipated; vice versa if
   \texttt{false}.
 \item
   \texttt{'contributions='} {[} \texttt{true} \textbar{}
   \emph{\texttt{false}} {]} - Decompose the simulated paths into
   contributions of individual shocks.
 \item
   \texttt{'deviation='} {[} \texttt{true} \textbar{}
   \emph{\texttt{false}} {]} - Treat input and output data as deviations
   from balanced-growth path.
 \item
   \texttt{'dbExtend='} {[} \texttt{true} \textbar{}
   \emph{\texttt{false}} \textbar{} struct {]} - Use the function
   \texttt{dbextend} to combine the simulated output data with the input
   database, or with another database, at the end.
 \item
   \texttt{'dTrends='} {[} \emph{`auto'} \textbar{} \texttt{true}
   \textbar{} \texttt{false} {]} - Add deterministic trends to
   measurement variables.
 \item
   \texttt{'ignoreShocks='} {[} \texttt{true} \textbar{}
   \emph{\texttt{false}} {]} - Read only initial conditions from input
   data, and ignore any shocks within the simulation range.
 \item
   \texttt{'plan='} {[} plan {]} - Specify a simulation plan to swap
   endogeneity and exogeneity of some variables and shocks temporarily,
   and/or to simulate some of the non-linear equations accurately.
 \item
   \texttt{'progress='} {[} \texttt{true} \textbar{}
   \emph{\texttt{false}} {]} - Display progress bar in the command
   window.
 \end{itemize}
 \paragraph{Options for models with non-linearised equations}
 
 \begin{itemize}
 \item
   \texttt{'addSstate='} {[} \emph{\texttt{true}} \textbar{}
   \texttt{false} {]} - Add steady state levels to simulated paths before
   evaluating non-linear equations; this option is used only if
   \texttt{'deviation=' true}.
 \item
   \texttt{'display='} {[} \emph{\texttt{true}} \textbar{} \texttt{false}
   \textbar{} numeric {]} - Display one-line report on each iteration; if
   \texttt{'display='} is a number \texttt{n}, display a report after
   every \texttt{n} iterations and a final report.
 \item
   \texttt{'error='} {[} \texttt{true} \textbar{} \emph{\texttt{false}}
   {]} - Throw an error whenever a non-linear simulation fails converge;
   if \texttt{false}, only an warning will display.
 \item
   \texttt{'lambda='} {[} numeric \textbar{} \emph{\texttt{1}} {]} - Step
   size (between \texttt{0} and \texttt{1}) for add factors added to
   non-linearised equations in every iteration.
 \item
   \texttt{'reduceLambda='} {[} numeric \textbar{} \emph{\texttt{0.5}}
   {]} - Factor (between \texttt{0} and \texttt{1}) by which
   \texttt{lambda} will be multiplied if the non-linear simulation gets
   on an divergence path.
 \item
   \texttt{'maxIter='} {[} numeric \textbar{} \emph{\texttt{100}} {]} -
   Maximum number of iterations.
 \item
   \texttt{'tolerance='} {[} numeric \textbar{} \emph{\texttt{1e-5}} {]}
   - Convergence tolerance.
 \end{itemize}
 \paragraph{Description}
 
 The time series in the output database, \texttt{S}, are are defined on
 the simulation range, \texttt{RANGE}, plus include any necessary initial
 conditions (for those variables that occur with lags in the model).
 
 \paragraph{Example}


