On Fri, 15 Oct 2004, Hiroyuki Kawakatsu wrote:
> i noticed that se.fit from predict.lm is the same whether
interval="conf"
> or interval="pred". it is not clear to me from ?predict.lm
whether this is
> intended or not. i suggest that se.fit should match the type of interval
> requested, if interval is specified. suggested change in lm.R line 700
It is intended. It has been that way in S for many years, and lots of
code relies on it. Why would it be useful to have the standard error of a
prediction interval called se.fit?
^^^
> if(se.fit || interval != "none") se <- sqrt(ip)
> to
> if(se.fit || interval != "none") se <- switch(interval,
none = ,
> confidence = sqrt(ip), prediction = sqrt(ip+res.var) )
>
>
> #---sample code to illustrate issue---
>
> x <- rnorm(5);
> y <- x + rnorm(5);
> out <- lm(y~x);
>
> xf <- data.frame(x=1);
> # expected y
> ye <- predict(out, xf, se.fit=TRUE, interval="conf");
> print(ye$fit);
> print( paste("se=", ye$se.fit) );
> # actual y
> ya <- predict(out, xf, se.fit=TRUE, interval="pred");
> print(ya$fit);
> print( paste("se=", ya$se.fit) );
>
> #---end of sample code---
>
> h.
> p.s. suggestion for ?predict.lm. i don't know whether the
> distinction between interval="confidence" and
interval="prediction" is
> standard terminology.
It is, just as capitalizing is standard usage and you seem not to know.
> it would be clear if the help page had something
> like
> interval="confidence" accounts only for coefficient
uncertainty,
> whereas interval="prediction" accounts for both coefficient and
> innovation uncertainty.
But `innovation' is not standard terminology, and it is not the
coefficients that uncertain, but their estimates.
--
Brian D. Ripley, ripley@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