[R] predict.lm with NAs

Walmes Zeviani walmeszeviani at hotmail.com
Thu Apr 15 14:22:34 CEST 2010


You can use predict() by specifying a complete data.frame() for prediction to
the argument newdata=. Look:

da <- expand.grid(x1=LETTERS[1:4], x2=1:9)
da$y <- rnorm(da$x1)
da$y[sample(length(da$y), 5)] <- NA

m0 <- lm(y~x1+x2, data=da)
predict(m0) # NA not predicted
predict(m0, newdata=da) # NA predicted

Sincerely.
Walmes.

-----
..ooo0
...................................................................................................
..(....)... 0ooo...                              Walmes Zeviani
...\..(.....(.....)...     Master in Statistics and Agricultural
Experimentation
....\_)..... )../....       walmeszeviani at hotmail.com, Lavras - MG, Brasil
............
(_/............................................................................................
-- 
View this message in context: http://n4.nabble.com/predict-lm-with-NAs-tp1840661p1886457.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list