It is straightforward to build an LMM with fixed variance components in SAS. For example, variance components = 5 and 10 (experimental error and sampling error, respectively)
proc glimmix; class trt rep;
model y = trt;
random rep(trt);
parms (5)(10) / hold=1,2;
ods output tests3=power_terms;
But it looks like R has no option to fix the variance components.
I can not find the solution in the manual of Lmer.
This can be done slightly more easily in glmmTMB
:
data("sleepstudy", package = "lme4")
library(glmmTMB)
m1 <- glmmTMB(Reaction ~ Days + (1|Subject),
family = gaussian,
data = sleepstudy,
start = list(betad = log(5),
theta = log(10)/2),
map = list(betad = factor(NA), theta = factor(NA))
)
Running Anova
:
car::Anova(m1, type = "3")
Analysis of Deviance Table (Type III Wald chisquare tests)
Response: Reaction
Chisq Df Pr(>Chisq)
(Intercept) 97012 1 < 2.2e-16 ***
Days 32541 1 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Note that finite-size corrections (i.e. F instead of chi-square tests) are not implemented for glmmTMB objects ...
Explanation:
map
argument specifies which model parameters to hold fixed or equal to each other: NA
specifies "hold fixed". betad
is the set of parameters controlling dispersion/residual variance, theta
controls the random effects variancestart
argument gives the starting values, which are the fixed values that will be applied when map
is in effect. Residual variance is specified on the log-variance scale; random-effects variance is specified on the log-standard-deviation scale.Excerpt from output:
Conditional model:
Groups Name Std.Dev.
Subject (Intercept) 3.162
Residual 2.236
These values are sqrt(10)
and sqrt(5)
, respectively.
You can also do this by specifying very narrow priors in the blme
package. In lme4
random effect variances can be fixed by writing a wrapper function for the negative log-likelihood function and doing the optimization yourself (see ?lme4::modular
), but residual variances can't be fixed because they are profiled out of the log-likelihood expression.