Multivariate Linear Mixed Model in lme4

后端 未结 3 1577
挽巷
挽巷 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.

提交回复
热议问题