Assuming the order of or association pattern among repeated measurements are available as a factor or continuous variable time
, you will need to decide whether it should be coded as 1–6, 1–24, or some other values where the distance between consecutive trials differ. AR(1) might be a good choice, but other alternative correlation structures require considering. For the trial index time
, we need its fixed effect as either a continuous or categorical variable.
The package {nlme} allows modeling random intercepts and coefficients along with AR process of the residual term, but it may not be necessary or significant for certain data. In the sleepstudy
data for example, if the variation by participant is controlled for, the residuals that represent the difference between predicted and observed reaction time may not present enough temporal correlation to necessitate error-correlation consideration. You can also use the package {glmmTMB} for some special error-correlation patterns.