[R] Possible bug in summary of residuals with lm and weights

From: Frank E Harrell Jr <f.harrell_at_vanderbilt.edu>
Date: Wed 29 Jun 2005 - 02:16:17 EST


I sent this to r-devel the other day but didn't get any takers. This may not be a bug but rather an inconsistency. I'm not sure if this is intentional. summary.lm stores weighted residuals whereas I think most users will want print.summary.lm to summarize unweighted ones as if saying summary(resid(fit)).

> set.seed(1)
> dat <- data.frame(y = rnorm(15), x = rnorm(15), w = 1:15)
> f <- lm(y ~ x, weights = w, data = dat)
> summary(f)

. . . .
Residuals:

    Min 1Q Median 3Q Max
-8.260 -1.565 0.117 2.105 4.666
. . . .
> resid(f)

           1 2 3 4 5 6 -0.73429677 0.06818092 -1.20558034 1.25783256 0.05231879 -1.18383039

           7 8 9 10 11 12   0.16034166 0.59880438 0.98337588 -0.58944957 1.40690588 0.31138819

          13 14 15
-0.35111933 -2.20770335 0.89438636

> version

platform i386-pc-linux-gnu

arch     i386
os       linux-gnu

system i386, linux-gnu
status
major 2
minor 1.0
year 2005
month 04
day 18
language R
-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Jun 29 02:18:38 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:06 EST