Given random effect values, find 'typical' instances.

find_typical(model, re = NULL, probs = NULL, ...)

Arguments

model

A supported model, see extract_random_effects.

re

The name of the grouping variable for the random effects. Default is NULL to return all.

probs

Quantile probabilities.

...

Other arguments to pass to extract_random_effects.

Value

A data frame that is a subset of extract_random_effects().

Details

In many cases, predictions are made by holding the random effects to zero, which can be seen as the typical case. When the clusters carry substantive meaning, for example, school, country, or hospital, it might be of interest to note which are most 'typical', or at any other value relative to their peers.

By default, this finds the labels associated with random effects that are closest to zero. Alternatively, one can specify quantile probabilities rather than the 'typical' value.

One should see the results as examples, not definitive. Depending on the results of the model, even differences from the lowest valued estimated random effect and the highest may not be statistically notable.

Note

Not surprisingly, different estimation procedures may produce different random effect estimates. As such, you may get a different result from say, the lme4 vs. glmmTMB package. In addition, because nlme doesn't automatically handle crossed random effects, you will potentially get a label that is not actually seen in the data, but reflects the nesting of multiple grouping factors. I don't care enough about nlme usage to do anything about this at present.

Examples

library(mixedup)
library(lme4)

lmer_1 <- lmer(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy)

find_typical(lmer_1, re = 'Subject')
#> # A tibble: 2 × 7
#>   group_var effect    group  value    se lower_2.5 upper_97.5
#>   <chr>     <chr>     <fct>  <dbl> <dbl>     <dbl>      <dbl>
#> 1 Subject   Days      333   -0.224  2.31     -4.74       4.29
#> 2 Subject   Intercept 335   -0.334 12.1     -24.0       23.3