[R] drop.terms and [.terms ignores intercept
peter dalgaard
pdalgd at gmail.com
Wed Sep 29 11:13:39 CEST 2010
On Sep 29, 2010, at 10:29 , Niels Richard Hansen wrote:
> The functions drop.terms and [.terms ignores if the intercept
> has been explicitly removed. Is that a deliberate feature?
Perhaps rather an unimplemented one. The root cause is that both functions use reformulate() on the "term.labels" attribute, and there is no way to specify that you want to reformulate into a no-intercept formula. On the other hand, the modeling code will happily proceed with a no-intercept model even if there is no "-1" in formula part of a terms object, e.g.
> x <- terms(y~a+b)
> attr(x,"intercept") <- 0
> lm(x)
Call:
lm(formula = x)
Coefficients:
a b
0.2263 0.4178
> formula(x)
y ~ a + b
so I suppose that there is no really good excuse not to carry the "intercept" attribute over. As usual, with code as old as this, there is always the risk that something actually relies on current behavior.
--
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list