RATS 11.1
RATS 11.1

We have not emphasized simultaneous equations in designing RATS over the years, leaving the field of the “big model” to specialized software. However, RATS can easily handle models of a more modest size, providing estimation and forecasting techniques.

Preliminary Transformations

Most simultaneous equations models require a sizable set of preliminary transformations of the variables: differences, averages, logs, percentage changes, etc. When these involve lags, some data points are lost. Fortunately, you do not need to keep track of this information—RATS handles it by marking as missing any entry which it cannot compute. For instance, in this example, the three constructed variables are actually defined over different periods.

 

set addshort = rs+rs{1}+rs{2}+rs{3}

set diffyd   = yd-yd{1}

set diffrate = rl-rs

 

We would strongly urge you to read the data as you receive it from the original source and to do any needed transformations as part of your program rather than saving the transformed data into a new file. The latter procedure would require someone recording what transformations were done, while the SET instructions are, in effect, self-documenting.

 

Instrument Lists

The estimation instructions (LINREG, AR1, SUR, NLLS and NLSYSTEM) take their instruments from the list maintained by the instruction INSTRUMENTS. With a small model, you can just set the list once and estimate the model. With a larger model, the available instrument list may be too large to be used in its entirety, as it will exhaust your degrees of freedom. Thus, during estimation, you may need to change it from one equation to the next. A combination of INSTRUMENT instructions with the DROP and ADD options will let you make small changes:

 

instrument(drop)  rw rw{1}    Drops RW and RW{1} from the list

instrument(add)   xz zw       Adds XZ and ZW to the list

 

Example Model

We use a small macroeconomic model to demonstrate estimation and use of simultaneous equations. The base model is taken from Pindyck and Rubinfeld (1998), p. 390. Their model is

 

\(\begin{array}{l} {C_t} = {\alpha _C} + {\beta _C}{\kern 1pt} {Y_t} + {\gamma _C}{C_{t - 1}} + {u_{{\kern 1pt} Ct}}{\kern 1pt}  \\ {I_t} = {\alpha _I} + {\beta _I}\left( {{Y_{t - 1}} - {Y_{t - 2}}} \right) + {\gamma _I}{Y_t} + {\delta _I}{R_{t - 4}} + {u_{It}}{\kern 1pt}  \\ {R_t} = {\alpha _R} + {\beta _R}{Y_t} + {\gamma _R}\left( {{Y_t} - {Y_{t - 1}}} \right) + {\delta _R}\left( {{M_t} - {M_{t - 1}}} \right) + {\varepsilon _R}\left( {{R_{t - 1}} + {R_{t - 2}}} \right) + {u_{Rt}} \\ {Y_t} \equiv {C_t} + {I_t} + {G_t} \\ \end{array}\)

 

The data set consists of the following variables, quarterly from 1947:1 to 1988:1. However, the estimates are done using a common estimation range of 1950:1 through 1985:4. If RATS were left to determine the range, estimation would start in 1948:1 as the start of the range is determined by lag 4 on RATE in the instrument set.

 

CONS (C)

= real personal consumption

INVEST (I)

= real gross domestic investment

GNP (Y)

= real GNP net of exports and imports

GOVT (G)

= real government purchases of goods and services

MONEY (M)

= M1

RATE (R)

= 90 day Treasury bill rate

 

The variables \(Y_t-Y_{t-1}\) (YDIFF), \(R_t+R_{t-1}\) (RSUM)  and \(M_t-M_{t-1}\) (MDIFF) and are created from these:

 

set ydiff = gnp-gnp{1}

set rsum  = rate+rate{1}

set mdiff = m-m{1}

 

Though we will start with the original set of equations, we will end up using a slightly different form for the investment equation, adding an \(I_{t-1}\) term to the second equation above. This is done because an estimate of the autocorrelation coefficient on the residuals in the original equation comes in very close to one.

 

The instrument set for all equations will be the full list of exogenous (GOVT and MDIFF) and pre-determined variables (lags and functions of lags of the four endogenous variables) that appear in the model. Note that you need to include the CONSTANT.

 

instruments constant cons{1} ydiff{1} gnp{1} govt $

   mdiff rsum{1} rate{4}

Estimation

There are four main estimation techniques for simultaneous equations: Two-Stage Least Squares (2SLS), Three-Stage Least Squares (3SLS), Limited Information Maximum Likelihood (LIML) and Full-Information Maximum Likelihood (FIML). 2SLS and LIML are "limited information" estimators, doing a single equation at a time, while 3SLS and FIML estimate the full system—as such, they are limited to use in relatively small models. By far, the most common method is 2SLS. These are demonstrated in SIMULEST.RPF, which estimates the model above using each of the four techniques.

 

 

Setting Up a Model for Forecasting

