[R] GLMing with all possible combinations (automatically)
keren at math.montana.edu
Wed Mar 7 18:33:44 CET 2012
glm(Response~ .^2, data=yourdata.frame)
For all predictors (.) and 2-way interactions (^2).
You might also want to see ?drop.terms and ?formula for automating the
construction of all model combinations.
Side note: R is not SAS (fortunately). Interaction is denoted ":", X*Y
is shorthand for X+Y+X:Y. Your "X+Y+X*Y" is redundant.
On Wed, Mar 7, 2012 at 4:16 AM, Christofer Bogaso
<bogaso.christofer at gmail.com> wrote:
> Dear all, I was working with a GLM model and wondering whether is it
> possible to have a model description with all possible main effects as
> well as all interactions. Currently I do it manually however this will
> become cumbersome if I have large number of variables.
> Means suppose I have 3 explanatory variables and want to feed
> automatically with all possible combinations like:
> .................................................... all combinations
> which are possible
> Thanks and regards,
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help