[R] predict.lm with (logical) NA vector

Edzer J. Pebesma e.pebesma at geog.uu.nl
Mon Nov 10 09:07:36 CET 2003


I was surprised by the following (R 1.8.0):

R> lm.fit = lm(y~x, data.frame(x=1:10, y=1:10))
R> predict(lm.fit, data.frame(x = rep(NA, 10)))
             1              2              3              4              5
-1.060998e-314 -1.060998e-314 -1.060998e-314 -1.060998e-314 -1.060998e-314
             6              7              8              9             10
  0.000000e+00  1.406440e-269  6.715118e-265  4.940656e-323  1.782528e-265
R> predict(lm.fit, data.frame(x = as.numeric(rep(NA, 10))))
 1  2  3  4  5  6  7  8  9 10
NA NA NA NA NA NA NA NA NA NA

shouldn't the first predict() call return NA's, or else issue an error 
message?
--
Edzer




More information about the R-help mailing list