# [R] How to analyse simple study: Placebo-controlled (2 groups) repeated measurements (ANOVA, ANCOA???)

Frank E Harrell Jr f.harrell at vanderbilt.edu
Thu May 17 14:29:08 CEST 2007

```Karl Knoblick wrote:
> Hallo!
>
> I have two groups (placebo/verum), every subject is measured at 5 times, the first time t0 is the baseline measurement, t1 to t4 are the measurements after applying the medication (placebo or verum). The question is, if there is a significant difference in the two groups and how large the differnce is (95% confidence intervals).
>
> Let me give sample data
> # Data
> ID<-factor(rep(1:50,each=5)) # 50 subjects
> GROUP<-factor(c(rep("Verum", 115), rep("Placebo", 135)))
> TIME<-factor(rep(paste("t",0:4,sep=""), 50))
> set.seed(1234)
> Y<-rnorm(250)
> # to have an effect:
> Y[GROUP=="Verum" & TIME=="t1"]<-Y[GROUP=="Verum" & TIME=="t1"] + 0.6
> Y[GROUP=="Verum" & TIME=="t2"]<-Y[GROUP=="Verum" & TIME=="t2"] + 0.3
> Y[GROUP=="Verum" & TIME=="t3"]<-Y[GROUP=="Verum" & TIME=="t3"] + 0.9
> Y[GROUP=="Verum" & TIME=="t4"]<-Y[GROUP=="Verum" & TIME=="t4"] + 0.9
> DF<-data.frame(Y, ID, GROUP, TIME)
>
> I have heard of different ways to analyse the data
> 1) Comparing the endpoint t4 between the groups (t-test), ignoring baseline

Don't even consider this

> 2) Comparing the difference t4 minus t0 between the two groups (t-test)

This is not optimal

> 3) Comparing the endpoint t4 with t0 as a covariate between the groups (ANOVA - how can this model be calculated in R?)

Using t0 as a covariate is the way to go.  A question is whether to just
use t4.  Generally this is not optimum.

> 4) Taking a summary score (im not sure but this may be a suggestion of Altman) istead of t4
> 5) ANOVA (repeated measurements) times t0 to t5, group placebo/verum), subject as random factor - interested in interaction times*groups (How to do this in R?)
> 6) as 5) but times t1 to t5, ignoring baseline (How to do this in R?)
> 7) as 6) but additional covariate baseline t0 (How to do this in R?)
>
> How to analyse these models in R with nested and random effects and possible covariate(ID, group - at least I think so) and random parameter ID)? Or is there a more simple possibility?

It's not obvious that random effects are needed if you take the
correlation into account in a good way.  Generalized least squares using
for example an AR1 correlation structure (and there are many others) is
something I often prefer.  A detailed case study with R code (similar to
your situation) is in http://biostat.mc.vanderbilt.edu/FrankHarrellGLS .
This includes details about why t0 is best to consider as a covariate.
One reason is that the t0 effect may not be linear.

If you want to focus on t4 it is easy to specify a contrast (after
fitting is completed) that tests t4.  If time is continuous this
contrast would involve predicted values at the 4th time, otherwise
testing single parameters.

Frank Harrell

>
> Perhaps somebody can recommend a book or weblink where these different strategies of analysing are discussed - preferable with examples with raw data which I can recalculate. And if there is the R syntax includede - this would be best!
>
> Any help will be appreciate!
>
> Thanks!
> Karl

--
Frank E Harrell Jr   Professor and Chair           School of Medicine
Department of Biostatistics   Vanderbilt University

```