The MODEL Data Type

A MODEL is a special data type in RATS which describes a collection of equations or formulas. For a simultaneous equations model, this is usually created with the instruction GROUP. The MODEL data type is also used in VAR analysis—in that case, the SYSTEM instruction is the standard creator.

 

There is no hard limit on the number of equations in a model. However, if you have a 100+ equation model, you may be better off with a more specialized program.

 

There are a number of functions and operations you can apply to the MODEL data type. For instance, the “+” operator applies to models to combine two smaller models into a larger one. The function %MODELSIZE(model) returns the number of equations. %MODELDEPVARS(model) returns a VECTOR of INTEGERS which lists the dependent variables of the equations. %MODELLABEL(model,i) returns the label for the dependent variable of equation i.

 

There are quite a few other functions for manipulating the MODEL data type, but most of those apply mainly to vector autoregressions or similar types of multivariate time series models.

 

Creating Formulas

A model which is linear in its endogenous variables can be forecast using methods similar to those for VAR’s and ARIMA models. However, our emphasis will be on more general models which could have non-linear aspects, such as mixed logs and levels, or even explicitly non-linear equations. Your model can include linear equations defined using the DEFINE option of an instruction like LINREG or BOXJENK, but any non-linearities have to be handled using FRMLs. A FRML is a description of a (possibly) non-linear relationship.

 

There are five ways to create the FRMLs for use in simultaneous equations:

LINREG(FRML=formula to define) or AR1(FRML=formula to define) defines a formula from the estimated equation.

FRML defines formulas with free parameters (specified by NONLIN) to be estimated by NLLS or NLSYSTEM. Or, with fixed parameters, it allows you to input directly a structural equation, if, for instance, you estimated it outside of RATS.

FRML(EQUATION=equation to convert) or FRML(LASTREG) converts an already estimated (linear) equation to a formula.

FRML(IDENTITY) creates an identity.

EQUATION(FRML=formula to define) associates the named formula with the equation being defined. If the equation is estimated (for instance with SUR or LINREG(EQUATION=equation)) the formula is automatically redefined. This association is broken if you ever change the equation in such a way that something changes besides its coefficients.

 

The GROUP Instruction

You put a model together using the instruction GROUP. This creates a model from a set of FRML’s and EQUATION’s. Each endogenous variable must be on the left side of one and only one of these. See the discussion below for tips on bringing your model into compliance. If you are doing any type of simulation which adds shocks to the equations, it will also be necessary to list identities last.

 

The GROUP instruction also allows you to specify the series which are to receive the forecasted values. This is done by appending >>series to a formula on the list. If you are planning to do simulations with Normally distributed shocks, you will also provide the covariance matrix for those shocks on GROUP using the CV option.

 

The models created with GROUP can be “added” using the notation model1+model2, which appends model2 to model1. This allows you to define separate “sector” models and combine them for forecasting.

 

For the simple forecasting examples later, we have created a “source” file called PRSETUP.SRC which estimates the (revised) Pindyck and Rubinfeld model using 2SLS, and performs all other operations which must be done before doing forecasts. The LINREG instructions on that include the FRML option to save the estimated equation in a form usable for forecasting, as described in the next section.

 

instruments constant cons{1} ydiff{1} gnp{1} invest{1} $

  govt mdiff rate rate{4}

linreg(inst,frml=conseq) cons 1950:1 1985:4

# constant gnp cons{1}

linreg(inst,frml=investeq) invest 1950:1 1985:4

# constant invest{1} ydiff{1} gnp rate{4}

linreg(inst,frml=rateeq) rate 1950:1 1985:4

# constant gnp ydiff mdiff rsum{1}

 

We also need to define the accounting and definitional identities needed to close the model:

 

frml(identity) gnpid gnp = cons+invest+govt

frml(identity) rsumid rsum = rate+rate{1}

frml(identity) ydiffid ydiff = gnp-gnp{1}

 

group prsmall conseq>>f_cons  investeq>>f_invest rateeq>>f_rate  gnpid>>f_gnp  rsumid ydiffid

 

Swapping Endogenous Variables

Because RATS uses a Gauss–Seidel algorithm to solve models, each endogenous variable must be on the left side of one and only one of the equations. If you estimate an equation with an exogenous variable on the left (such as a money demand equation), or a pair of equations with the same variable on the left, you must rearrange an equation to make it compatible with GROUP. If the equation is linear and is estimated by LINREG, AR1 or SUR, you can accomplish this by using MODIFY and VREPLACE with SWAP:

 

linreg(inst,define=mtemp)  money

# constant gnp rate

modify mtemp

vreplace money by rate swap

 

This rewrites the equation with RATE, rather than MONEY, as the dependent variable. You can see the results by using the PRINT option on VREPLACE.

 

