RATS 10.1
RATS 10.1

Instructions /

LINREG Instruction

Home Page

← Previous Next →

LINREG( options )  depvar start end resids

# list of explanatory variables (in Regression Format)
 

LINREG computes a single linear regression using least squares, weighted least squares, or instrumental variables.

Wizards

Use the Statistics—Linear Regressions Wizard and select "OLS", "Weighted Least Squares", or "Instrumental Variables" as the Method.

Parameters

depvar

dependent variable

start, end

Range to use in estimation. If you have not set a SMPL, this defaults to the largest common range for all the variables involved. If you use the INSTR option, the instruments are included in determining the default.

resids

series for residuals (optional)

Options

[PRINT]/NOPRINT

VCV/[NOVCV]

These control the printing of the regression output and the estimated Covariance/correlation matrix of the coefficients, respectively.

 

TITLE="title for output" [Depends upon estimation method]

This option allows you to supply your own title to label the resulting output.

 

SMPL=Standard SMPL option [unused].

Omits from the estimation any observations where SMPL series or expression is zero.

 

SPREAD=Standard SPREAD option [unused]

WEIGHT=Standard WEIGHT option[unused]

Use SPREAD for weighted least squares and WEIGHT to provide different weights for each observation.

 

SHUFFLE=SERIES[INTEGER] with entry remapping[unused]

 

EQUATION=Equation to estimate [unused]

Use the EQUATION option to estimate a previously defined equation. If you use it, omit the supplementary card.

 

DEFINE=equation to define [unused].

FRML=formula to define [unused]

These define an equation and formula, respectively, using the results of the estimation. You can use the equation/formula for forecasting or other purposes.

 

CMOM/[NOCMOM]

Use the CMOM option together with the CMOMENT instruction (executed prior to the LINREG). LINREG takes the required cross products of the variables from the array created by CMOMENT. This has two uses:

By computing the cross products just once, you can reduce the computations involved in repetitive regressions.

By altering the %CMOM array before running the regression, you can implement ridge, mixed and related estimators.

To use CMOM, you must include all variables involved in the regression in the list for CMOMENT. RATS will ignore the LINREG start and end parameters, and carry over the range from CMOMENT.
 

CREATE/[NOCREATE]

If you use CREATE, LINREG does not estimate the regression. Instead, it generates the standard regression output and statistics using information that you provide. See “Options with Create” for details.

 

DFC=degrees of freedom correction [0].

Corrects for degrees of freedom lost in the dependent variable in processing prior to the regression.

 

ENTRIES=number of entries to use from supplementary card [all].

This allows you to control how many of the elements on the supplementary card are processed. This can be useful in repetitive-analysis tasks, where you may want to add additional entries on each trip through a loop, for example.

 

UNRAVEL/[NOUNRAVEL]

Substitutes for ENCODED variables. RATS does not print the intermediate regression (in terms of encoded variables).

Options for Least Squares

ROBUSTERRORS/[NOROBUSTERRORS]
 

LAGS=correlated lags [0]

LWINDOW=NEWEYWEST/BARTLETT/DAMPED/PARZEN/QUADRATIC/[FLAT]/PANEL/WHITE

LWFORM=VECTOR with the window form [not used]

CLUSTER=series with category values for clustered standard errors [not used]

DAMP=value of \(\gamma\) for LWINDOW=DAMPED [0.0]

When used without the INSTRUMENTS option, these permit calculation of a consistent covariance matrix allowing for heteroscedasticity (with ROBUSTERRORS) or serial correlation (with LAGS), or clustering based upon some other set of categories.

Options for Instrumental Variables (Two-Stage Least Squares/GMM)

INSTRUMENTS/[NOINSTRUMENTS]

Use the INSTRUMENTS option to do two-stage least squares or GMM. You must set your instruments list first using the instruction INSTRUMENTS.

