[R] update() ignores object
Sverre Stausland
johnsen at fas.harvard.edu
Mon Aug 15 22:44:02 CEST 2011
Hi all,
I'm extracting the name of the term in a regression model that
dropterm specifies as the least significant one, and I'm assigning
this name to an object. However, when I use update(), it ignores this
object. Is there a way I can make it not ignore it? A reproducible
example is below:
> lm(x1~1+y1*y2+y3+y4,data=anscombe)->my.lm
> rownames(dropterm(my.lm,test="F",sort=TRUE))[1]->my.object
> my.object
[1] "y1:y2"
> update(my.lm,.~.-my.object)
Call:
lm(formula = x1 ~ y1 + y2 + y3 + y4 + y1:y2, data = anscombe)
Coefficients:
(Intercept) y1 y2 y3 y4
-8.95635 1.11420 0.61921 0.76762 0.21237
y1:y2
-0.04056
> update(my.lm,.~.-y1:y2)
Call:
lm(formula = x1 ~ y1 + y2 + y3 + y4, data = anscombe)
Coefficients:
(Intercept) y1 y2 y3 y4
-6.6409 0.7618 0.3836 0.7759 0.1640
More information about the R-help
mailing list