Definitional Identities

If you have a model with mixed logs and levels, or other transformations of endogenous variables, you need to add to your model identities which define them. Usually, these will just mimic the SET instructions used to make the transformations:

 

set rsum  = rate+rate{1}

frml(identity) rsumid rsum = rate+rate{1}

 

If you don’t do this, the forecasting procedure will treat RSUM and RATE as unrelated variables.

 

Gauss–Seidel Algorithm

RATS solves models using the Gauss–Seidel algorithm. This is a simple, and usually effective, algorithm which requires no complex calculations.

 

Out-of-Sample Forecasts

To compute forecasts out-of-sample, you need to make some assumptions about the future of the exogenous variables. There are two ways to handle these:

Add to the model simple equations, such as autoregressions, to forecast them.

Set paths for them over the forecast period, using SET for systematic paths and DATA otherwise.

 

You can, of course, combine these two, treating different variables differently. The short example SIMULFORE.RPF uses the first method, while the add factor example SIMULADD.RPF uses the second. SIMULFORE.RPF has the slight complication that MDIFF, not MONEY itself, is needed in the interest rate equation, thus requiring an additional identity to define this to the model. PRSETUP.SRC is described above.

 

source prsetup.src

linreg(define=moneyeq) m

# constant m{1 2}

linreg(define=govteq) govt

# constant govt{1 2}

frml(identity) mdiffid mdiff = m-m{1}

group exogs moneyeq govteq mdiffid

forecast(model=exogs+prsmall,print,from=1986:1,to=1990:4)

 

Multipliers

You compute multipliers by running the model with and without a set of changes to the paths of the exogenous variables. Unless the model is linear (this one is), the computed multipliers apply only to the particular context—they will change when you solve the model at a different period, or with different assumptions on the other exogenous variables.

 

You must compute the two sets of forecasts and subtract them to get the multipliers, which can involve some rather complicated bookkeeping. The easiest way to do this is with the RESULTS option on FORECAST which creates a VECTOR of SERIES for the results. The DO loop in this example loops over the number of equations in the model and creates labels of “M_dependent variable” for the multipliers.

 

This is example SIMULMULT.RPF.

 

source prsetup.src

smpl 1984:1 1985:4

forecast(model=prsmall,results=base)

compute govt(1984:1)=govt(1984:1)+1.0      increase govt

forecast(model=prsmall,results=mults)

compute govt(1984:1)=govt(1984:1)-1.0      reset govt

 

do i=1,%rows(mults)

   set mults(i) = (mults(i)-base(i))/2.0

   labels mults(i)

   # # "M_"+%modellabel(prsmall,i)

end do i

 

print(picture="*.###") / mults

 

Historical Simulations

You can use the instruction THEIL to compute statistics on the accuracy of the model using the historical data. Because this solves the model for each time period you loop over, it can take a long time with a big model.

 

This looks at forecasts for 1 to 4 steps ahead over the period from 1982:1 to 1985:4. The TO=1985:4 on THEIL(SETUP,...) indicates the end of the historical data.

 

This is example SIMULTHEIL.RPF.

 

source prsetup.src

theil(setup,model=prsmall,steps=4,to=1985:4)

do time=1982:1,1985:4

   theil time

end do time

theil(dump,window="Forecast Performance")

 

Add Factors

Add factors adjust the solution of the model by altering one or more intercepts, or, equivalently, adding a non-zero error term to one or more equations. You can implement add factoring in RATS using either the SHOCKS or INPUT options of FORECAST. INPUT (which uses a supplementary cards) is more convenient for small models and SHOCKS (which uses a VECTOR) is better for larger ones. If you need to add factor more than one period, use the PATHS option.

 

This example (SIMULADD.RPF) does three forecasts, bumping the first period interest rate by 0.5 and 1.0 points for the second and third. (Adding x to the interest rate (3rd) equation adds x to RATE, since \(R_t\) appears only in that equation. Generally, the effect of a change will not be quite as predictable).

 

source prsetup.src

smpl 1986:1 1988:4

set m     1986:1 1988:4 = m{1}*1.01

set govt  1986:1 1988:4 = govt{1}*1.008

set mdiff 1986:1 1988:4 = m-m{1}

declare real fudge

dofor fudge = 0.0 0.5 1.0

   forecast(model=prsmall,input,print)

   # 0.0 0.0 fudge

end dofor

 

A similar setup using SHOCKS would use (following the SET MDIFF)

 

declare vector shocks(3)

compute shocks=%const(0.0)

declare real fudge

dofor fudge = 0.0 0.5 1.0

  compute shocks(3)=fudge

  forecast(model=prsmall,shocks=shocks,print)

end dofor


Copyright © 2026 Thomas A. Doan