I was dealing with the
lme4 package in R and was a bit confused with how to interpret the random effects in a following example:
library(dplyr) library(ggplot2) library(tidyr) library(lmerTest) setwd("F:/5_1 Analize/Article_2 - LMM/") dat <- data.frame( ID = rep(1:20, each = 60), Task = rep(1:60, each = 20), Group = rep(c("A","B","C"), each = 20), Accuracy = sample(c(0,1), size = 1200, replace = T), RT = sample(200:3000, size = 1200, replace = T) ) mod <- glmer(Accuracy~RT*Group + (1+RT|Task) + (1+RT|ID), data = dat, family = "binomial")
Basically, every participant (variable ID) goes through 3 conditions (Group). In each condition, there are 20 trials (Task; Task is each single trial a person goes through in the experiment - there are 60 trials, and all of them are different. First 20 are in condition/group A, next 20 in condition B, and last 20 in group C).
We measure Accuracy and reaction time. In the modeling we want to predict Accuracy from RT, controlling for random effects between subjects and tasks, both for intercepts and slopes. We also control for the fixed effect of the group.
The formula of the example can be described as:
Accuracy ~ (beta0 + b0ID + b0Task + betaGroup0) + (beta1 + b1ID + b1Task + betaGroup1)*RT
(b-random effects, beta - fixed effects)
My question is following:
1) When I run
coef(mod)$ID and look at the Intercept column - what do I see? Do I see random intercepts for each person across all three conditions (i.e., on all Tasks), or do I see random intercepts for each person for Group A? My idea is the second one. If that is true, how can I get an average random person intercept for all three groups?
2) When I run
coef(mod)$Task and also look at Intercept column - do I see intercepts for each item independently of Group variable or not?