Skip to content
Prev 37279 / 63421 Next

problem with zero-weighted observations in predict.lm?

Peter Dalgaard wrote:
Spoke too soon, it fixes Bill's case, but breaks one of the regression
tests!

In fact this goes deeper, summary.lm special-cases the same zero-rank
case by using length(residuals), so it also miscalculates with zero weights:
Call:
lm(formula = y ~ 0, weights = c(0, rep(1, 9)))

Residuals:
     Min       1Q   Median       3Q      Max
-1.95428 -1.40571 -0.42378 -0.05795  1.05518

No Coefficients

Residual standard error: 1.119 on 10 degrees of freedom

----

Hum. lm() actually returns df.residual, AFAICS in all cases, now why
don't we just use that throughout????