I use the R code:
dat<-data.frame(p1=c(0,1,1,0,0), GAMMA.1=c(1,2,3,4,3), VAR1=c(2,2,1,3,4), GAMMA.2=c(1,1,3,4,1))
form <- p1 ~ GAMMA.1:VAR1 + GAMMA.2:VAR1
mod <- glm(formula=form, data=dat, family=binomial)
(coef <- coefficients(mod))
# (Intercept) GAMMA.1:VAR1 VAR1:GAMMA.2
# 1.7974974 -0.2563667 -0.2181079
As we can see the names of coef
for the interaction GAMMA.2:VAR1
is not in the same order as in form
(we have VAR1:GAMMA.2
instead). For several reasons, I need the output
# (Intercept) GAMMA.1:VAR1 GAMMA.2:VAR1
# 1.7974974 -0.2563667 -0.2181079
without changing the names of the coefficients afterwards. Specifically, I want the same names for the coefficients as I used in the form
object (without switching as in the code above). Can I tell glm()
not to switch the names of the interactions?