Skip to content
Prev 333215 / 398506 Next

Bug in predict.lm?

The same problem appears on a 64-bit linux:
platform       x86_64-pc-linux-gnu
arch           x86_64
os             linux-gnu
system         x86_64, linux-gnu
status
major          3
minor          0.2
year           2013
month          09
day            25
svn rev        63987
language       R
version.string R version 3.0.2 (2013-09-25)
nickname       Frisbee Sailing

After dputting the predict.lm function (traceback etc. did not give a hint
on the source of the error message) I could locate the invalid call at
around the 70-80th rows of the function:

...
        if (type != "terms") {
            if (p > 0) {
                XRinv <- if (missing(newdata) && is.null(w))
                    qr.Q(qr.lm(object))[, p1, drop = FALSE]
                else X[, piv] %*% qr.solve(qr.R(qr.lm(object))[p1,
                                                               p1])
                ip <- drop(XRinv^2 %*% rep(res.var, p))
            }  else ip <- rep(0, n)
        }
...

Here ...&& is.null(w)... causes the troubles.