[R] Random Effects Model with Interacting Covariates
Douglas Bates
bates at stat.wisc.edu
Mon Jul 31 19:38:31 CEST 2006
On 7/31/06, Dov Stekel <d.j.stekel at bham.ac.uk> wrote:
> Hi
>
> I have been asked by a colleague to perform a statistical analysis
> which uses random effects - but I am struggling to get this to work
> with nlme in R. Help would be very much appreciated!
>
> Essentially, the data consists of:
>
> 10 patients. Each patient has been given three different treatments (on
> three separate days). 15 measurements (continuous variable) have been
> taken from each patient both before and after each of the treatments.
> So the data looks like:
>
> Patient When Treat Measurement
> a before A 10.3
> a before A 11.2
> ...
> a after A 12.4
> ...
> a before B 11.6
> ...
> a after B ...
>
> and the same for treatment C, patients, b,c,d, etc.
>
> My colleague would like to test to see if the treatments are different
> from each other. i.e., is the change (before to after) due to the
> treatments different between the treatments. It would seem to me like a
> random effects model in which we are interested in the significance of
> the interaction terms Treat:When, with repeated measures in the
> patients (who are random effects, but crossed with the covariates).
> Unfortunately, the groupedData formula only lets me put a single
> covariate on the LHS - nothing as complicated as this!
I'm not sure I understand what the LHS of a formula for a groupedData
object has to do with your question.
You will need to specify the model that you wish to fit by lme and,
for that, you will need to decide which terms should be fixed effects
and which random effects. Do you think that the patients contribute
only an additive shift in the response or do you think that the
patients may have different initial values and different levels of
change in the Before/After responses?
It seems that you could begin by fitting
fm1 <- lme(Measurement ~ When*Treat, random = ~ 1 | Patient, data = ...)
and
fm2 <- lme(Measurement ~ When*Treat, random = ~ 1|Patient/When, data = ...)
There are many other variations that you could consider but we can
only guess at because we don't know enough of the context of the data.
For example, it is possible that it would be appropriate to eliminate
a main effect for Treat because the Treatment cannot be expected to
influence the measurement before the Treatment is applied. The
fixed-effects term would then be specified as
fm3 <- lme(Measurement ~ When + When:Treat, random = ...)
>
> I could, of course, advise her to simply combine all 30 data points for
> each treatment in each patient into a single number (representing
> difference between before and after), but is there a way to use all the
> data in an LME?
>
> Thanks!
>
>
> Dov
>
>
>
> **************************************************************
>
> Dr Dov Stekel
> Lecturer in Bioinformatics
> School of Biosciences
> University of Birmingham
> Birmingham B15 2TT
> Tel: +44 121 414 4209
> Email: d.j.stekel at bham.ac.uk
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list