[R] Confidence intervals for gls models?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon May 19 08:58:07 CEST 2003
On Sun, 18 May 2003, Spencer Graves wrote:
> 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?
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.)
>
> hth. spencer graves
>
> Brown, David wrote:
> > Is there an easy way to compute confidence intervals (or prediction
> > intervals) for gls models?
> >
> > E.g. for standard linear models, with the predict.lm function, we can set
> > interval="confidence" , level = 0.95 and type="response".
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list