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.
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$