S = simulate(M,D,Range,...)
[S,Flag,AddF,Discrep] = simulate(M,D,Range,...)
M
[ model ] - Solved model object.
D
[ struct | cell ] - Input database or datapack from which the initial conditions and shocks from within the simulation range will be read.
Range
[ numeric ] - Simulation range.
S
[ struct | cell ] - Database with simulation results.Flag
[ cell | empty ] - Cell array with exit flags for non-linearised simulations.
AddF
[ cell | empty ] - Cell array of tseries with final add-factors added to first-order approximate equations to make non-linear equations hold.
Discrep
[ cell | empty ] - Cell array of tseries with final discrepancies between LHS and RHS in equations earmarked for non-linear simulations by a double-equal sign.
'anticipate='
[ true
| false
] - If true
, real future shocks are anticipated, imaginary are unanticipated; vice versa if false
.
'contributions='
[ true
| false
] - Decompose the simulated paths into contributions of individual shocks.
'deviation='
[ true
| false
] - Treat input and output data as deviations from balanced-growth path.
'dbOverlay='
[ true
| false
| struct ] - Use the function dboverlay
to combine the simulated output data with the input database, or with another database, at the end.
'dTrends='
[ 'auto' | true
| false
] - Add deterministic trends to measurement variables.
'ignoreShocks='
[ true
| false
] - Read only initial conditions from input data, and ignore any shocks within the simulation range.
'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.
'progress='
[ true
| false
] - Display progress bar in the command window.
'addSstate='
[ true
| false
] - Add steady state levels to simulated paths before evaluating non-linear equations; this option is used only if 'deviation=' true
.
'display='
[ true
| false
| numeric | Inf ] - Report iterations on the screen; if 'display=' N
, report every N
iterations; if 'display=' Inf
, report only final iteration.
'error='
[ true
| false
] - Throw an error whenever a non-linear simulation fails converge; if false
, only an warning will display.
'lambda='
[ numeric | 1
] - Step size (between 0
and 1
) for add factors added to non-linearised equations in every iteration.
'reduceLambda='
[ numeric | 0.5
] - Factor (between 0
and 1
) by which lambda
will be multiplied if the non-linear simulation gets on an divergence path.
'maxIter='
[ numeric | 100
] - Maximum number of iterations.
'tolerance='
[ numeric | 1e-5
] - Convergence tolerance.
Time series in the output database, S
, are are defined on the simulation range, RANGE
, plus include all necessary initial conditions, i.e. lags of variables that occur in the model code. You can use the option 'dboverlay='
to combine the output database with the input database (i.e. to include a longer history of data in the simulated series).
If you simulate a model with N
parameterisations and the input database contains K
data sets (i.e. each variable is a time series with K
columns), then the following happens:
The model will be simulated a total of P = max(N,K)
number of times. This means that each variables in the output database will have P
columns.
The 1st parameterisation will be simulated using the 1st data set, the 2nd parameterisation will be simulated using the 2nd data set, etc. until you reach either the last parameterisation or the last data set, i.e. min(N,K)
. From that point on, the last parameterisation or the last data set will be simply repeated (re-used) in the remaining simulations.
Put formally, the I
-th column in the output database, where I = 1, ..., P
, is a simulation of the min(I,N)
-th model parameterisation using the min(I,K)
-th input data set number.