# How should the interaction between two dichotomous effects coded predictors be interpreted?

This is in the context of a linear mixed effects model, though I'm not sure that changes things.

Imagine two dichotomous predictors: Factor A and Factor B.

The model includes the following predictors: A + B + AxB

What precisely is the interaction term testing? I had assumed it tested whether the effect of A differed based on levels of B. But someone recently suggested this might not be the case, and that a type-III ANOVA would be necessary to evaluate the significance of this interaction.

Could anyone help me understand exactly what the AxB interaction is testing, especially with regards to my earlier understanding?

Edit:

Here is some R Code for the sort of model I describe, and the resulting output.

require(lme4)
require(lmerTest)
require(data.table)

Subject <- rep(1:30, each = 12)
Item <- rep(1:12, times = 30)
IV1 <- rep(rep(c("A", "B"), each = 6), times = 10)
IV2 <- rep(c("A", "B"),times = 180)
DV <- sample(c(0,1), replace = TRUE, size = 360)

data <- as.data.table(cbind(Subject, Item, IV1, IV2, DV))

data$$IV1 <- as.factor(data$$IV1)
data$$IV2 <- as.factor(data$$IV2)
data$$DV <- as.factor(data$$DV)

contrasts(data$$IV1) <- c(1, -1) contrasts(data$$IV2) <- c(1, -1)

m <- glmer(DV ~ IV1*IV2 + (1|Subject) + (1|Item), family = "binomial", data = data)
summary(m)


Resulting output:

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: binomial  ( logit )
Formula: DV ~ IV1 * IV2 + (1 | Subject) + (1 | Item)
Data: data

AIC      BIC   logLik deviance df.resid
507.5    530.8   -247.7    495.5      354

Scaled residuals:
Min      1Q  Median      3Q     Max
-1.1435 -1.0000  0.8745  0.8745  1.0690

Random effects:
Groups  Name        Variance Std.Dev.
Subject (Intercept) 1e-12    1e-06
Item    (Intercept) 0e+00    0e+00
Number of obs: 360, groups:  Subject, 30; Item, 12

Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept)  0.10075    0.10594   0.951    0.342
IV11         0.16751    0.10594   1.581    0.114
IV21        -0.03338    0.10594  -0.315    0.753
IV11:IV21    0.03338    0.10594   0.315    0.753

Correlation of Fixed Effects:
(Intr) IV11   IV21
IV11       0.008
IV21       0.001 -0.001
IV11:IV21 -0.001  0.001  0.008


The interaction term does what you said, it estimates the interaction between A and B. For continuous variables this means that you have one slope for these two variables, which tells you how the effect changes with varying A and B.

When you have two discrete variables, you get as many terms ("slopes") as there are levels, since these two variables can only change in discrete values, and so you cannot get only 1 term out as you would in the continuous case.

Similarly to testing whether a factor has all terms equal to some value (say 0), you would then use an ANOVA on the linear model to test whether the interaction (or factor variable) is significant overall, because you have to group all the levels together.

Edit: in your case you do get only 1 term/coefficient for the interaction, that represents the interaction for the only other non-reference level, B in your case. So that is the difference of the effect of B, compared to A.

Note: I don't know why you changed the contrasts, but if you keep them original it will be more clear.

Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.09125    0.22119  -0.413    0.680
IV1B         0.41253    0.30400   1.357    0.175
IV2B        -0.23022    0.30383  -0.758    0.449
IV1B:IV2B   -0.27381    0.42998  -0.637    0.524


(Intercept) is the effect of A of IV1 and A of IV2
IV11 is the effect of B of IV1, compared to A of IV1
IV21 is the effect of B of IV2, compared to A of IV2
IV11:IV21 is the effect of B of IV1 and B of IV2, compared to A of IV1 and A of IV2