R nlme: how to run simple mixed model by studyid ID

I'm trying to run a simple mixed model by subject id: y=week. Since it's repeated measures, I assumed that I need to use mixed model to account for within subject variability, even though I want to run the model by subject id? In addition, since the measurements are equally spaced, I tried to use AR(1) covariance structure. However, my code: fm <- lme(y ~ week , correlation = corAR1(), data = test) didn't work and I don't know what's the problem.

I'm new to R and my questions are:

  1. How to run mixed model by study id, so that each model is for each participant?
  2. Since I want to run each model by study id, there is only within subject variability. Is nlme:lme with AR structure over complicated ?

here is my sample data:
R eg data

Thanks everyone's feedback, much appreciated!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.