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

问题描述

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

提前致谢!

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

标签: rlme4mixed-modelsvariance

解决方案


推荐阅读