3
$\begingroup$

In R, is it possible to force a lmer model with random effect to be fitted on data with only one level? We want to do this to keep the same model structure in rare case where our data only contains 1 grouping level. In a previous step, we manually fix variance of the random effects (https://stackoverflow.com/questions/39718754/fixing-variance-values-in-lme4), hence we do not need to estimate it.

The objective is not to estimate the variance components of the mixed model, but to estimate how pre-specified variances for a number of random factors affect the standard error of a mean value. For example, if $Y = \mu + A + B + C + \epsilon$ and we know (from other analyses) $V[A], V[B], V[C]$ and $V[\epsilon]$ then what is the variance of our estimate of $\mu$ when estimated from a data set that also contains information on the levels of the random factors $A, B$ and $C$? Hopefully, there is an easy way with lmer() or at least getting the design matrix for the random factors out so that the covariance structure for all the random components can be calculated.

For information, this can be done easily in SAS with the hold-option to the parms statement in PROC MIXED, but apparently this is not as easily done in lmer().

The following illustrate the error.


library(lme4)
#> Loading required package: Matrix

sleepstudy$Subject <- as.character(sleepstudy$Subject)
ss <- sleepstudy[sleepstudy$Subject == "308", ]

m1 <- lmer(Reaction ~ Days + (1 | Subject), ss)
#> Error: grouping factors must have > 1 sampled level
$\endgroup$
1
  • 1
    $\begingroup$ Why do you need this? $\endgroup$
    – Roland
    Commented Jan 6, 2017 at 7:05

1 Answer 1

2
$\begingroup$

Such a model is unidentifiable, because there's no way to distinguish the single random intercept from the model's overall intercept. Instead, say lm(Reaction ~ Days, ss).

$\endgroup$
4
  • $\begingroup$ And that's apparently what SAS does internally. It could be automated in R too but there doesn't seem sufficient demand of such a feature. $\endgroup$
    – Roland
    Commented Jan 6, 2017 at 7:05
  • 1
    $\begingroup$ @Roland I think lmer does the right thing here. It's better to alert the analyst that a model is unidentifiable than to silently change it so it's identifiable. $\endgroup$ Commented Jan 6, 2017 at 17:25
  • 1
    $\begingroup$ Yes, I fully agree. $\endgroup$
    – Roland
    Commented Jan 6, 2017 at 19:11
  • $\begingroup$ I just updated the question to make it clearer on what we are trying to port from SAS to R. $\endgroup$ Commented Jan 9, 2017 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.