Karl Knoblick
2007-May-17 12:16 UTC
[R] How to analyse simple study: Placebo-controlled (2 groups) repeated measurements (ANOVA, ANCOA???)
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 2) Comparing the difference t4 minus t0 between the two groups (t-test) 3) Comparing the endpoint t4 with t0 as a covariate between the groups (ANOVA - how can this model be calculated in R?) 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?) What will be best? - (Advantages / disadvantages?) 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? 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
2007-May-17 12:29 UTC
[R] How to analyse simple study: Placebo-controlled (2 groups) repeated measurements (ANOVA, ANCOA???)
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 baselineDon'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?) > > What will be best? - (Advantages / disadvantages?) > 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 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
Karl Knoblick
2007-May-30 11:53 UTC
[R] How to analyse simple study: Placebo-controlled (2 groups) repeated measurements (ANOVA, ANCOA???)
Dear Frank Harrell, many thanks for your answers!!! I have downloaded your Harrell_notes.pdf and I think it would be best to have a look in some books you mentioned in the bibliographie. Can you recommend one especially? TO ANYBODY: Has anybody examples for similar data sets (as below) with R code? This would be a great help! (My impression of the example of Frank Harrell at the end of Harrell_notes.pdf is that it is more complicated and therefore more difficult to understand than the simplier data set I want to analyse.) Thanks!!! Karl ----- Urspr?ngliche Mail ---- Von: Frank E Harrell Jr <f.harrell at vanderbilt.edu> An: Karl Knoblick <karlknoblich at yahoo.de> CC: r-help at stat.math.ethz.ch Gesendet: Donnerstag, den 17. Mai 2007, 14:29:08 Uhr Betreff: Re: [R] How to analyse simple study: Placebo-controlled (2 groups) repeated measurements (ANOVA, ANCOA???) 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 baselineDon'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?) > > What will be best? - (Advantages / disadvantages?) > 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 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 __________________________________ Yahoo! Clever: Stellen Sie Fragen und finden Sie Antworten. Teilen Sie Ihr Wissen. yahoo.de/clever