2

I am creating a linear mixed model for which I did estimate/define my variance components in advance. Now I would like to add them to the function but I dont know how to do this. The currently used "lmer"-function from the "lme4"-package does estimate the variance components by itself and I dont know how to pre-define them.

Thanks in advance!

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
T. Grüter
  • 121
  • 7
  • You cannot fit a model with a pre-defined residual variance. – Roland May 16 '18 at 12:34
  • Youre right (I edidted the post). I want to predefine the variance of the fixed and random effects. – T. Grüter May 16 '18 at 12:42
  • That can still not be right. I would somewhat understand fixing the random effects variance. – Roland May 16 '18 at 12:54
  • There are people (e.g. animal breeders) who do a variance component analysis and then use those once estimated variance-components to run theyr mixed model (e.g. breeding value estimation). Thats what I would like to do in R but I dont see a way to tell the function my desired variance-components. – T. Grüter May 16 '18 at 13:41
  • [This question/answer](https://stackoverflow.com/questions/39718754/fixing-variance-values-in-lme4) seems related. – aosmith May 30 '18 at 14:39

0 Answers0