From hkawakat at qub.ac.uk  Fri Oct 15 11:56:41 2004
From: hkawakat at qub.ac.uk (Hiroyuki Kawakatsu)
Date: Fri Oct 15 12:07:49 2004
Subject: [Rd] se.fit from predict.lm 
Message-ID: <Pine.CYG.4.58.0410151039340.1212@erdos>

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


[Rd] se.fit from predict.lm
Hiroyuki Kawakatsu