Help structure linear mixed effects model random effects structure


Nesting random effects models hurts my head.


I want to identify if there is an effect of 1) age, 2) task condition in an eye tracking task on a longitudinal sample.


There are 8 trials with half a pixelated and unpixelated version of 4 videos in the eye tracking task

Task Variables: TrialOrder (Dummy: 0 - 8), Content (Dummy: 0 - 4), Social/Nonsocial (Dummy: 0,1)

Infants came in at different ages over 1 - 6 visits spanning 2 - 50 months

We had about 250 infants with 750 recordings (~ 200 with 500 recording after data quality assurance)

Participant Variable: Age(Continuous), SexM (Dummy: 0,1)

Each recording had an associated data quality measure to ensure effects are not spuriously acocunted for by noise or missing data etc

Data Quality: %ValidData (Continuous), Accuracy (Continuous), Precision (Continuous)


Given it is repeated measures I believe this is required, plus it provides indepedent intercepts for individual...


Saccade Amplitude ~ Age + SexM + TrialOrder + Content + Social/Nonsocial + %ValidData + Accuracy + Precision + (1 | ID)

and if I think participants might have different different slopes

Saccade Amplitude ~ Age + SexM + TrialOrder + Content + Social/Nonsocial + %ValidData + Accuracy + Precision + (age | ID)


Now how do I integrate the multiple trials within a recording?


Saccade Amplitude ~ Age + SexM + TrialOrder + Content + Social/Nonsocial + %ValidData + Accuracy + Precision + (age | ID) + (1 | trials)
Saccade Amplitude ~ Age + SexM + TrialOrder + Content + Social/Nonsocial + %ValidData + Accuracy + Precision + (age + trials | ID)


or... nesting...

uhhhhh....


Saccade Amplitude ~ Age + SexM + TrialOrder + Content + Social/Nonsocial + %ValidData + Accuracy + Precision + (trials | age /ID)


Please also include reasoning on why nesting works... the way it should...


(Im using lme4/glmmTMB in R for my analysis)
  • Kav10 Kav10
    0

    Low bounty!

    • I second that. The offered bounty is low for the level of the question.

Answer

Answers can be viewed only if
  1. The questioner was satisfied and accepted the answer, or
  2. The answer was disputed, but the judge evaluated it as 100% correct.
View the answer
Kav10 Kav10
1.7K
  • Hi Kav10, I think you are considering trial/ recording/visit differently than I do. Bob has a visit at 3, 10, 12 month,s with an eye tracking recording at each, consisting of 8 trials Sally has a visit at 12, 18, 24, 32 months... etc Given the variability in age at each visit and number of visits, age is taken to be the analog for visit. Thus wouldnt trial be within age. How would that update your formulae. Thank you.

  • To clarify, I have "Recording" variable in question originally outlined question. I use the term "trial" to for the 8 elements of a the stimuli presented. "Visits" (not previously mentioned) range from 1 to 6 but occur at vastly different ages such that I believe they are meaningless. "Age" is the quasi visit measure. So am I looking at (trial|age/ID)?

    • I *donot* have "Recording" variable in question originally outlined question.

    • That is trials nested in age when measures occured within ID.

    • Kav10 Kav10
      0

      My understanding was that trial is different from recording. Meaning that infants are brought to participate in this study, there were multiple trials, within each, there were multiple recordings. I got it from where you mentioned there were 200 infants with 750 recordings.

    • Kav10 Kav10
      0

      Isn’t that correct?

  • Kav10 Kav10
    0

    So, trial is different that recording, correct?

    • Yes... data would look like Age 3mo Bob, median saccade latency for each ... trial 1,2,3,4,5,6,7,8 Age 5mo Bob, median saccade latency trial for each... 1,2,3,4,5,6,7,8 ... Age 12mo Bob, median saccade latency for each.... trial 1,2,3,4,5,6,7,8 Age 15 mo Sally, median saccade latency for each... trial 1 2 3 4 5 6 7 8 .. .

  • Kav10 Kav10
    0

    Where is the recording? How do you show the 750 recordings? Did you mean 750 records instead of recording?

    • Yes... records... observations.... 200 babies + 6 visits + lots of missing data = 700 ... observations

    • Kav10 Kav10
      0

      OK, so that was the confusing piece. Observations. I see. For recording, I thought you meant something like video recordings.

  • Kav10 Kav10
    0

    If age is serving as the analog for visit and you want to include trials within each age/visit, you can include a random effect for trials nested within age/visit. Here are the two possible model formulations: Saccade Amplitude ~ Age + SexM + TrialOrder + Content + Social/Nonsocial + %ValidData + Accuracy + Precision + (age | ID) + (1 | trials:age:ID)

    • I think this is getting closer! You said two possible models and I see one.

    • I ask because I still wonder about my proposed (trial| age/ID) which I dont understand exactly how it is different than (1|trial:age:ID). After all we are doing (age|ID)is understood and we are not using (1|age:ID).

    • Kav10 Kav10
      0

      The model (trial|age/ID) would indicate that trials are nested within age and that age is nested within each ID. This is different from the model specification (1|trials:age:ID), which indicates that trials are nested within age, which is nested within ID. Again, the difference between the two model specifications would depend on the structure of your data and the research question you are trying to answer.

    • Kav10 Kav10
      0

      If you believe that trial effects are specific to each age/visit, then (trial|age/ID) would be more appropriate. If you believe that trial effects are constant across age/visit, then (1|trials:age:ID) may be more appropriate. It may be helpful to try out different model specifications and compare their fit and interpretability.

    • Thats a helpful breakdown between the two!

    • Kav10 Kav10
      0

      Glad it was helpfulz

  • Kav10 Kav10
    0

    Here is the second one: Saccade Amplitude ~ Age + SexM + TrialOrder + Content + Social/Nonsocial + %ValidData + Accuracy + Precision + (age + 1 | ID) + (1 | trials:age)

    • Kav10 Kav10
      0

      Both models include a random intercept for ID and a fixed effect for age, sex, trial order, content, social/nonsocial, and data quality measures. The first model includes a random intercept for trials nested within age/visit and a random slope for age within each individual. The second model includes a random intercept for trials nested within age/visit and a random slope for age and a random intercept for each individual. The R syntax should be very similar to what I provided before.

  • Thank you for sticking in there with me!

    • Kav10 Kav10
      0

      Of course! I am glad I was able to help.

The answer is accepted.
Join Matchmaticians Affiliate Marketing Program to earn up to 50% commission on every question your affiliated users ask or answer.