View source: R/n_grouplevels.R
n_grouplevels | R Documentation |
Returns the number of group levels of random effects from mixed models.
n_grouplevels(x, ...)
x |
A mixed model. |
... |
Additional arguments that can be passed to the function. Currently,
you can use |
The number of group levels in the model.
data(sleepstudy, package = "lme4")
set.seed(12345)
sleepstudy$grp <- sample(1:5, size = 180, replace = TRUE)
sleepstudy$subgrp <- NA
for (i in 1:5) {
filter_group <- sleepstudy$grp == i
sleepstudy$subgrp[filter_group] <-
sample(1:30, size = sum(filter_group), replace = TRUE)
}
model <- lme4::lmer(
Reaction ~ Days + (1 | grp / subgrp) + (1 | Subject),
data = sleepstudy
)
n_grouplevels(model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.