Skip to content
Prev 316407 / 398503 Next

how to suppress the intercept in an lm()-like formula method?

On 1/29/2013 9:25 AM, Duncan Murdoch wrote:
That's very clever.  I think I can use this locally in my function. 
However, it is still a mystery to me *where* in the process terms()
gets called.  The main incantation for model formulae in lm() is below, 
so who calls terms()?

     cl <- match.call()
     mf <- match.call(expand.dots = FALSE)
     m <- match(c("formula", "data", "subset", "weights", "na.action"), 
names(mf), 0L)
     mf <- mf[c(1L, m)]

     mf[[1L]] <- as.name("model.frame")
     mf <- eval(mf, parent.frame())

     mt <- attr(mf, "terms")

It is also a mystery to me where na.action takes its effect. Presumably 
this is somewhere before lm.fit(x, y, ...)
gets called, but I'd like to take account of this in my cancor.default 
method.

-Michael