Bug in lm.wfit with zero weights in 0.63.3 (PR#136)
ripley@stats.ox.ac.uk
ripley@stats.ox.ac.uk
Tue, 9 Mar 1999 14:31:15 +0100
R 0.63.3 (any platform)
library(lqs)
example(lqs)
gives
Warning in (y - z$residuals) + offset : longer object length
is not a multiple of shorter object length
repeatedly. The problem is in lm.wfit, which removes cases with
zero weights, but does not adjust the offset. The fix is
z$fitted.values <- (y - z$residuals)
z$weights <- w
if (zero.weights) {
coef[is.na(coef)] <- 0
f0 <- x0 %*% coef
if (ny > 1) {
save.r[ok, ] <- z$residuals
save.r[nok, ] <- y0 - f0
save.f[ok, ] <- z$fitted.values + offset[ok,]
save.f[nok, ] <- f0 + offset[nok,]
}
else {
save.r[ok] <- z$residuals
save.r[nok] <- y0 - f0
save.f[ok] <- z$fitted.values + offset[ok]
save.f[nok] <- f0 + offset[nok]
}
z$residuals <- save.r
z$fitted.values <- save.f
z$weights <- save.w
} else
z$fitted.values <- z$fitted.values + offset
The only examples affected are those with a non-zero offset and zero
weights: these will have incorrect fitted values.
I've commited this for 0.64.0.
--
Brian D. Ripley, ripley@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-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._