I have a data set including four variables (ID,Time, group, result) in the following format. I want to see if the result (such as Calcium) change over time in different group or not. I was wondering what is the right statistical model to use? Can I use two way mixed anova for this analysis?

> Id     time   group     Result 
  1        0       0      
  1        1       0
  1        2       0
  2        0       1
  2        1       1
  2        2       1
  3        0       0
  3        1       0
  3        2       0    

Also, I am confused between choosing aov with Error(ID/Time) and lmer with (Time|ID)? Which one I need to choose?


In case you have a balanced design in which all subjects only have measurements on specific time points, and provided that you have a moderate number of subjects, the best you could do is to fit a marginal model with an unstructured covariance matrix, e.g., using function gls() from package nlme. In your case, something like

fm <- gls(Result ~ time * group, data = <your_data>, correlation = corSymm(form = ~ 1 | Id), weights = varIdent(form = ~ 1 | time))

  • $\begingroup$ What is the required number of repeats in order to use gls? Forexample, can I use it if I have more than 3 time points in my data set? Also do I need to check the Sphericity assumption if I want to apply your suggestion? $\endgroup$ – stat Aug 31 '18 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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