8
$\begingroup$

I have a dataset of 12 days of diary data. I am trying to use lme to model the effect of sleep quality on stress, with random intercept effects of participant and random slope effect of sleep quality. I am not particularly interested in asking whether there was change over time from diaryday 1 to 12, just in accounting for the time variable.

I'm much more familiar with lme4 for multilevel models, but given my diary data structure, it seemed important to account for temporal autocorrelations in variance.

I've tried following model syntax from here, but I'm not totally clear on what the syntax actually means.

My question: What exactly does the syntax of correlation = corAR1(form = ....) specify? What is the difference between the corAR1 syntax I have written in the two following models?

Model 1:

lme(stress_diary ~ sleepquality_diary + time.diary + diaryday + sex, 
data = data_diary,
random = ~ 1 + sleepquality_diary| randomid, 
correlation = corAR1(form = ~ diaryday | randomid), #What exactly am I specifying?
na.action=na.exclude)

Model 2:

lme(stress_diary ~ sleepquality_diary + time.diary + diaryday + sex, 
data = data_diary,
random = ~ 1 + sleepquality_diary| randomid, 
correlation = corAR1(), #What exactly am I specifying?
na.action=na.exclude)

Variables key: stress_diary = a value from 1 to 5 sleepquality_diary = a value from 1 to 5 time.diary = time of day of response, from 00:00 (midnight) diaryday = day of response, 1:12 sex = M,F randomid = participant

I am quite new to time series and longitudinal diary data, so I know I am missing some of the intuitions.

$\endgroup$
1
  • $\begingroup$ corAR1() is the simplest correlation structure affecting only the intercept, corAR1(form = ~ diaryday | randomid) is specifying a correlation structure based on randomid (that is a different correlation structure for every randomid) which has an effect on both the intercept and the slope of the diaryday variable. $\endgroup$ Commented Sep 21, 2018 at 6:35

1 Answer 1

9
$\begingroup$

The AR1 structure specifies that the correlations between the repeated measurements of each subject decrease with the time lag, i.e., the distance in time between the measurements.

When you specify lme(..., correlation = corAR1()) this is equivalent to lme(..., correlation = corAR1(form = ~ 1 | id)) and assumes that the measurements are equally spaced.

When instead you specify lme(..., correlation = corAR1(form = ~ time | id)) you use the time variable time to determine how far apart the measurements are, and define the time lag. Note, however, that corAR1() works with discrete time. There is also corCAR1() that works with continuous time.

$\endgroup$

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.