Suppose you are using R
and have data stored in a data frame, M
. Then I know that
g <- glm(Y ~ ., data=M)
will automatically fit a model where Y
is the dependent variables and all other columns of M
are the predictors. Is there an analogously simple way to additionally include every two way interaction?
You can do two-way interactions simply using .*.
and arbitrary n -way interactions writing .^n
. formula(g)
will tell you the expanded version of the formula in each of these cases.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.