RATS 11.1
RATS 11.1

We are using the term heteroscedasticity to mean that the equation errors are uncorrelated across observations, but have unequal variances in some systematic way. (It is sometimes used to define any departure from i.i.d. errors.) There are two common ways to deal with heteroscedasticity: weighted least squares (WLS) estimation, and the White (or Eicker-White) covariance matrix correction. Both are easily implemented in RATS, with the SPREAD and ROBUSTERRORS options respectively.

 

Note that neither of these methods is an appropriate remedy for heteroscedasticity that is the result of a poorly specified model. It’s possible that a better approach than “correcting” for the problem is to adjust the actual model, usually through a rescaling such as conversion to per capita values, to produce more equal variances.

 

See "Heteroscedasticity Testing" for a discussion of tests for this.

Heteroscedasticity: WLS using the SPREAD Option

Use the SPREAD option on an estimation instruction to perform weighted least squares, that is, to correct for heteroscedasticity of a known form:

\begin{equation} y_t = X_t \beta + u_t ,{\rm{Var}}\left( {u_t } \right) = V_t \label{eq:linreg_spreadmodel} \end{equation}

To do weighted least squares, you only need to know a series which is proportional to \(V_t\). Weighted least squares improves the precision of the estimates by “downweighting” observations known to have a high residual variance.

 

spread=residual variance series

The residual variances, \(V_t\), are proportional to the entries of the residual variance series. You can use a series or a formula.

 

Note that SPREAD specifies the variances, or at least a series proportional to them. The “WEIGHT” option used in many other statistics packages requests \(p_t  = {1 \mathord{\left/{\vphantom {1 {\sqrt {V_t } }}} \right.} {\sqrt {V_t } }}\). RATS has a WEIGHT option, but that’s for doing probability weights for the observations. The SPREAD option is available on the estimation instructions LINREG, STWISE, SUR, and ESTIMATE, and the related instructions MAKE, VCV, CMOM, MCOV, RATIO, PANEL, and PSTATS.

 

The SPREAD option implements WLS as follows: If \(p_t  = {1 \mathord{\left/{\vphantom {1 {\sqrt {V_t } }}} \right.} {\sqrt {V_t } }}\), and weighted variables are those multiplied by \(p_t\) and unweighted variables are not scaled, then:

 

Coefficients

computed by regressing \(p_t y_t \) on \(p_t X_t\) (weighted regression)

\(R^2\), other goodness of fit

computed from the weighted regression

Durbin-Watson

computed using unweighted residuals

Residuals

are unweighted

 

RATS leaves the residuals saved in %RESIDS (or using the residuals parameter) in unweighted form so they correspond with the actual data. If you use them later in a VCV or RATIO instruction, you must again use the SPREAD option.

HETERO.RPF example

The example file HETERO.RPF analyzes a linear regression of food expenditures on income for a cross section of 40 individuals demonstrating the techniques in this section. It's fairly clear that the variance of the errors increases with income. If we assume it’s directly proportional to income, we compute the weighted least squares estimator by

 

linreg(spread=income) food

# constant income

 

The ROBUSTERRORS Option

With the ROBUSTERRORS option, LINREG computes the regression using least squares, but then computes a consistent estimate of the covariance matrix allowing for heteroscedasticity, as in Eicker (1967) and White (1980). Note that the coefficients themselves do not change, only their standard errors. For the case of a simple linear regression, the covariance matrix is computed using the results of "A General Framework" with \(Z=X\), \(L=0\) and \(\Theta=I\). This simplifies the formula quite a bit to

\begin{equation} \left( {\beta _T - \beta _0 } \right)\sim N\left( {0,\left( {\sum {X'_t } X_t } \right)^{ - 1} \left( {\sum {X'_t u_t^2 } X_t } \right)\left( {\sum {X'_t } X_t } \right)^{ - 1} } \right) \end{equation}

If you know the form of heteroscedasticity, this will not be as efficient as weighted least squares—the advantage is that you do not need to know the form. In HETERO.RPF, this does the least squares regression with “White” standard errors:

 

linreg(robust) food

# constant income

Feasible GLS

While sometimes there may be good theoretical reasons for the spread function to take a particular form, more often all that may be known is that it is likely to be some function of some of the variables in the data set. Under those circumstances, you may be able to estimate the function and apply the weights obtained from that. This process is called Feasible or Estimated GLS (FGLS or EGLS). Greene (2012, Chapter 9) has an especially detailed look at the subject.

 

Because the spread function has to be positive, the most common form used for it is an exponential; in inverse form:

\begin{equation} \log V_t = \gamma + \delta Z_t \label{eq:linreg_spreadtheoretical} \end{equation}

A feasible implementation of this is to run \eqref{eq:linreg_spreadtheoretical} as a regression with \(log V_t\) replaced by the squared (least squares) residuals.

 

If the explanatory variable in this is \(Z_t=log X_t\), this implies

\begin{equation} V_t = e^\gamma Z_t^\delta \equiv \sigma ^2 Z_t^\delta \end{equation}

so it would be an arbitrary power of \(X\). If the choice above of SPREAD=INCOME were correct, we would expect a \(\delta\) of around 1. The implementation in HETERO.RPF is:

 

linreg food

# constant income

*

set esq = log(%resids^2)

set z   = log(income)

*

linreg esq

# constant z

 

PRJ is then used to compute the fitted values from the auxiliary regression. Since that predicts the log variance, the exp of it is used for the SPREAD option:

 

prj vhat

linreg(spread=exp(vhat)) food

# constant income

 

It’s possible to estimate both the regression parameters and the variance parameters jointly, but that requires non-linear methods.

 


Copyright © 2026 Thomas A. Doan