Re: your partial corr. function

Richard M. Heiberger (rmh@astro.ocis.temple.edu)
Tue, 15 Nov 94 11:49:25 -0500


I have received a request for explanation of why the partial correlation
function I posted last week works.

SWP is a variant of Gaussian elimination and provides a very efficient
solution to the normal equations. While I recommend the discussion of
SWP in my book (Heiberger 1989), there are other references. Snedecor
and Cochran (beginning in the 6th edition (or maybe its 7th)), Winer
beginning in the 2nd edition, Goodnight in the American Statistician
1979, Kennedy and Gentle 1980, Thisted 1988, Dempster 1969, and of
course, Beaton 1964.

The definition of partial correlation is this:
Let y1.x be the residuals from regressing y1 on x.
Let y2.x be the residuals from regressing y2 on x.
Then "the partial correlation of y1 and y2 adjusted for x" is defined as
"the correlation of y1.x and y2.x".

The SWP works with the crossproduct matrix, called covariance or cov.x
below, and does the arithmetic of regression, removing as an X
whichever variables are mentioned in the argument. In the example, I
called it correlation or corr.x, following the notation of your question.
The rescaling to correlation is unnecessary for the algorithm.

If

cov.x = XX XY
YX YY

then swp(cov.x, X) =

-(XX^(-1)) XX^(-1) XY
YX (XX^(-1)) YY - (YX (XX^(-1)) XY)

This is easy to see when X and Y are single columns. It is also true
when X and Y are sets of multiple columns. It is an interesting
exercise to demonstrate algebraically that (in the notation of the
function)

swp( swp(cov.x, 1), 2) == swp( swp(cov.x, 2), 1)

The YY - (YX (XX^(-1)) XY) piece of the tmp matrix in the function
(consisting of those rows and columns with positive diagonal) are the
crossproduct of the adjusted Y variables. To make them into
correlations they need to be rescaled to have 1 on the diagonals.
Hence the final multiplication by the reciprocal of the square root of
the diagonals.