I'm very new to R so maybe i'm doing something wrong so please let me know it that is that case. Here is an example where the summary() and residuals() applied to lm object produce different results (I think the residuals() results is correct since SAS produces those numbers - the second residual corresponding to observation with weight 4 is wrong in summary()). x <- c( 10, 20, 30, 40 ) y <- c( 33.8, 62.2, 92.0, 122.4 ) w <- c( 1, 4, 1, 1 ) lm.obj <- lm( y ~ x, weights=w ) print( summary( lm.obj ) ) print( residuals( lm.obj ) ) Best regards, Tomislav Goles PS. my version or R is 0.64.2 on Linux. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> "Tom" == Tomislav Goles <tom at ait-tech.com> writes:Tom> I'm very new to R so maybe i'm doing something wrong so Tom> please let me know it that is that case. Tom> Here is an example where the summary() and residuals() Tom> applied to lm object produce different results Tom> (I think the residuals() results is correct since SAS produces Tom> those numbers - the second residual corresponding to observation Tom> with weight 4 is wrong in summary()). Tom> x <- c( 10, 20, 30, 40 ) Tom> y <- c( 33.8, 62.2, 92.0, 122.4 ) Tom> w <- c( 1, 4, 1, 1 ) Tom> lm.obj <- lm( y ~ x, weights=w ) Tom> print( summary( lm.obj ) ) (showing the weighted residuals) Tom> print( residuals( lm.obj ) ) (showing the raw residuals) No real bug here. One could argue that summmary() should say "Weighted residuals:" instead of "Residuals:" (but note that R's behavior here is really like S'). Tom> Best regards, Tom> Tomislav Goles Tom> PS. my version or R is 0.64.2 on Linux. which is *really* too old. but it doesn't matter here... -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On 10 Jan 2000, Tomislav Goles wrote:> > I'm very new to R so maybe i'm doing something wrong so > please let me know it that is that case. > Here is an example where the summary() and residuals() > applied to lm object produce different results > (I think the residuals() results is correct since SAS produces > those numbers - the second residual corresponding to observation > with weight 4 is wrong in summary()). > > x <- c( 10, 20, 30, 40 ) > y <- c( 33.8, 62.2, 92.0, 122.4 ) > w <- c( 1, 4, 1, 1 ) > lm.obj <- lm( y ~ x, weights=w ) > print( summary( lm.obj ) ) > print( residuals( lm.obj ) )It's the documentation that is wrong. R follows S, which says for summary.lm: residuals: the model residuals. These are the weighted residuals if weights were given in the model. The function weighted.residuals gives those directly.> PS. my version or R is 0.64.2 on Linux.Well, we have had four versions since then, and many, many bugs have been fixed. -- Brian D. Ripley, ripley at 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._