FORECAST Instruction |
FORECAST( options ) equations
# equation forecasts newstart (one per equation if MODEL isn’t used)
# first period shocks to non-identities (only with INPUT option)
# list of series with paths of shocks (only with PATHS option)
FORECAST is the workhorse forecasting instruction. It normally computes dynamic forecasts—that is, it feeds forward forecasts of the early periods for use in later periods—but it can also do static forecasting. For forecasting a single equation, you may find UFORECAST more convenient.
FORECAST assumes zero shocks across the forecast period. You can override this with one of the options INPUT, SHOCKS, MATRIX or PATHS. If you want to draw random (Normal) shocks, use SIMULATE.
You need to build your model before doing FORECAST. You can either supply a list of equations on supplementary cards, or use the MODEL option to forecast a model defined using the MODEL option on SYSTEM or by a GROUP instruction.
For linear systems of Equations, FORECAST solves directly. For non-linear systems created from Formulas using GROUP, it solves the system (if possible) using the Gauss-Seidel algorithm.
Wizard
The Time Series—VAR (Forecast/Analyze) Wizard can actually forecast any MODEL, and thus provides access to most of the functionality of FORECAST. For single equations, use the Time Series—Single-Equation Forecast Wizard.
Parameters
equations |
number of equations |
Two additional parameters (steps and start) used in versions before 7 have been replaced by the STEPS, FROM, and TO options described below. RATS will still recognize these older parameters.
Options
MODEL=general model to be forecast [unused]
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 you use this, omit the “equation” supplementary cards.
FROM=starting period of the forecast interval
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. Otherwise 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)
If you use STEPS, but not FROM, the default for FROM will be one entry past the end of the estimation range that was used last.
PRINT/[NOPRINT]
TITLE="title for output" [none]
WINDOW="title of window" [not used]
Use PRINT if you want RATS to display the forecasts 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 FORECAST 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.
RESULTS=VECTOR[SERIES] for result series
STDERRS=VECTOR[SERIES] for standard errors of forecast
These allow you to save the forecasts and standard errors of forecast into VECTORS of SERIES. For instance, RESULTS=FCASTS will make FCASTS(i) the series of forecasts for the ith equation in the model. See the ERRORS instruction for details on how the standard errors of forecast are computed.
SKIPSAVE=number of steps to skip when saving forecasts [0]
This option makes it easy to save forecasts only at the desired horizons when doing multi-step-ahead forecasts in a rolling regression loop. See “Using the SKIPSAVE Option”.
STATIC/[NOSTATIC]
ERRORS=VECTOR[SERIES] of one-step forecast errors
Use STATIC if you want static forecasts rather than dynamic forecasts—that is, if you want to use actual values rather than forecasted values for lagged dependent variable terms at later forecast horizons.
When doing static forecasts, you can use the ERRORS option to save the forecast errors into a VECTOR of SERIES.
ITERS=Maximum iterations for Gauss-Seidel [50]
CVCRIT=Convergence criterion for Gauss-Seidel [.00001]
DAMP=Damping factor for Gauss-Seidel [0.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.
INPUT/[NOINPUT]
SHOCKS=VECTOR for first period shocks to add in [unused]
PATHS/[NOPATHS]
MATRIX=RECTANGULAR matrix of time paths of shocks [unused]
These options (which are mutually exclusive) add shocks to the equations. INPUT and SHOCKS options do this only at the first period, MATRIX and PATHS over the whole forecast horizon. You can use them either with linear or general models. They have a number of uses, from add factoring to bootstrapping. See “Options for Adding Shocks”
Equation Supplementary Cards (if not using MODEL)
There is one supplementary card for each equation, unless you use the MODEL option. The other two types of supplementary cards shown above are only used with special options for adding shocks: INPUT and PATHS.
equation |
the equation name or number |
forecasts |
(Optional) The series for the computed forecasts of the dependent variable of equation. If you find it is convenient, forecasts may be the same as the dependent variable. |
newstart |
(Optional) The forecasts will be saved starting in entry newstart of the forecasts series. By default, this will be the same as the starting period of the forecast range. |
Variables Defined
%FSTART |
Starting entry of forecasts (INTEGER) |
%FEND |
Ending entry of forecasts (INTEGER) |
Description
FORECAST solves the model for each time period requested. If there are any lagged dependent variables, FORECAST will use the actual data if the lag reaches back before the first forecast period, and will use the forecasted values if not (unless you use the STATIC option).
For instance, in forecasting the range T+1 to T+n, a one period lag will come from the actual data at period T when forecasting T+1, but will come from the period T+1 forecast when forecasting T+2. Note, however, that this only applies for variables which are dependent variables of one of the equations of the system. Any exogenous variables have to be treated as described below.
If you have an equation with a moving average part (for instance, one estimated with BOXJENK with MA or SMA terms), the lagged residuals come from the series of residuals saved when estimating the equation.
If you have a MODEL which includes FRML’s, FORECAST uses the Gauss–Seidel solution method.
If you get forecasts which show as NA (missing values), the usual cause is that an exogenous variable is not defined into your forecasting period. Other possibilities are the absence of a lagged dependent variable. For instance, you try to forecast beginning at 2019:1, but one of your series has no data for 2018:4 and you need a lag of it.
Exogenous Variables
Exogenous variables require some care, as you need values for them throughout the forecast period. If a variable is not the dependent variable of one of the equations, FORECAST takes its values over the forecast horizon from its data series. If you are forecasting out-of-sample, you have two basic ways to handle exogenous variables:
•Close the model by adding to it equations or formulas, such as univariate autoregressions, that forecast the exogenous variables.
•Set up time paths for the variables (prior to forecasting) with SET or DATA or some other instruction that will directly provide the values.
Using All Available Data
FORECAST in its simplest form sometimes cannot take advantage of all available information in applied forecasting situations. Data for different series may become available at slightly different times. As it is described above, FORECAST cannot make forecasts when only part of the data are available for a time period. See "Conditional Forecasting" for information on methods of incorporating all known data into the forecasts.
Examples
system(model=canmodel)
variables canrgdps canm1s cancd90d cancpinf canusxsr usargdps
lags 1 to 4
det constant
specify(tightness=.15,type=symmetric) 0.50
end(system)
estimate
forecast(model=canmodel,results=forecasts,from=2006:3,steps=10)
forecasts 2006:3 to 2008:4 using a six-variable VAR. The forecasts are in series FORECASTS(1) (for CANRGDPS) to FORECASTS(6) (for USARGDPS).
Below, equation UNEMPEQ is a forecasting equation for the series UNEMP. The FORECAST instruction computes and prints forecasts for 24 months beginning with 2018:7. The GRAPH graphs both the forecasts and the last year of actual data.
forecast(print,from=2018:7,to=2020:6) 1
# unempeq foreun
graph 2
# unemp %fstart %fend
# foreun
Next, equation M1EQ has the log of M1 (LOGM1) as its dependent variable, RATEEQ is an equation for an interest rate, and PRICEQ is for LOGPRICE. This computes forecasts over 2018:2 to 2022:4 (fifteen quarters) and appends them to the original data series. The SET instructions take the anti-logs of LOGM1 and LOGPRICE, and the PRINT instruction prints the forecasts along with the last five quarters of data. This uses the variables %FSTART and %FEND defined by FORECAST to simplify the steps after doing the forecasts.
forecast(from=2018:2,steps=15) 3
# m1eq logm1
# rateeq rate
# priceq logprice
set m1 %fstart %fend = exp(logm1)
set price %fstart %fend = exp(logprice)
print %fstart-5 %fend m1 rate price
You can do the same operation using a GROUPed system by incorporating definitional identities for the log relationships:
frml(identity) m1iden m1 = exp(logm1)
frml(identity) priceiden price = exp(logprice)
group smallmod m1eq rateeq>>rate priceeq $
m1iden>>m1 priceiden>>price
forecast(model=smallmod,from=2014:2,to=2018:4,print)
MATRIX=RECTANGULAR array of shock paths
PATHS/[NOPATHS]
You can use MATRIX or PATHS to input paths of shocks over more than one period. With MATRIX, the columns of the RECTANGULAR array provide the paths for the equations. These correspond to equations in the order in which the model was formed. The number of rows does not have to be equal to steps. Shocks will be zero for steps beyond those supplied by the array.
With PATHS, a supplementary card lists the series which provide the paths of the shocks. These series must be defined for steps entries beginning with the entry given by the start parameter. Put a * on the supplementary card for an equation whose shocks you want to be zero.
INPUT/[NOINPUT]
SHOCKS=VECTOR for first period shocks
You can use either of these options to input general first period shocks. With INPUT, a supplementary card provides the values; with SHOCKS, the indicated VECTOR provides the shocks.
Examples with Added Shocks
group macro conseq>>f_cons investeq>>f_invest $
rateeq>>f_rate gnpid>>f_gnp
set m = m{1}*1.015
forecast(input,model=macro,from=2018:3,to=2021:2)
# 0.0 0.0 0.5
forecasts a small macro model, assuming 6% (compound) growth in the (exogenous) money stock and “add factoring” the interest rate equation by .5.
boot select / 1960:1 2018:4
set path1 = resids1(select)
set path2 = resids2(select)
forecast(paths,from=1960:1,to=2018:4) 2
# x1eq x1simul
# x2eq x2simul
# path1 path2
The code above generates X1SIMUL and X2SIMUL as bootstrapped realizations of a model. BOOT combined with the two SET instructions creates a path of residuals selected randomly from the estimation period.
When doing multi-step-ahead forecasts in a rolling regression application, you often are interested only in the last forecast step computed on each trip through the loop. For example, suppose you are doing a rolling regression with quarterly data and are only interested in the forecasts for one year beyond the end of the estimation sample. You can’t just do:
do end=2009:1,2018:1
linreg(define=yequation) y 1980:1 end
# constant y{1} x1 x2
forecast(from=end+1,steps=4) 1
# yeq yfore
end
because each new set of four forecasts will overwrite the second, third, and fourth forecasts from the previous trip through the loop. You could add instructions to copy the fourth-quarter forecasts into a separate series, but the easiest solution is to use the SKIPSAVE option:
do end=2009:1,2018:1
linreg(define=yequation) y 1980:1 end
# constant y{1} x1 x2
forecast(skip=3,from=end+1,steps=4) 1
# yeq yfore
end
RATS still computes (and stores internally) all four forecast steps, but only the fourth step is saved into the YFORE series. When the loop is complete, YFORE will contain the one-year-ahead forecasts from each regression.
Copyright © 2025 Thomas A. Doan