On 1/29/2013 10:11 AM, John Fox wrote:
Hi Michael,
OK -- I see -- you need to do more than fix up the model matrix.
How about this?
formula <- update(formula, . ~ . - 1)
cl <- match.call()
cl$formula <- formula
mf <- match.call(expand.dots = FALSE)
mf$formula <- formula
Best,
John
That's the cleverest solution I've seen. It fixes it early, and avoids
later complications / kludges.
Thanks very much for this. I'm cc'ing R-help for posterity.
best,
-Michael
-----Original Message-----
From: Michael Friendly [mailto:frien...@yorku.ca]
Sent: Tuesday, January 29, 2013 9:36 AM
To: John Fox
Subject: Re: [R] how to suppress the intercept in an lm()-like formula
method?
On 1/29/2013 9:23 AM, John Fox wrote:
Hi Michael,
How about,
x <- x[, colnames(x) != "(Intercept)"]
Thanks, John
See my followup post. I'm now using
remove.intercept <- function(x) {
if (colnames(x)[1] == "(Intercept)") {
x <- x[,-1]
attr(x, "assign") <- attr(x, "assign")[-1]
}
x
}
which works, but other objects in the function (mt & mf) are silently
wrong, still including the intercept.
--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street Web: http://www.datavis.ca
Toronto, ONT M3J 1P3 CANADA
--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street Web: http://www.datavis.ca
Toronto, ONT M3J 1P3 CANADA
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.