Skip to content
Prev 206817 / 398503 Next

Remove term from formula for predict.lm

This recomputes the lm but if that is ok then:

mod <- lm(y1 ~ x1 + x2 + x3 + x4, anscombe)

mod$call$formula <- update(as.formula(mod$call$formula), ~ . - x1 - x2)
predict(eval(mod$call), list(x3 = 1, x4 = 1))
On Tue, Jan 19, 2010 at 11:10 AM, Werner W. <pensterfuzzer at yahoo.de> wrote: