[R-sig-ME] Specifying models nested crossed random effects
jmichaelrosenberg at gmail.com
Sat Apr 8 17:27:19 CEST 2017
I am new to the group and have a question about crossed random effects for
student, sample, and program sources of variation.
In my study of out-of-school programs, our outcomes are continuous measures
of participant's interest and engagement (we envision that different
outcomes will be analyzed as part of separate models).
In specific, our data consists of:
- About 20 individuals per program
- About 10 programs
- Within each site, about 20 samples (the samples were at the same time
for all of the individuals within the program, but at different times at
Because there are dependencies by both participant, sample, and program, we
think there are two crossed random effects, one for observations associated
with each individual, and one for observations associated with each sample.
Both of these random effects are nested in one of the 10 programs.
The data look like the following:
# A tibble: 2,970 × 4
overall_engagement participant_ID program_ID sample_ID
<dbl> <fctr> <fctr> <fctr>
1 2.833333 1001 1 1-2015-07-14-1
2 2.833333 1001 1 1-2015-07-14-2
3 2.500000 1001 1 1-2015-07-15-1
4 2.333333 1001 1 1-2015-07-15-2
5 3.000000 1001 1 1-2015-07-21-1
6 2.666667 1001 1 1-2015-07-21-2
7 3.000000 1001 1 1-2015-07-21-4
8 3.166667 1001 1 1-2015-07-22-1
9 3.833333 1001 1 1-2015-07-22-4
10 3.000000 1001 1 1-2015-07-28-1
# ... with 2,960 more rows
Our understanding from the nested or crossed section of the FAQ and the
answer to this question is that because we have unique variables do have
unique values of the sample, there seem to be two options for how we can
specify the model using the lme4 package in R:
1. Not nesting the crossed random effects within the site because the
sample variable includes a site identifier:
lmer(interest ~ 1 + (1|participant_ID) + (1|sample_ID), data = df)
2. Creating the sample variable without a site identifier but in a way so
that samples within each site were still identified uniquely and nesting
the crossed random effects within the site:
lmer(interest ~ 1 + (1|site/participant_ID) + (1|site/sample), data = df)
Based on this question
some example models where this seemed to work), we were also curious about
adding an interaction (to option 1 or option 2) between participant_ID
and sample_ID by adding a random effect via (1|participant_ID:sample_ID).
Does either of these seem like they would help to account for
dependencies by participant, sample, and program?
Please let me know if more information (or less!) would be helpful. Thank
you for considering this.
Joshua Rosenberg, Ph.D. Candidate
Educational Psychology and Educational Technology
Michigan State University
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models