SIMULATE Instruction |
SIMULATE(options) equations
# equation forecasts newstart column (omit when using MODEL option)
SIMULATE solves a model, drawing shocks to the equations from a Normal distribution.
SIMULATE has an older syntax, which is still supported, that uses parameters rather than options for several pieces of information. See "Older Syntax" below.
Parameters
equations |
Number of equations in the system. Omit this parameter when using the MODEL option. |
Options
MODEL=model to simulate
Of the two ways to input the form of the model to be solved (the other is with supplementary cards), this is the more convenient and is the only way to forecast with a set of FRMLs. MODELs are usually created by GROUP or SYSTEM. If the model includes any identities, those should be last in the model. If you use this, omit the “equation” supplementary cards.
FROM=starting period of the forecast interval [end period of previous estimation + 1]
TO=ending period of the forecast interval
STEPS=number of forecast steps to compute
These determine the periods for which forecasts will be computed. If you have set a SMPL, these default to forecast over that range. If you haven't then you can use:
• FROM and TO to set the starting and ending periods for the forecasts, or
• FROM and STEPS to set the starting date and number of steps (periods)
RESULTS=VECTOR[SERIES] for result series
This provides a VECTOR of SERIES which will be filled with the results. For instance, RESULTS=SIMULS will make SIMULS(i) the series of simulations for the ith equation in the model.
CV=SYMMETRIC covariance matrix of residuals
FACTOR=RECTANGULAR decomposition matrix [unused]
You can use CV to supply a \(\Sigma\) matrix. If you're using the MODEL option and you either estimated the model with ESTIMATE or SUR, or you provided a covariance matrix when you set the model up with GROUP, you don't need to use this. If you need to compute a covariance from a general set of residuals, use VCV and pass %SIGMA from that through using the CV option.
As an alternative, you can use the FACTOR option (the older DECOMP is also acceptable as a synonym) to provide a factorization of the covariance matrix of residuals—see orthogonalization. Note that the distribution (though not the actual values) of the simulations doesn’t depend upon which factorization is chosen for \(\Sigma\).
ITERS=iteration limit for solution algorithm [50]
CVCRIT=convergence criterion [.00001]
DAMP=damping factor (1.0=no damping) [1.0]
When simulating a nonlinear model (created by the GROUP instruction and specified by the MODEL option), you can use these three options to control various aspects of the model-solving procedure.
PRINT/[NOPRINT]
TITLE="title for output" [none]
WINDOW="title of window" [not used]
Use PRINT if you want RATS to display the simulated data in the output window or file; this is not done automatically. If you use PRINT and the TITLE option, it will display the title over the table of forecasts.
Use the WINDOW option to have SIMULATE display the results in a (read-only) spreadsheet window with the title on the WINDOW option (the TITLE option is ignored). This will show the forecasts in columns below the name of the dependent variable. Note that you can use the File–Export... operation to export data directly from such a window.
Supplementary cards (omitted when using MODEL option)
equation |
the equation |
forecasts |
(Optional) The series for the forecasts of the dependent variable of equation. forecasts can be the same as the dependent variable. |
newstart |
(Optional) The starting entry for forecasts. By default, the same as FROM. |
column |
If you use the FACTOR option, this is the column in that matrix which corresponds to this equation. By default, RATS assumes that the order in which you list the equations matches the order of the columns in the FACTOR matrix. |
Variables Defined
%FSTART |
Starting entry of simulations (INTEGER) |
%FEND |
Ending entry of simulations (INTEGER) |
Description
SIMULATE forecasts a system of equations using a random number generator to add shocks to those equations which are not identities. Note that identities must be last in the list of supplementary cards, or at the end of the model.
The shocks at each period are generated by a draw from a \(Normal(0,\Sigma)\) distribution. You put the variance/covariance matrix \(\Sigma\) into SIMULATE in one of the following ways:
1.If you use MODEL, it will already be part of that if you estimated the model with ESTIMATE or SUR, or provided a covariance matrix with the CV option on GROUP.
2.You can supply it using the CV option. If you use the column fields on the supplementary cards, you will get a rearrangement of this.
3.You can supply a factorization of \(\Sigma\) using the FACTOR option.
4.In all other cases, \(\Sigma\) is taken to be a diagonal matrix with diagonal equal to the variances of the individual equations or formulas.
Comments
The standard way to use SIMULATE is to loop over the number of draws you want to make, compiling statistics on characteristics of the simulated series. See the section on Simulations and Bootstrapping for more.
The instruction SEED can be helpful in checking programs which use SIMULATE because it allows you to control the set of random numbers that RATS generates.
Note that SIMULATE isn’t needed to create a series of random numbers or simple transformations of them. A SET instruction using functions like %RAN and %UNIFORM is easier to set up.
If you need the shocks to have some distribution other than Normal, use FORECAST with the PATHS option, using SET instructions to create the series of shocks. (That is how bootstrapping is done).
To simulate an equation that includes moving average (MA) terms, the equation must have a series of residuals associated with it. This happens automatically for equations estimated using instructions like BOXJENK, but for equations defined using EQUATION, you must assign the residuals manually, using either ASSOCIATE or the %eqnsetresids() function. For example:
set armaresids = 0.0
equation(ar=lags,ma=1,noconstant,coeffs=coeffsvec,$
variance=1) yeq y
compute %eqnsetresids(yeq,armaresids)
Examples
This computes and copies to a file a 100 element realization of the AR(2) process
\({y_t} = 6.0 + 1.4{y_{t - 1}} - 0.8{y_{t - 2}} + {u_t};{\rm{Var}}\left( {{u_t}} \right) = 4.0\)
Since the simulation starts out “cold” with zeros for the lagged values, the program generates an additional 48 points at the beginning for burn-in. Simulations start at period 3 because of the two lags:
allocate 150
set y = 0.0
equation(variance=4.0,coeffs=||6.0,1.4,-.8||) simeq y 2 0
simulate(from=3,steps=148) 1
# simeq y
open copy simul.dat
copy 51 150 y
This next example does 100 simulations of a six-variable VAR over the period 2011:1 to 2016:4 and fills a pair of vectors with the minimum and maximum achieved by the exchange rate over that period. (The simulated values for the exchange rate are in SIMULS(2), since it is the second equation in the model.)
system(model=canmodel)
variables usargdps canusxsr cancd90d canm1s canrgdps cancpinf
lags 1 to nlags
det constant
end(system)
estimate(noprint)
declare vector minxrate(100) maxxrate(100)
do draw=1,100
simulate(model=canmodel,results=simuls, $
steps=24,start=2011:1)
ext(noprint) simuls(2)
compute minxrate(draw)=%minimum,maxxrate(draw)=%maximum
end do draw
SIMULATE(options) equations steps start VCVmatrix
# equation forecasts newstart column (omit when using MODEL option)
Deprecated Parameters
steps |
number of steps. Prefer the newer STEPS, FROM and TO options. By default, it's the end period of the last estimation instruction + 1. |
start |
start period of forecast. Prefer the newer FROM option. |
VCVmatrix |
covariance matrix. Prefer the newer CV option. |
Copyright © 2025 Thomas A. Doan