[Rd] se.fit from predict.lm

From: Hiroyuki Kawakatsu <hkawakat_at_qub.ac.uk>
Date: Fri 15 Oct 2004 - 19:56:41 EST


hi,

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

    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 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.

> version

         _
platform i386-pc-mingw32

arch     i386
os       mingw32

system i386, mingw32
status
major 2
minor 0.0
year 2004
month 10
day 04
language R

Hiroyuki Kawakatsu
School of Management and Economics
25 University Square
Queen's University, Belfast
Belfast BT7 1NN
Northern Ireland
United Kingdom
Tel +44 (0)28 9097 3290
Fax +44 (0)28 9033 5156

R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Oct 15 20:32:03 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:00:36 EST