Doran, Harold
2006-Oct-05 15:39 UTC
[R] treatment effect at specific time point within mixedeffects model
Hi David: In looking at your original post it is a bit difficult to ascertain exactly what your null hypothesis was. That is, you want to assess whether there is a treatment effect at time 3, but compared to what. I think your second post clears this up. You should refer to pages 224- 225 of Pinhiero and Bates for your answer. This shows how to specify contrasts.> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of > Afshartous, David > Sent: Thursday, October 05, 2006 11:08 AM > To: Spencer Graves > Cc: r-help at stat.math.ethz.ch > Subject: Re: [R] treatment effect at specific time point > within mixedeffects model > > Hi Spencer, > > Thanks for your reply. > I don't think this answers my question. > > If I understand correctly, your model simply removes the > intercept and thus the intercept in fm1 is the same as the > first time factor in fm1a ... but am I confused as to why the > other coefficient estimates are now different for the time > factor if this is just a re-naming. > The coefficient estimates for the interactions are the same > for fm1 and fm1a, as expected. > > But my question relates to the signifcance of drug at a > specific time point, e.g., time = 3. The coeffecieint for > say "factor(time)3:drugP" measures the interaction of the > effect of drug=P and time=3, which is not testing what I want > to test. Based on the info below, I want to compare 3) versus 4). > > 1) time=1, Drug=I : Intercept > 2) time=1, Drug=P : Intercept + DrugP > 3) time=3, Drug=I : Intercept + factor(time)3 > 4) time=3, Drug=P : Intercept + factor(time)3 + DrugP + > factor(time)3:drugP > > I'm surprised this isn't simple or maybe I'm missing > something competely. > > thanks > dave > > > > > > -----Original Message----- > From: Spencer Graves [mailto:spencer.graves at pdf.com] > Sent: Wednesday, October 04, 2006 7:11 PM > To: Afshartous, David > Cc: r-help at stat.math.ethz.ch > Subject: Re: [R] treatment effect at specific time point > within mixed effects model > > Consider the following modification of your example: > > fm1a = lme(z ~ (factor(Time)-1)*drug, data = data.grp, random > = list(Patient = ~ 1) ) > > summary(fm1a) > <snip> > Value Std.Error DF t-value p-value > factor(Time)1 -0.6238472 0.7170161 10 -0.8700602 0.4047 > factor(Time)2 -1.0155283 0.7170161 10 -1.4163256 0.1871 > factor(Time)3 0.1446512 0.7170161 10 0.2017405 0.8442 > factor(Time)4 0.7751736 0.7170161 10 1.0811105 0.3050 > factor(Time)5 0.1566588 0.7170161 10 0.2184871 0.8314 > factor(Time)6 0.0616839 0.7170161 10 0.0860286 0.9331 > drugP 1.2781723 1.0140139 3 1.2605077 0.2966 > factor(Time)2:drugP 0.4034690 1.4340322 10 0.2813528 > 0.7842 factor(Time)3:drugP -0.6754441 1.4340322 10 -0.4710104 > 0.6477 factor(Time)4:drugP -1.8149720 1.4340322 10 > -1.2656424 0.2343 factor(Time)5:drugP -0.6416580 1.4340322 > 10 -0.4474502 0.6641 factor(Time)6:drugP -2.1396105 > 1.4340322 10 -1.4920240 0.1666 > > Does this answer your question? > Hope this helps. > Spencer Graves > > Afshartous, David wrote: > > > > All, > > > > The code below is for a pseudo dataset of repeated measures on > > patients where there is also a treatment factor called > "drug". Time > > is treated as categorical. > > > > What code is necessary to test for a treatment effect at a > single time > > > point, > > e.g., time = 3? Does the answer matter if the design is a > crossover > > design, > > i.e, each patient received drug and placebo? > > > > Finally, what would be a good response to someone that > suggests to do > > a simple t-test (paired in crossover case) instead of the > test above > > within a mixed model? > > > > thanks! > > dave > > > > > > > > z = rnorm(24, mean=0, sd=1) > > time = rep(1:6, 4) > > Patient = rep(1:4, each = 6) > > drug = factor(rep(c("I", "P"), each = 6, times = 2)) ## P = > placebo, I > > > = Ibuprofen dat.new = data.frame(time, drug, z, Patient) data.grp = > > groupedData(z ~ time | Patient, data = dat.new) > > fm1 = lme(z ~ factor(time) + drug + factor(time):drug, data = > > data.grp, random = list(Patient = ~ 1) ) > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Afshartous, David
2006-Oct-05 16:48 UTC
[R] treatment effect at specific time point within mixedeffects model
Hi Harold, Thanks for your response. I'll check out p.224 in P&B, thanks. The null hypothesis is that there is no difference between say A=[time=3, drug=I] and B=[time=3, drug=P], or mu_A = mu_B. If the study is a crossover design, i.e., each patient receives drug=I and drug=P, I assume that a simple paried t-test could also be employed at time=3. However, I'd like to test this within a mixed effects model; With respect to 3) and 4) below, it seems somewhat difficult to express this specific hypothesis in terms of the model paramaters. Ways in which this null are violated under the mixed effects models could be: 1) there is no interaction between time and Drug, i.e., there is a drug effect but it is the same at all time points. (the specific interaction in 3) below represents the shift of the effect of drug=P from time=1 to time=3 ... so the lack of significance of the paramater "factor(time)3:drugP" doesn't capture what I want) 2) there is neither interaction nor drug effect (variable Drug not significant). But both these violations are more general than my null; I think testing fixed effects 3) versus 4) below is what I want, but this also seems strange since possibly the drug effect and drug:time interaction as defined in the model are signicant (with time=1 as the reference baseline). Regardless, I assume I would need to employ coef() and vcov() to obtain the needed info ... but I notice that coef() produces 4 values for the intercept of fm1 below, does anyone know why this occurs? I apologize if my explanation above is confusing, I've tried to make it as clear as possible. thanks again, dave -----Original Message----- From: Doran, Harold [mailto:HDoran at air.org] Sent: Thursday, October 05, 2006 11:40 AM To: Afshartous, David; Spencer Graves Cc: r-help at stat.math.ethz.ch Subject: RE: [R] treatment effect at specific time point within mixedeffects model Hi David: In looking at your original post it is a bit difficult to ascertain exactly what your null hypothesis was. That is, you want to assess whether there is a treatment effect at time 3, but compared to what. I think your second post clears this up. You should refer to pages 224- 225 of Pinhiero and Bates for your answer. This shows how to specify contrasts.> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Afshartous, > David > Sent: Thursday, October 05, 2006 11:08 AM > To: Spencer Graves > Cc: r-help at stat.math.ethz.ch > Subject: Re: [R] treatment effect at specific time point within > mixedeffects model > > Hi Spencer, > > Thanks for your reply. > I don't think this answers my question. > > If I understand correctly, your model simply removes the intercept and> thus the intercept in fm1 is the same as the first time factor in fm1a> ... but am I confused as to why the other coefficient estimates are > now different for the time factor if this is just a re-naming. > The coefficient estimates for the interactions are the same for fm1 > and fm1a, as expected. > > But my question relates to the signifcance of drug at a specific time > point, e.g., time = 3. The coeffecieint for say "factor(time)3:drugP"> measures the interaction of the effect of drug=P and time=3, which is > not testing what I want to test. Based on the info below, I want to > compare 3) versus 4). > > 1) time=1, Drug=I : Intercept > 2) time=1, Drug=P : Intercept + DrugP > 3) time=3, Drug=I : Intercept + factor(time)3 > 4) time=3, Drug=P : Intercept + factor(time)3 + DrugP + > factor(time)3:drugP > > I'm surprised this isn't simple or maybe I'm missing something > competely. > > thanks > dave > > > > > > -----Original Message----- > From: Spencer Graves [mailto:spencer.graves at pdf.com] > Sent: Wednesday, October 04, 2006 7:11 PM > To: Afshartous, David > Cc: r-help at stat.math.ethz.ch > Subject: Re: [R] treatment effect at specific time point within mixed > effects model > > Consider the following modification of your example: > > fm1a = lme(z ~ (factor(Time)-1)*drug, data = data.grp, random = > list(Patient = ~ 1) ) > > summary(fm1a) > <snip> > Value Std.Error DF t-value p-value > factor(Time)1 -0.6238472 0.7170161 10 -0.8700602 0.4047 > factor(Time)2 -1.0155283 0.7170161 10 -1.4163256 0.1871 > factor(Time)3 0.1446512 0.7170161 10 0.2017405 0.8442 > factor(Time)4 0.7751736 0.7170161 10 1.0811105 0.3050 > factor(Time)5 0.1566588 0.7170161 10 0.2184871 0.8314 > factor(Time)6 0.0616839 0.7170161 10 0.0860286 0.9331 > drugP 1.2781723 1.0140139 3 1.2605077 0.2966 > factor(Time)2:drugP 0.4034690 1.4340322 10 0.2813528 > 0.7842 factor(Time)3:drugP -0.6754441 1.4340322 10 -0.4710104 > 0.6477 factor(Time)4:drugP -1.8149720 1.4340322 10 > -1.2656424 0.2343 factor(Time)5:drugP -0.6416580 1.4340322 10 > -0.4474502 0.6641 factor(Time)6:drugP -2.1396105 > 1.4340322 10 -1.4920240 0.1666 > > Does this answer your question? > Hope this helps. > Spencer Graves > > Afshartous, David wrote: > > > > All, > > > > The code below is for a pseudo dataset of repeated measures on > > patients where there is also a treatment factor called > "drug". Time > > is treated as categorical. > > > > What code is necessary to test for a treatment effect at a > single time > > > point, > > e.g., time = 3? Does the answer matter if the design is a > crossover > > design, > > i.e, each patient received drug and placebo? > > > > Finally, what would be a good response to someone that > suggests to do > > a simple t-test (paired in crossover case) instead of the > test above > > within a mixed model? > > > > thanks! > > dave > > > > > > > > z = rnorm(24, mean=0, sd=1) > > time = rep(1:6, 4) > > Patient = rep(1:4, each = 6) > > drug = factor(rep(c("I", "P"), each = 6, times = 2)) ## P > placebo, I > > > = Ibuprofen dat.new = data.frame(time, drug, z, Patient) data.grp = > > groupedData(z ~ time | Patient, data = dat.new) > > fm1 = lme(z ~ factor(time) + drug + factor(time):drug, data = > > data.grp, random = list(Patient = ~ 1) ) > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Afshartous, David
2006-Oct-06 16:51 UTC
[R] treatment effect at specific time point within mixedeffects model
-----Original Message----- From: Chuck Cleland [mailto:ccleland at optonline.net] Sent: Friday, October 06, 2006 5:32 AM To: Afshartous, David Subject: Re: [R] treatment effect at specific time point within mixedeffects model Afshartous, David wrote:> The data structure is a repeated measures crossover design, i.e., N > patients measured at 6 time points, each on drug and placebo; thus no > clustering of individuals within groups > if I understand you correctly.David: That is not the same as the structure of data.grp, where there is no crossover. I believe this makes drug a within-subjects effect in the mixed model. In the simple t-test, drug is essentially a between-subjects effect since only one time is considered. If I understand correctly, the simple t-test is an independent sample t-test since at a particular time each subject serves in only one drug condition. <DA> sorry, the pseudo data of data.grp should have had crosover. RE the t-test, a paired t-test would account for the dependence.> I just ran the mixed model w/ the new contrast coding so that the > coefficient for Drug now tests the signifiance of Drug at Hour 3. The> p-value is comparable to that obtained from the paired t-test at hour > 3. > > However, for a different dataset the relevant mixed model p-value is > .003 while that > for the paired t-test is .04. > > Given this data structure, does anyone have any suggestions as to what> to look for that could explain why in one case p-values are consistent> and in > the other case they are not? > This would be especially helpful since the medical people want to > solely focus on hour 3 and perform the paired t-test. Sorry to > belabor the question but I've been getting various > answers to this question and would like to resolve it.Are the coefficients for this comparison the same with each approach? Here is one way of doing the simple t-test which gives the coefficient for that approach: lm(z ~ drug, data = data.grp, subset = (time == "Time-3")) <DA> but this wouldn't be a paired t-test, correct? If the coefficients for this simple t-test approach and the contrast in the mixed-model are the same, then the difference in significance results from differences in the standard errors. The mixed-model approach takes into account many more observations of z, so I would consider its estimate of the standard error to be better than the estimate that only considers one time point. <DA> RE the coefficients: they are the same for both approaches for both my datasets above, as expected. For the latter case where the mixed model obtained much greater significance than the paired t-test, I guess your explantion how it uses more data to estimate the standards error is on target. Finally, would it be okay to say that the paired t-test is a "valid conservative method" for this question at a single time point if that time point is the main endpoint of the study? There is an article in the British Journal of Medicne ("Analysis of Serisal Measurments in Medical Research", v300, p.230, Mathews et al) that critiques testing several separate time points, but I don't think their arguments invalidate doing a single paired t-test. hope this helps, Chuck -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894
Apparently Analagous Threads
- treatment effect at specific time point within mixed effects model
- maintaining specified factor contrasts when subsetting in lmer
- anova statistics in lmer
- summarizing dataframe at variable/factor levels
- Extracting standard errors for adjusted fixed effect sizes in lmer