RATS 10.1
RATS 10.1

Statistics and Algorithms /

Recomputing a Covariance Matrix

Home Page

← Previous Next →

Current statistical practice includes a large set of procedures which produce consistent estimates for coefficients, while giving inconsistent estimates of the covariance matrix of the estimated coefficients. For example:

Least squares with heteroscedasticity or serial correlation of the residuals.

Robust estimators computed with iterated weighted least squares.

Heckman’s iterated least squares procedure for truncated samples (Heckman, 1976).

 

RATS can handle the first automatically if you use the ROBUSTERRORS option which is described in "A General Framework". You need to do the computations yourself in other situations. This relies upon an extension of the general results from that page.

Computational Strategy

A basic strategy for computing the covariance matrix which works in a wide variety of situations is the following: If the estimator solves the first order conditions

\begin{equation} \sum {X'_t {\kern 1pt} {\kern 1pt} f\left( {y_t - X_t \beta } \right) = 0} \end{equation}          

for some function \(f(u)\) , the covariance matrix of \(\hat \beta \) can be estimated by the “sandwich” \(\bf{A}^{-1}\bf{B}\bf{A}^{-1}\) where

\begin{equation} {\bf{B}} = \sum {X'_t X_t {\kern 1pt} {\kern 1pt} f^2 \left( {y_t - X_t \beta } \right)} \end{equation}

and

\begin{equation} {\bf{A}} = \sum {X'_t X_t {\kern 1pt} {\kern 1pt} f'\left( {y_t - X_t \beta } \right)} \end{equation}    

You might have to change the sign on \(\bf{A}\) to make it positive definite. A sign change will cancel out of the calculation because \(\bf{A}^{-1}\) appears twice. You can compute \(\bf{B}\) and \(\bf{A}\) with the instruction MCOV using as residuals (in the notation of MCOV):

the series \(f\) for computing \(\bf{B}\)

the series \(f'\) with the option NOSQUARE for computing \(\bf{A}\)

Use the following steps:

1.Compute your estimates.

2.Compute the series of values \(f(u)\) and \(f'(u)\).

3.Compute \(\bf{A}\) and \(\bf{B}\) using MCOV.

4.Replace %XX with \(\bf{A}^{-1}\bf{B}\bf{A}^{-1}\) using the instruction compute %xx=%mqform(b,inv(a))

5.Use LINREG with the options CREATE and FORM=CHISQUARED to reprint the regression, using the new standard errors and covariance matrix.

 


Copyright © 2025 Thomas A. Doan