在R中运行具有预定义方差分量的线性混合模型(lmer,lme4)

时间:2018-05-16 12:33:29

标签: r lme4 mixed-models variance

我正在创建一个线性混合模型,我事先估计/定义了我的方差分量。现在我想将它们添加到函数中,但我不知道该怎么做。目前使用的“lme4”函数来自“lme4” - 包确实自己估计方差分量,我不知道如何预先定义它们。

提前致谢!

For Example this data:

library(lme4)

f <- rnorm(10, mean=1.4025, sd=0.101)
m <- rnorm(10, mean=1.9025, sd=0.15)
gain <-  c(f,m,f,m)
s <- c("f","f","f","f","f","m","m","m","m","m")
sex <- c(s,s,s,s)
i <- c(1:10)
anim <- as.factor(c(i,i,i,i))

invented <- data.frame(gain,sex,anim)

# model

lmm <- lmer(gain ~ sex + (1|anim), data = d)
summary(lmm)

# How can I add variance components to the model?
# Fixed-effect-variance = 0.0135
# Random-effect-variance = 0.0045

0 个答案:

没有答案