# should i use only main effect or include interaction for my ancova, not sure how to define my model

I am running an ancova, dv= "usc", between var=group, covariate = gender.

I am not sure if i should use * or + in my formula. also, if i wanted to add another covariate (say education), how would i do it.

my goal is to show that usc is different between groups when controlling for gender as well (and also add education after)

anova_test(data = variables_oaya, formula = usc ~ gender*group,  wid = sub, type = 3, detailed = TRUE)

ANOVA Table (type III tests)

Effect      SSn     SSd DFn DFd      F        p p<.05      ges
1  (Intercept) 2275.403 9834.35   1 216 49.977 2.12e-11     * 0.188000
2       gender    2.062 9834.35   1 216  0.045 8.32e-01       0.000210
3        group 1393.779 9834.35   1 216 30.613 9.07e-08     * 0.124000
4 gender:group    5.962 9834.35   1 216  0.131 7.18e-01       0.000606


when the interaction * is used, my gender p val is 0.832

however when i use +, gender p val is 0.097

anova_test(data = variables_oaya, formula = usc ~ gender+group,  wid = sub, type = 3, detailed = TRUE)

ANOVA Table (type III tests)

Effect      SSn      SSd DFn DFd       F        p p<.05   ges
1 (Intercept) 4631.424 9840.313   1 217 102.133 6.33e-20     * 0.320
2      gender  125.752 9840.313   1 217   2.773 9.70e-02       0.013
3       group 3243.704 9840.313   1 217  71.531 4.03e-15     * 0.248



so my question is how do i know which one is right??i dont fully understand the model/math so im sorry if this is a silly q

When you add an interaction between two variables in your model, you evaluate the "main effect" of each interacting variable as the coefficient when the other variable it is interacting with is has a value of 0. Thus the gender coefficient in the first model is the coefficient for gender==1 at a value of group==0. In terms of adding further terms to the model, it appears that you can use the covariate option in the anova_test command to adjust your estimates for education.

Is there a reason you are using anova rather than a mixed model? The equivalent lmer code for your first model with education added would be the following, after having loaded both lmer and lmertest (for p-values):

lmer1 <- lmer(usc ~ 1 + gender*group + education + (1 | sub), data = variables_oaya)


A reason to use mixed models (and lmer) is the considerable increase in flexibility that comes with using the regression framework.

• could you elaborate more on what you mean regarding interaction vs not. How do I choose which model?
– matt
Nov 23, 2022 at 4:01
• You can run both the model with and without interactions and then compare information criteria fit indices such as AIC and BIC. Comparing AIC from the two models, the model with the lower AIC value provides a better fit to the data. To get AIC and BIC, you can use anova(m1, m2) substituting the name for your two lmer model fits for the model with and without the interaction. See stats.stackexchange.com/questions/577/… for a discussion of these two fit indices. Nov 23, 2022 at 17:22