[R] Possible bug in summary of residuals with lm and weights
Frank E Harrell Jr
f.harrell at vanderbilt.edu
Tue Jun 28 18:16:17 CEST 2005
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
More information about the R-help
mailing list