[R-sig-ME] how to fit multivariate linear mixed model with `lme4`

Ned Dochtermann ned.dochtermann at gmail.com
Fri Oct 28 17:28:28 CEST 2011


Hi Iftikhar,

There are a couple of ways to fit multivariate models with lme4. The
approach I was initially familiar with (based on a SAS note I came across
but consistent with the thread another list member provided) requires the
use of dummy variables. There is an example of this data structure and code
syntax using dummy variables at: 
https://stat.ethz.ch/pipermail/r-sig-mixed-models/2011q3/006713.html

An easier approach uses the melt function in the library reshape and then
similar syntax, for that see Ben Bolker's post in the same thread.

Unfortunately I don't know, and Dr. Bolker didn't seem to know off-hand
either, how to deal with issues regarding the residual matrix. There would
be a bit more flexibility in this regard using either lme or MCMCglmm rather
than lmer but I don't think any of the R packages have the same flexibility
in regards for residual matrix specification as SAS's Proc Mixed. Anyway, if
you're going to use lmer you're going to be making some pretty major
assumptions about your within Block variances for each response variable.
Just something to be aware of.

Good luck.

Ned

--
Ned Dochtermann
Department of Biology
University of Nevada, Reno

ned.dochtermann at gmail.com
http://wolfweb.unr.edu/homepage/mpeacock/Ned.Dochtermann/
http://www.researcherid.com/rid/A-7146-2010
--



Message: 1
Date: Thu, 27 Oct 2011 01:05:28 +0200
From: iftikhar ahmad <iftich2002 at gmail.com>
To: r-sig-mixed-models at r-project.org
Subject: [R-sig-ME] how to fit multivariate linear mixed model with
	`lme4`
Message-ID:
	<CAJvxsf7X2Cqunq++A5yaDDKUbG1gM0_rTETmRGFCFtNNRz79vQ at mail.gmail.com>
Content-Type: text/plain

Hello All,

I wonder how to fit multivariate linear mixed model with `lme4`. I fitted
univariate linear mixed models with the following code:

    library(lme4)
    lmer.m1 <- lmer(Y1~A*B+(1|Block)+(1|Block:A), data=Data)
    summary(lmer.m1)
    anova(lmer.m1)

    lmer.m2 <- lmer(Y2~A*B+(1|Block)+(1|Block:A), data=Data)
    summary(lmer.m2)
    anova(lmer.m2)

I'd like to know how to fit multivariate linear mixed model with `lme4`. The
data is below:

    Block A B    Y1    Y2
     1 1 1 135.8 121.6
     1 1 2 149.4 142.5
     1 1 3 155.4 145.0
     1 2 1 105.9 106.6
     1 2 2 112.9 119.2
     1 2 3 121.6 126.7
     2 1 1 121.9 133.5
     2 1 2 136.5 146.1
     2 1 3 145.8 154.0
     2 2 1 102.1 116.0
     2 2 2 112.0 121.3
     2 2 3 114.6 137.3
     3 1 1 133.4 132.4
     3 1 2 139.1 141.8
     3 1 3 157.3 156.1
     3 2 1 101.2  89.0
     3 2 2 109.8 104.6
     3 2 3 111.0 107.7
     4 1 1 124.9 133.4
     4 1 2 140.3 147.7
     4 1 3 147.1 157.7
     4 2 1 110.5  99.1
     4 2 2 117.7 100.9
     4 2 3 129.5 116.2

Thank in advance for your time and cooperation.

Regards,
Iftikhar Ahmad




More information about the R-sig-mixed-models mailing list