I have a dataframe containing four columns:
Participants are crossed with both factors.
Here is a very limited simulated example for structure, not simulating expected (random) effects:
df <- data.frame(ID = rep(1:10, each = 6),
F1 = factor(rep(c("A","B"), n = 30)),
F2 = factor(rep(c("C","D","E"), each = 2, n = 10)),
score = rnorm(60, mean = 4, sd = 0.8))
ID F1 F2 score
1 1 A C 4.066147
2 1 B C 3.613192
3 1 A D 3.897367
4 1 B D 3.612968
5 1 A E 3.157702
6 1 B E 3.707172
7 2 A C 2.984475
8 2 B C 4.488807
9 2 A D 4.711186
10 2 B D 3.774878
Considering that this is just an example and that the real dataset is fitted for mixed modelling, I want to look at the F1 * F2 interaction using the lme4 and lmerTest packages, using contrast coding:
contrasts(df$F1) <- c(-1/2,1/2)
contrasts(df$F2) <- matrix(c(-2/3,1/3,1/3,
0,-1/2,1/2),
ncol = 2)
library(lme4)
library(lmerTest)
model <- lmer(score ~ F1 * F2 + (1 | ID), data = df)
From here, I can look at the results using anova(), giving me the omnibus effects:
anova(model)
Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
F1 1.59711 1.59711 1 45 2.3893 0.1292
F2 1.17285 0.58642 2 45 0.8773 0.4229
F1:F2 0.39331 0.19666 2 45 0.2942 0.7466
However, when trying to get the effect sizes with r2beta() from r2glmm, I only get the effect sizes of specific contrasts:
library(r2glmm)
r2beta(model)
Effect Rsq upper.CL lower.CL
1 Model 0.119 0.435 0.052
2 F11 0.064 0.286 0.000
3 F21 0.042 0.249 0.000
6 F11:F22 0.012 0.181 0.000
4 F22 0.006 0.163 0.000
5 F11:F21 0.005 0.157 0.000
Is there a way to get effect sizes for the omnibus tests using r2glmm? I know it is possible with effectsize and the eta_squared() function, but both packages have a very different approach to compute effect sizes. I would like to stick with r2glmm as much as possible to produce effect sizes in a similar fashion to previous work, but am open to other suggestions.
EDIT: It actually is possible to get omnibus effect sizes with r2glmm when using the GitHub version - the CRAN version has not been updated yet. See https://github.com/bcjaeger/r2glmm/issues/16#issue-1236836438
It actually is possible to get omnibus effect sizes with r2glmm when using the GitHub version - the CRAN version has not been updated yet. See https://github.com/bcjaeger/r2glmm/issues/16#issue-1236836438