Download RATS Programming Manual, By Walter Enders
Transcript
Vector and Matrix Manipulations 197
5. Creating Matrices from Your Data
If you are going to use matrix manipulations on your data set, it is important to realize that
RATS does not treat a series in the same way as a vector. For example, a vector is a onedimensional array such that the elements have subscripts that run from 1 to N. In order to
manipulate the vector, each element needs to be defined. Unlike a vector, you can manipulate a
series even if it has ranges that are undefined or NA. The key point is that RATS treats the two
differently: to perform any matrix manipulations on your data set, you need to create vectors
from your series. You can also create a RECTANGULAR matrix of series such that you can
refer to each element by its row and column. In a RECTANGULAR matrix, columns represent
variables and rows represent observations. Thus, element i,j is the element in the i-th row of the
j-th column. Similarly, element i,j is the i-th observation of variable j.
You can create matrices from series using the MAKE instruction. The syntax is:
MAKE array start end numobs numvars
# list of variables
numobs:
numvars:
INTEGER used by RATS to return the number of observations (i.e., the
number of rows)
INTEGER used by RATS to return the number of variables (i.e., the
number of columns)
Options:
EQUATION=
equation supplying variables
LASTREG:
use regressors from last regression.
NOTE: Omit the supplementary card with either of the above.
TRANS:
set up the transpose of the observation array
Examples
For all of the examples below, read in the data set MONEY_DEM.XLS and create dlrgdp using
PROGRAM 5 of CHAPTER5.PRG. Next, estimate dlrdgp as an AR(2) process using:
lin dlrgdp / resids
# constant dlrgdp{1 to 2}
Variable
Coeff
Std Error
T-Stat
Signif
****************************************************************
1. Constant
0.0051566068 0.0010217954
5.04661 0.00000119
2. DLRGDP{1}
0.2508977521 0.0769801061
3.25925 0.00135976
3. DLRGDP{2}
0.1362250820 0.0762100846
1.78749 0.07571568
Now we can perform the identical estimation using matrices. First, we can make the matrix x
containing the regressors from the AR(2) using:
make(lastreg) x 4 2001:1