Re: Generalized least squared model with known covariance matrix

Jim Robison-Cox (jimrc@mathfs.math.montana.edu)
Fri, 16 Jan 1998 15:55:56 -0700 (MST)


On Thu, 15 Jan 1998, Ba Pham wrote:

> I try to fit a GLS model in which the responses are correlated with a
> knonw covariance matrix, hence I need to sandwich the covariance
> matrix into the normal equation. Wonder how that can be done with the
> existing procedures in Splus version 3.3 for Windows.
> Thank you.
> Ba' Pham
> Dept of Medicine - U of Ottawa
> 501 Smyth Rd, Ottawa Ontario Canada K1H 8L6
> Phone: (613) 737 8472. Fax: (613) 737 8141
> Email: bpham@ogh.on.ca

OLS assumes:
y = X * b + e where var(e) = sigma^2 * I, an n by n identity

GLS assumes var(e) = sigma^2 * V where V is symmetric positive
definite, known.

We can decompose V into U * U' and take T = inverse of U

Then var(T * e) = sigma^2 * T * U * U' * T' = sigma^2 * I
so the transformed model:
T*y = T * X * b + T * e can be fit with OLS

There are several ways to find T. One is:

Transf <- solve(t(chol(V)))
#(Splus chol() puts transposes oppositely from mine)

Ty <- Transf *% y
TX <- Transf %*% X

now you are ready to use lm()

fit <- lm(Ty ~ TX)

This is assuming that V is n by n. SOmetimes it's block diagonal and
much efficiency would be gained by using that structure.

Jim Robison-Cox ____________
Department of Math Sciences | | phone: (406)994-5340
2-214 Wilson Hall \ BZN, MT | FAX: (406)994-1789
Montana State University | *_______|
Bozeman, MT 59717 \_| e-mail: jimrc@math.montana.edu