[R] Remove term from formula for predict.lm

Walmes Zeviani walmeszeviani at hotmail.com
Tue Jan 19 18:22:25 CET 2010


Werner,

You could set 0 to that regressors you don't want to consider for
prediction.

da <- expand.grid(A=1:20, B=rnorm(20, 4, 0.2), C=10^seq(1,2,l=20))
da$y <- rnorm(da$A, 0, 0.3)

m0 <- lm(y~A+B+C, data=da)

new <- da
new$C <- 0

predict(m0)[1:5]
predict(m0, newdata=new)[1:5]

At your disposal.
Walmes.

-----
..oooO
..................................................................................................
..(....)... 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/Remove-term-from-formula-for-predict-lm-tp1017686p1017759.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list