Multivariate Linear Mixed Model in lme4

后端 未结 3 1576
挽巷
挽巷 2021-01-31 05:57

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

library(lme4)
lmer.m         


        
相关标签:
3条回答
  • 2021-01-31 06:26

    This can sometimes be faked satisfactorily in nlme/lme4 by simply reformatting your data like

    require(reshape)
    Data = melt(data, id.vars=1:3, variable_name='Y')
    Data$Y = factor(gsub('Y(.+)', '\\1', Data$Y))
    
    > Data
      Block A B Y value
    1     1 1 1 1 135.8
    2     1 1 2 1 149.4
    3     1 1 3 1 155.4
    4     1 2 1 1 105.9
    5     1 2 2 1 112.9
    6     1 2 3 1 121.6
    ...
    

    and then including the new variable Y in your linear mixed model.

    However, for true Multivariate Generalized Linear Mixed Models (MGLMM), you will probably need the sabreR package or similar. There is also an entire book to accompany the package, Multivariate Generalized Linear Mixed Models Using R. If you have a proxy to a subscribing institution, you might even be able to download it for free from http://www.crcnetbase.com/isbn/9781439813270. I would refer you there for any further advice, as this is a meaty topic and I am very much a novice.

    0 讨论(0)
  • 2021-01-31 06:43

    lmer and its elder sibling lme are inherently "one parameter left of ~". Have a look at the car packages; it offers no off-the shelf repeated measurement support, but you will find a few comments on the subject by searching the R list:

    John Fox on car package

    0 讨论(0)
  • 2021-01-31 06:51

    @John's answer above should be largely right. You add a dummy variable (ie--the factor variable Y) to the model. Here you have 3 subscripts i= 1...N for observations, j=1,...,4 for blocks, and h=1,2 for the dependent var. But you also need to force the level 1 error term to 0 (or to near zero), which I'm not sure lme4 does. Ben Bolker might provide more information. This is described more in Goldstein (2011) Chap 6 and Chap 7 for latent multivariate models.

    IE

    Y_hij = \beta_{01} z_{1ij} + \beta_{02} z_{2ij} + \beta X + u_{1j} z_{1ij} + u_{2j} z_{2ij}

    So:

    require(reshape2)
    Data = melt(data, id.vars=1:3, variable_name='Y')
    Data$Y = factor(gsub('Y(.+)', '\\1', Data$Y))
    
    m1 <- lmer(value ~ Y + A*B + (1|Block) + (1|Block*A), data= Data)
    # not sure how to set the level 1 variance to 0, @BenBolker
    # also unclear to me if you're requesting Y*A*B instead of Y + A*B
    
    0 讨论(0)
提交回复
热议问题