Statistics and Algorithms / Forecasting (Introduction) / Producing Forecasts |
Static Forecasting with PRJ
The instruction PRJ can be used to compute fitted values or forecasts for a linear model after you estimate the model with LINREG, STWISE, BOXJENK or AR1. They are calculated using the most recently estimated regression. PRJ does static forecasts only, and so can only be used out-of-sample (for more than one period) if your model itself is static. An example of such a use of PRJ was provided earlier.
Using UFORECAST and FORECAST
For more general forecasting of linear and non-linear models, use UFORECAST or, for multi-equation models or additional flexibility, FORECAST. As noted earlier, these produce dynamic forecasts by default—use the STATIC option to get static forecasts. Remember, for models that do not have a dynamic structure (that is, they have no lagged dependent variables), either method will produce the same results. The next paragraphs discuss the use of the instructions in various situations.
Single-Equation Linear Models
If you are estimating your model with LINREG, use the DEFINE option to save the estimated equation, which can then be forecast. This, and many of the other samples are from BASICFORECAST.RPF, which uses a data set with monthly data through 1994:12. The final year of this is “held back” for evaluation, so the estimates run only through 1993:12. For actual forecasting, you would use the full data set in the estimates.
cal(m) 1954:1
open data rsales.dat
data(format=prn,org=columns) 1954:1 1994:12
*
set logrsales = log(rsales)
set time = t
*
linreg(define=saleseq) logrsales * 1993:12
# constant time
You can use the Time Series—Single-Equation Forecasts wizard to generate the forecasting instruction, or you can type the command directly. For example:
uforecast(equation=saleseq) logfore 1994:1 1994:12
or
forecast(steps=12) 1
# saleseq logfore
The parameters for the UFORECAST are the series for the forecasts (LOGFORE), and the range. The option EQUATION=SALESEQ gives the equation to use.
The basic syntax of FORECAST is shared by several other instructions (IMPULSE, ERRORS, SIMULATE and HISTORY). The STEPS option indicates that we want to forecast for 12 steps. We could also use the options FROM=1994:1,TO=1994:12 to set the forecast range. The supplementary card supplies the equation to forecast (SALESEQ), and the series into which the forecasts are saved (LOGFORE).
You can also use the SMPL instruction to specify the forecast range. Note that this changes the default range for any subsequent instructions, so be careful using it.
smpl 1994:1 1994:12
forecast 1
# ordereq logfore
AR1 Models
The DEFINE option on the AR1 instruction produces a linearized equation from the original non–linear model:
open data housing.dat
calendar(m) 1983:1
data(format=free,org=col) 1983:1 1989:10 housing construct rates
*
ar1(define=firsteq) housing * 1988:10
# constant construct{0 to 6} rates{0 to 9}
*
uforecast(equation=firsteq) firstfore 1988:11 1989:10
This reads in data for HOUSING, CONSTRUCT and RATES, fits an AR1 model, and forecasts the model for 12 steps starting in 1988:11.
Multiple Equation Systems
FORECAST can also be used to produce forecasts for systems of equations. The equations are usually defined using either EQUATION instructions or the SYSTEM instruction and then estimated using ESTIMATE or SUR. However, your system might consist of equations estimated using several LINREG instructions, or it might include identity equations or other equations whose coefficients you have set yourself using EQUATION or ASSOCIATE.
The forecasting instructions don’t “care” how the equations in the model were defined or estimated. As long as the necessary data are available and the equation coefficients have been estimated or set, you can produce forecasts.
To forecast a system of equations, you can use the Time Series—VAR (Forecast/Analyze) wizard to generate the appropriate instruction, or type in the FORECAST instruction directly. If using FORECAST directly, you can either:
•group the equations into a MODEL and use the MODEL=name option to forecast the model, or
•list each of the equations in the system on a separate supplementary card
If you create the equations using a SYSTEM instruction, you can use the MODEL option on SYSTEM to automatically group those equations into a MODEL. Otherwise, use the GROUP instruction to construct the MODEL from a list of existing equations
group ourmodel houseeq>>fhousing conseq>>fconstruct rateeq>>frates
forecast(model=ourmodel,from=1989:11,to=1990:12)
or
forecast(from=1989:11,to=1990:12) 3
# houseeq fhousing
# conseq fconstruct
# rateeq frates
Note that a MODEL can include non–linear formulas as well as equations.
Non-Linear Models
Non-linear models are constructed using formulas (FRMLs). These are typically defined using the instruction FRML, although they can also be created using LINREG or EQUATION. You can estimate them using NLLS, NLSYSTEM, or MAXIMIZE.
To generate forecasts for a non-linear model, you must group them into a model and use the MODEL option on FORECAST—you cannot list FRMLs on supplementary cards. This is true even when forecasting a single formula.
In some cases, you may need or want to include identities in your forecasting model. You might have accounting identities in a simultaneous equations model, or, if you are forecasting a model estimated in logs, you might want to include an identity FRML to generate levels from the logs.
Identity equations can be created using EQUATION instructions, while identity formulas are created using FRML. Identities should be listed after all estimated equations on the supplementary cards, or on the list in a GROUP instruction.
These two instructions define the same identity, one (RSUMID) as a FRML and one (RSUMEQ) as an EQUATION.
frml(identity) rsumid rsum = rate+rate{1}
equation(identity,coeffs=||1.0,1.0||) rsumeq rsum
# rate{0 1}
Copyright © 2025 Thomas A. Doan