Skip to content

Confidence intervals for gls models?

3 messages · Brown, David, Spencer Graves, Brian Ripley

#
What about the obvious:

tstDf <- data.frame(x=1:9, y=rnorm(9), w=1:9)
fit <- lm(y~x, tstDf, weights=w)
pred <- predict(fit, se.fit=T)
pred$fit + outer(pred$se.fit, c(-2, 2))

"predict.lm" might need weights for interval="prediction" with newdata, 
but not with interval="confidence" ... or am I missing something?

hth.  spencer graves
Brown, David wrote:
#
On Sun, 18 May 2003, Spencer Graves wrote:

            
That's weighted least squares, not generalized least squares.

predict.gls does not have an `se.fit' argument.

Howver, lm.gls in package MASS will do the trick at the existing data 
points.  (To predict at newdata you would need to have a model for the 
covariance matrix, and once you have that you are doing time series or 
kriging or ... and there are many other possibilities.)