I fit a mixed model using lmer
of the lme4
package in R
. Using lmerTest::anova
I can get the sums of squares for fixed effects I have included in my model. Unfortunately, the total sums of squares (SSTO) and the error sums of squares (SSE) are not provided. Is there a way to obtain these values? I am including a contrived dataset below for checking solutions.
# libraries
library(lme4)
library(lmerTest)
# factors
fixed <- c(rep('a', 4), rep('b', 4))
random <- c('r1', 'r1', 'r2', 'r2', 'r3', 'r3', 'r4', 'r4')
# constructing response variable
fixed_effect <- ifelse(fixed == 'a', 1, 2)
random_effect <- as.numeric(gsub('r', '', random))
error <- rnorm(length(fixed))
y <- fixed_effect + random_effect + error
# modeling
mod <- lmer(y ~ fixed + (1|random))
anova(mod) # only provides sums of squares for fixed effects