I need specify a model using lmer() with data (n > 3500) in which there is a lot of variability in the age of the (human) subjects and also the duration between measurements (5 measurements total but a lot of subjects have missing data for multiple measurements). The outcome measure is a cognitive performance assessment on a tablet, and there is a grouping factor (A vs B) that is of interest. This is what the data look like:

id   gender  group  org time age score
1      2      0.5     1    1  57    37
1      2      0.5     1    2  57    44
1      2      0.5     1    3  62    47
1      2      0.5     1    4  NA    NA
1      2      0.5     1    5  NA    NA
2      1     -0.5     3    1  58    56
2      1     -0.5     3    2  61    60


The data are messy but I'm looking to make use of most of it instead of trying to impose some order and losing half or more of the data in the process. I want to test whether there are group differences in how performance changes with repeat testing, such that the A group scores better after more testing, which could be indicative of more strategy use or learning, or motivation. To complicate things further, the subjects are nested within organizations that administered the testing.

There are two ways I'm thinking I could model this. One is like this:

lmer(score ~ time * group + age + gender + (time | org/id) 

The other would be to create multiple change scores (e.g., time2-time1, time3-time4, etc.) and create a new 'time' variable that would indicate whether it was the first change score, second, third, etc. I'd also create a 'duration' variable to control for variability in the duration between the two time points related to the change score. I'd also control for age at time 1. The model would be something like:

lmer(change_score ~ time * group + age_at_time1 + duration_betw_timepoints + gender + (change_score | org/id) 

The 'compact' model for each of these would not include the interaction term. The idea is to test whether there are group differences in how performance changes with repeat testing (first model above) OR group differences in growth (second model). What I'm not sure of is whether any of what I'm proposing is ok. It makes sense to me but maybe it's not the right way to model this kind of data?


1 Answer 1


I don't think your second model is the best way to deal with this problem. I do think you are on to something with regards to accounting for the amount of time elapsed between measurements. Right now, you have "time" coded as 1-5, but as you mentioned that's likely not appropriate because the amount of (real world) time elapsed between measurement 1 and measurement 2 may not be the same from one participant to another.

Do you have access to the raw data? You could calculate the true elapsed time (e.g in days) as a new variable called "days," which would start at 0 and increment up.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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