[R-sig-ME] contrasts among simple effects
Lenth, Russell V
russell-lenth at uiowa.edu
Sat Oct 17 00:30:00 CEST 2015
I think we tend to highly overrate the idea of trying to engineer factor codings in order to get estimates of interesting contrasts among the regression coefficients. It gets confusing when there are multiple factors, and often, only some of the contrasts of interest can be estimated this way unless more than one version of the model is fitted. There are good packages that can handles such things -- multcomp, lsmeans, effects, etc. With your example, you could do, for example:
library(lsmeans)
lsm <- lsmeans(model2a, ~ drug | time)
lsm
pairs(lsm) # compare drugs at each time
pairs(lsm, by = "drug") # compare times for each drug
Russ
--
Russell V. Lenth - Professor Emeritus
Department of Statistics and Actuarial Science
The University of Iowa - Iowa City, IA 52242 USA
Voice (319)335-0712 - FAX (319)335-3017
russell-lenth at uiowa.edu - http://www.stat.uiowa.edu/~rlenth/
> Greetings R Community
>
> Apologize for previously sending a csv file.
>
> My goal is to make orthogonal contrasts among simple effects in
> analysis of repeated measures data. The SAS publication, on page
> 1224, shows how to make this type of contrasts in SAS. But, my search
> of books about repeated measures analysis using R, and on-line has not yielded a methodology.
> Hopefully, someone can direct me to a book or publication that will
> show me a methodology.
>
> Statistical Analysis of Repeated Measures Data Using SAS Procedures
>
>
> http://cslras.pbworks.com/f/littell_j_anim_sci_76_4_analysis_of_repeat
> ed_measures_using_sas.pdf
>
>
>
> Attached is a txt data file (file name = heart_rate.txt). My code for
> the repeated measures analysis is below.
>
> library("nlme")
>
> # with AR1 variance/covariance structure, with ordered statement
>
> heartRate$time <- factor(heartRate$time)
>
> model2a <- lme(HR ~ drug*ordered(time), random =~1|person, correlation
> =corAR1(, form=~1|person), data = heartRate)
>
> summary(model2a)
>
> anova(model2a)
>
> Making a new variable ?simple? that merges the variables drug and time
> will enable me to make orthogonal contrasts among the simple effects.
> But, when using the variable ?simple? as the independent variable, the
> data will no longer be fitted to the AR1 variance/covariance structure.
>
> Thanks.
>
> Best regards,
>
> James F.Henson
More information about the R-sig-mixed-models
mailing list