Specifying models nested crossed random effects
Josh, Thanks for the questions. Can you provide a little bit more description about the variables? Does "site" = "program"? Are participants queried at multiple timepoints? If pre- and post-program, could this be included as a factor with levels "before" and "after"? Do you have any particular hypotheses or questions you want to answer with your model? Best wishes, Evan On Sat, Apr 8, 2017 at 11:27 AM, Joshua Rosenberg <
jmichaelrosenberg at gmail.com> wrote:
Hi r-sig-mixed-models,
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
different programs)
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
<http://stats.stackexchange.com/questions/96600/
interactions-between-random-effects>
(and
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).
Doe?s ?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.
Josh
--
Joshua Rosenberg, Ph.D. Candidate
Educational Psychology and Educational Technology
Michigan State University
http://jmichaelrosenberg.com
[[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Evan Palmer-Young PhD candidate Department of Biology 221 Morrill Science Center 611 North Pleasant St Amherst MA 01003 https://sites.google.com/a/cornell.edu/evan-palmer-young/ epalmery at cns.umass.edu ecp52 at cornell.edu [[alternative HTML version deleted]]