Skip to content
Prev 206842 / 398503 Next

Remove term from formula for predict.lm

If you want to keep the same coefficients but ignore certain ones just
use 0 for the ones you don't want:

mod <- lm(Sepal.Length ~ Petal.Length + Petal.Width, iris)
predict(mod, list(Petal.Length = 3, Petal.Width = 0))


Regarding the problem with the example, the example data was not the
best for showing this because there are co-linear columns in the
anscombe data set.  Using iris we see that it does produce different
answers:
1
4.857262
1
5.53337
On Tue, Jan 19, 2010 at 12:05 PM, werner w <pensterfuzzer at yahoo.de> wrote: