Skip to main content
QUICK REVIEW

[Paper Review] Using R formulae to test for main effects in the presence of higher-order interactions

Roger Lévy|arXiv (Cornell University)|May 8, 2014
Data Analysis with RComputer Science48 citations
TL;DR

This paper presents a method for testing main effects of factors in the presence of higher-order interactions using R formulae, particularly in mixed-effects models. By converting factors to sum-coding numeric contrasts and comparing nested models with and without the main effect, researchers can test for significant main effects even when interactions are present, ensuring correct statistical inference in modern regression frameworks.

ABSTRACT

Traditional analysis of variance (ANOVA) software allows researchers to test for the significance of main effects in the presence of interactions without exposure to the details of how the software encodes main effects and interactions to make these tests possible. Now that increasing numbers of researchers are using more general regression software, including mixed-effects models, to supplant the traditional uses of ANOVA software, conducting such tests generally requires greater knowledge of how to parameterize one's statistical models appropriately. Here I present information on how to conduct such tests using R, including relevant background information and worked examples.

Motivation & Objective

  • To address the challenge of testing main effects when higher-order interactions are present in regression models.
  • To provide a practical method for researchers using R to test main effects in mixed-effects models where traditional ANOVA tools are insufficient.
  • To clarify the interpretation of main effects in the presence of interactions, especially when predictors are coded with sum-to-zero contrasts.
  • To offer a generalizable, reproducible approach using model comparison via likelihood ratio tests in lme4 and lm.
  • To bridge the gap between traditional ANOVA and modern regression-based inference in experimental design.

Proposed method

  • Convert a K-level factor Y into K-1 numeric contrast variables using sum-coding (contr.sum) to represent its main effect in the model.
  • Construct a reduced model that includes Y's contrast variables and their interactions with X, but excludes the main effect of X.
  • Construct a full model that includes the main effect of X, Y's contrasts, and all X:Y interactions.
  • Use likelihood ratio tests (LRT) to compare the reduced and full models, with the test statistic assessing the significance of the main effect of X.
  • Apply the method in both linear models (lm) and mixed-effects models (lmer) with crossed random effects for subjects and items.
  • Ensure maximal random effects structure in mixed models to avoid Type I error inflation, including random slopes for all fixed effects.

Experimental results

Research questions

  • RQ1How can one test for a main effect of a factor X when it interacts with another factor Y in a regression model?
  • RQ2What is the correct way to parameterize a model in R to test for a main effect of X when interactions are present?
  • RQ3Why does the interpretation of a main effect of X depend on the coding of Y, especially when Y is a factor?
  • RQ4How can likelihood ratio tests be used to assess the significance of main effects in mixed-effects models with crossed random effects?
  • RQ5What role do contrast coding schemes like sum-coding play in ensuring valid interpretation of main effects in the presence of interactions?

Key findings

  • The likelihood ratio test comparing a model without the main effect of X to one with it showed no significant main effect (p = 0.752) in the mixed-effects model, indicating no evidence for a main effect of X.
  • In the linear model example, the F-test for the main effect of X was non-significant (F = 0.845, p = 0.367), consistent with the LRT result.
  • The method successfully reproduces traditional ANOVA results when using aov(), confirming its validity in standard designs.
  • Using sum-coding (contr.sum) ensures that the main effect of X represents the average effect across all levels of Y, which is the intended interpretation.
  • The approach is robust across model types, including both fixed-effects and mixed-effects models with crossed random effects for subjects and items.
  • The paper demonstrates that the main effect of X is not equivalent to its marginal effect when Y is not centered or coded with sum contrasts, highlighting the importance of proper contrast coding.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.