3
$\begingroup$

Problem

There are two excellent CV posts on specifying crossed effects models (post 1, post 2).

The issue I'm trying to wrestle with pertains to part of the answer to post 2, in particular how to nest crossed random effects.

In my study, I have:

  • About 20 individuals per site
  • About 10 sites
  • Within each site, there were about 20 samples

The outcome in the example is participant's "interest" (the study is about out-of-school programs).

Because there are dependencies by both participant and sample, I think there are two crossed random effects, one for observations associated with each individual, and one for observations associated with each sample. The hard part for me is that these random effects are nested in one of the 10 programs.

The samples were at the same time for all of the individuals within the site, but at different times at different sites, so that sample 1 in site A was not necessarily at the same time in any sense (not the same date / time nor at the same interval from the "start" of the site's activities). Therefore, to create the variable identifying the time of the sample, I combined the site variable, the date that the sample was collected, and another variable specifying whether the sample was the 1st, 2nd, 3rd, or 4th sample collected for that date. It's a factor.

The data (in R) are as follows:

# A tibble: 2,970 × 4
    interest participant_ID  site           sample
   <dbl+lbl>          <dbl> <chr>         <fctr>
1          2           1001     1 1-2015-07-14-1
2          2           1001     1 1-2015-07-14-2
3          4           1001     1 1-2015-07-15-1
4          3           1001     1 1-2015-07-15-2
5          3           1001     1 1-2015-07-21-1
6          1           1001     1 1-2015-07-21-2
7          3           1001     1 1-2015-07-21-4
8          3           1001     1 1-2015-07-22-1
9          4           1001     1 1-2015-07-22-4
10         3           1001     1 1-2015-07-28-1
# ... with 2,960 more rows

Possible Solution

In the answer to post 2, the author of the selected answer wrote:

Because you do not have unique values of the tow variable (i.e. because as you say below tows are specified as 1, 2, 3 at every station), you do need to specify the nesting, as (1|station:tow:day). If you did have the tows specified uniquely, you could use either (1|tow:day) or (1|station:tow:day) (they should give equivalent answers).

In mapping this to my example, I do have unique values of the sample (tow variable), I do not need to specify the nesting. I'm having trouble specifying this model mathematically, and, thus, in terms of model syntax. (I am using lme4 in R).

But, here seem to be the options:

  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), 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)

Other examples interact the crossed random effects, via adding a term such as (1|participant_ID:sample).

Does either of these seem like they would account for dependencies by both participant and sample? Or, are there other options or better ways to model this?

$\endgroup$
  • $\begingroup$ You are over-complicating this. You need a random effect of sample, of participant, and of site. So your option #1 is okay, but you should probably add (1|site) into there. Your option #2 is also fine, and you don't need to change anything about how you code your sample variable; (1|site/sample) is equivalent to (1|site)+(1|site:sample) and if your sample is coded like it is then this is further equivalent to (1|site)+(1|sample). The same goes for the participant term. So option #2 will be equivalent to #1 if you add the site term to #1 as I suggested above. $\endgroup$ – amoeba says Reinstate Monica Apr 13 '17 at 23:14
  • $\begingroup$ Whether you use (1|participant_ID:sample) is another issue. I would try fitting models with and without this term and see what comes out. $\endgroup$ – amoeba says Reinstate Monica Apr 13 '17 at 23:15
  • $\begingroup$ And one more thing: what do you actually expect the interest to depend upon? You are studying how the interest is influenced -- by what? I am asking because you don't have any fixed effects in your models, only random effects. That's strange. $\endgroup$ – amoeba says Reinstate Monica Apr 13 '17 at 23:23
  • 1
    $\begingroup$ It seems from running the models different ways that a unique sample identifier (for each prompt in each program) with a participant random effect and site random effect is the most straightforward way to go - and is equivalent, as you suggest, to a not unique sample identifier nested within a site random effect and a participant random effect. $\endgroup$ – Joshua Rosenberg Apr 15 '17 at 12:17
  • 1
    $\begingroup$ That's correct @Joshua (referring to your last comment). And an interaction term won't make sense if you have 1 observation per interaction combination. So the bottomline IMHO is that you should use (1|site) + (1|participant_ID) + (1|sample) and if the site term comes out with zero variance then so be it; but you cannot know in advance, so it makes sense to put it in the model anyway. $\endgroup$ – amoeba says Reinstate Monica Apr 15 '17 at 15:51
2
+50
$\begingroup$

Here's my read on what experiment was done and how I would model it.

Each observation has three identifiers and one value.

You stated that these identifiers are participant, site, and sample and the value is interest.

You explained to me that there are many levels of each of these identifiers and you expect measurements that have a common value of any one of them (same participant, same site or same sample) are likely to be more similar than observations that have none in common.

This sounds like a perfect situation for an LMM with random intercept for each of those factors. Thus, model I would fit would be:

lmer(formula = interest ~ (1|participant_ID) + (1|site) + (1|sample),
     data = df)

EDIT: deleted misunderstandings.

$\endgroup$
  • $\begingroup$ Thanks, there is a calendar-date-varying component of the observation (I wrote: The samples were at the same time for all of the individuals within the site, but at different times at different sites, so that sample 1 in site A was not necessarily at the same time in any sense (not the same date / time nor at the same interval from the "start" of the site's activities)). $\endgroup$ – Joshua Rosenberg Apr 14 '17 at 16:03
  • $\begingroup$ When I wrote "calendar-date-varying", what I meant was something like outdoor temperature, where what day of the year it is really matters (hotter in the summer, colder in the winter). I'm not hearing anything in your post to suggest that what day of the year it is matters to the measurement. That's why I dropped the date of the measurement in my analysis. $\endgroup$ – rcorty Apr 14 '17 at 16:05
  • $\begingroup$ Thank you, I am sorry that this was not clear, there is something important about day of the year - the samples were during different activities during after-school programs that exhibit a lot of variation (i.e., kids' interest is higher during certain calendar dates (and times) when doing hands-on group activities versus working individually). So, activities during the moment / time point are expected to be a source of variation. $\endgroup$ – Joshua Rosenberg Apr 14 '17 at 17:50
  • $\begingroup$ Okay, I would make another random effect for that, then. See edit above. $\endgroup$ – rcorty Apr 14 '17 at 18:28
  • 1
    $\begingroup$ discussed in chat and understand that three random effects for participant, site, and sample may be on right track, i.e. lmer(formula = interest ~ (1|participant_ID) + (1|site) + (1|sample), data = df) $\endgroup$ – Joshua Rosenberg Apr 15 '17 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.