lundi 19 juin 2017

Interpreting random effects in lme4 package

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 goes through 3 conditions (Group). In each conditions there are 20 trials (Task). We measure Accuracy and reaction time. In the modeling we want to predict Accuracy from RT, controlling for random effects in 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, 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 independantly of Group variable or not?

Thanks!




Aucun commentaire:

Enregistrer un commentaire