WMATRIX=weighting matrix [\({\left( {{\bf{Z'Z}}} \right)^{ - 1}}\)]

IWMATRIX=inverse weighting matrix [not used]

OPTIMALWEIGHTS/[NOOPTIMALWEIGHTS]

UPDATE=NONE/ONCE/CONTINUOUS

This controls the updating of the weighting matrix. You can directly input a weight matrix with the WMATRIX or IWMATRIX option. If you don’t, the weight matrix is initialized as the \({\left( {{\bf{Z'Z}}} \right)^{ - 1}}\) matrix which gives two-stage least squares. If you use OPTIMALWEIGHTS or UPDATE=CONTINUOUS (they’re synonyms), the weight matrices are recomputed after every iteration using the next group of options.

 

[ZUDEP]/NOZUDEP

LAGS=correlated lags [0]

LWINDOW=NEWEYWEST/BARTLETT/DAMPED/PARZEN/QUADRATIC/[FLAT]/PANEL/WHITE

DAMP=value of \(\gamma\) for LWINDOW=DAMPED [0.0]

LWFORM=VECTOR with the lag window form [not used]

CLUSTER=SERIES with category values for clustered calculation

Use these to select the type of correlation assumed for the Z'u process.
 

ZUMEAN=VECTOR of means of moment conditions [zeros]

This allows you to supply a VECTOR (with dimensions equal to the number of instruments) with a set of known (non-zero) means for \(E({\bf{Z}}'{\bf{u}})\). By default, RATS sets these to zero.

 

CENTER/[NOCENTER]

CENTER adjusts the formula for the weight matrix to subtract off the (sample) means of \({\bf{Z}}'{\bf{u}}\), which may be non-zero for an overidentified model.

 

JROBUST=STATISTIC/[DISTRIBUTION]

You can use this option to adjust the J-statistic specification test when the weighting matrix used is not the optimal one.

Examples

linreg(define=foodeq) foodcons / resids

# constant dispinc trend

 

regresses FOODCONS on DISPINC and TREND, saves the residuals as RESIDS, and creates equation FOODEQ.


 

linreg(robusterrors) gdp 1955:1 2009:4

# constant m1{-4 to 8}

 

regresses GDP on 4 leads to 8 lags of M1 and corrects the covariance matrix for possible heteroscedasticity.


 

instruments constant mdiff{0 1} govt{0 1} $

   invest{1} cons{1 2} gnp{1 2} rate{1 to 5}

linreg(inst,frml=conseq) cons

# constant gnp cons{1}

 

computes two-stage least squares estimates of CONS on GNP and lagged CONS and defines the FRMLCONSEQ from the results.

Variables Defined (for all)

%BETA

coefficient VECTOR

%DURBIN

Durbin-Watson statistic (REAL)

%FUNCVAL

final value of the function being optimized (REAL)

%MEAN

mean of dependent variable (REAL)

%NDF

number of degrees of freedom (INTEGER)

%NFREE

number of free parameters (INTEGER)

%NOBS

number of observations (INTEGER)

%NREG

number of regressors (INTEGER)

%RESIDS

SERIES containing the residuals

%RHO

first lag correlation coefficient (REAL)

%RSS

residual sum of squares (REAL)

%SEESQ

standard error of estimate squared (REAL)

%SIGMASQ

maximum likelihood variance estimate (REAL)

%STDERRS

VECTOR of coefficient standard errors

%TSTATS

VECTOR containing the t-stats for the coefficients

%VARIANCE

variance of dependent variable (REAL)

%XX

\({\left( {{\bf{X'X}}} \right)^{ - 1}}\) or similar where appropriate, otherwise the covariance matrix of coefficients (SYMMETRIC)

Variables Defined (for Least Squares)

%LOGL

normal log likelihood (REAL)

%RBARSQ

R-bar-squared (REAL)

%RSQUARED

R-squared (REAL)

%TRSQ

number of observations times raw R-squared (REAL)

%TRSQUARED

number of observations times the centered R-squared (REAL)

 

Variables Defined (for Instrumental Variables)

%JSTAT

test statistics for overidentification (for instrumental variables regressions) (REAL)

%JSIGNIF

significance level of %JSTAT (REAL)

%NDFJ

degrees of freedom for %JSTAT (INTEGER)

%UZWZU

\({\bf{u'}}{\kern 1pt} {\bf{Z}}{\kern 1pt} {\bf{W}}{\kern 1pt} {\bf{Z'u}}\)  (REAL)

%WMATRIX

final weight matrix for GMM (SYMMETRIC)

 

Options with CREATE

If you use LINREG with the option CREATE, LINREG does not compute the regression. Instead, it prints standard regression output using the information which you supply. By using LINREG(CREATE), you can get the proper t-statistics and gain access to the hypothesis testing instructions: EXCLUDE, SUMMARIZE, TEST, RESTRICT and MRESTRICT.

 

You can use the following options with CREATE:

 

CREATE/[NOCREATE]

with CREATE the regression is not estimated, LINREG just prints the regression output using information you supply.

 

LASTREG/[NOLASTREG]

With LASTREG, RATS uses the regressors from the preceding regression. You do not need to include a supplementary card.

 

EQUATION=equation to use

You can use the EQUATION option as an alternative to a supplementary card to input a regression which differs from the preceding one (so you can’t use LASTREG). The equation should be an equation which you have already defined—it supplies the list of explanatory variables and dependent variable. Use the COEFF and COVMAT options to input the coefficients and covariance matrix.

 

COEFF=VECTOR of coefficients [default: current BETA]

COVMAT=SYMMETRIC covariance matrix [default: current XX]

The COEFF option supplies the VECTOR of coefficients and the COVMAT option supplies the matrix which will become the %XX matrix. You may not dimension %BETA or %XX (the default COEFF and COVMAT arrays) yourself. However, once you have completed a regression, you can use matrix instructions to alter them.

 

FORM=FTEST/CHISQUARED

If you change %XX or use COVMAT, and the new matrix is itself an estimate of the covariance matrix, use FORM=CHISQUARED to switch those formulas based on F and t to those based on Chi-squared and Normal.
 

REGCORR=number of restrictions

Use this option if you have computed the coefficients subject to restrictions. This allows LINREG to compute the proper degrees of freedom.
 

RESIDUALS=input residuals series

This option allows you to provide your own series of residuals. LINREG uses the input residuals series in computing the summary statistics.

Example Using CREATE

mcov(matrix=b,lastreg) / f

mcov(matrix=a,lastreg,nosquare) / fprime

compute %xx=%mqform(b,inv(a))

linreg(create,form=chisquared,lastreg)

 

This replaces %XX with a computed covariance matrix and reprints the regression.

 


Copyright © 2025 Thomas A. Doan