ENCODE Instruction |
ENCODE( options ) codings start end list of new series
# list of original variables in Regression Format
Creates series from linear combination of other series for restricted regressions. Used with UNRAVEL options on the estimation instructions.
Parameters
codings |
A RECTANGULAR matrix of dimension number of new series x number of original variables. Each row of codings provides the coefficients of a different linear combination of the variables. |
start, end |
range of entries to compute. This defaults to maximum range allowed by variables being transformed. |
new series |
List of series to be constructed by ENCODE. There should be one series per row of codings. We recommend using the newer RESULTS option instead. |
Options
RESULTS=VECTOR[SERIES] of constructed variables
The ENCODEd variables have no particular use other than as a group in a regression. RESULTS stores the constructed variables into a VECTOR[SERIES]. To do the restricted regression, just use the name of the RESULTS array in your regressions (for example, on the supplementary card of a LINREG)
[CLEAR]/NOCLEAR
Unless you use NOCLEAR, ENCODE erases any information from previous ENCODE instructions. If a regression requires more than one ENCODE, the ENCODEs after the first must use NOCLEAR.
ENTRIES=standard ENTRIES option [all]
Description
ENCODE and UNRAVEL work by estimating a regression on specially constructed variables. These new variables are linear combinations of your original set of regressors, incorporating the desired restrictions. When you UNRAVEL, the regression is rewritten in terms of the original regressors.
To illustrate: suppose you want the coefficients on X4 and X5 to be equal. You can run the regression with Z=(X4+X5) as an explanatory variable instead of X4 and X5 separately. This will give you the desired regression, except that X4 and X5 don’t show up in your output—Z does. ENCODE and UNRAVEL don’t change this procedure, they just ensure that the regression is reported using the original regressors. Basically, ENCODE computes the “Z” variable, and remembers how it was constructed. When you UNRAVEL a regression, the “Z” is replaced with equal coefficients on X4 and X5.
Example
The code below is taken from the example PDL.RPF. It computes a 3rd order polynomial distributed lag first using ENCODE and UNRAVEL, then with the @PDL procedure.
declare rect r
* PDL with no end constraints
dim r(4,25)
ewise r(i,j)=j^(i-1)
encode(results=enc) r
# shortrate{0 to 24}
linreg(unravel) longrate
# constant enc
* Same estimation using the PDL procedure
@pdl(graph) longrate
# shortrate 0 24 3
* PDL with far constraint
dim r(3,25)
ewise r(i,j)=(j-26)*j^(i-1)
encode(results=enc) r
# shortrate{0 to 24}
linreg(unravel) longrate
# constant enc
* Same estimation using the PDL procedure
@pdl(constrain=far,graph) longrate
# shortrate 0 24 3
Notes
When you UNRAVEL a regression, the result is a covariance matrix which is not full-rank. For instance, in the example above, the 27 coefficients in the final regression are actually linear combinations of the 9 coefficients estimated. You can run hypothesis tests on the restricted regressions as you would unrestricted ones. However, RATS may have to adjust the degrees of freedom of the test. For instance,
exclude
# shortrate{0 to 12}
will actually have just 4 numerator degrees of freedom, not 13. RATS will automatically adjust the degrees of freedom accordingly, and issue a warning like:
X13. Redundant Restrictions. Using 4 Degrees, not 13
Copyright © 2025 Thomas A. Doan