[R] similar limma's contrasts.fit() for lme (mixed effect model)object

Kuhn, Max Max.Kuhn at pfizer.com
Mon Jul 9 19:34:18 CEST 2007


Well, you picked the type of contrast that proves my statement wrong.
The interface in the contrast package (and the Design package) may not
be well suited for the type that you are interested in (or other types,
such as SAS's "lsmeans" type contrasts).

The good news is that the function contrast:::contrastCalc currently
does most of the work for all types of models. A modified version of
that function can be used for your situation. The top part of the
function works to generate two objects: xa and xb. Looking at the limma
documentation, this might correspond to vectors given for WT.SvsU and

I'll attach the modified version in an off-list email with an lme
example. (and I'll think about how to let the contrasts be specified by
the coefficient vectors for a future release)


-----Original Message-----
From: shirley zhang [mailto:shirley0818 at gmail.com] 
Sent: Monday, July 09, 2007 11:50 AM
To: Kuhn, Max
Cc: R-help at stat.math.ethz.ch
Subject: Re: [R] similar limma's contrasts.fit() for lme (mixed effect

Hi Max,

Thanks for your prompt reply. Actually I have already checked contrast
package, but I still could not figure out how to set the contrast
matrix for a 2x2 factorial design.

I would like to set a contrast exactly similar to the limma's user
guide, 8.7 Factorial Designs (page 45). For example, after a mixed
linear model fit with the default contr.treatment, I want to compute
an estimated coefficient as the sum of the third and fourth
coefficients of the original lme model (2x2 factorial design).

Could you give me an example how to implement this using  the contrast


On 7/9/07, Kuhn, Max <Max.Kuhn at pfizer.com> wrote:
> Shirley,
> The contrast package can do this. The method of specifying the
> conditions/coefficients is different (and I think easier).
> Max
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of shirley zhang
> Sent: Monday, July 09, 2007 11:16 AM
> To: R-help at stat.math.ethz.ch
> Subject: [R] similar limma's contrasts.fit() for lme (mixed effect
> model)object
> Dear R help,
> In limma package, contrasts.fit() function is very useful. I am
> wondering whether there is a similar function for lme object, which
> means given a mixed linear model fit, compute estimated coefficients
> and standard errors for a given set of contrasts.
> Thanks,
> Shirley
> ______________________________________________
> 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.
> ----------------------------------------------------------------------
> Unless expressly stated otherwise, this message is confidential and
may be privileged.  It is intended for the addressee(s) only.  Access to
this E-mail by anyone else is unauthorized.  If you are not an
addressee, any disclosure or copying of the contents of this E-mail or
any action taken (or not taken) in reliance on it is unauthorized and
may be unlawful.  If you are not an addressee, please inform the sender

More information about the R-help mailing list