Skip to content

get_predicted confidence intervals in mixed-effects models #677

@vincentarelbundock

Description

@vincentarelbundock

At the moment, confidence intervals around predicted values for lmerMod only take into account the fixed effects.

For example, in a model with Chick-level random intercepts and coefficients, each Chick will have intervals of the exact same width at every time point:

library(lme4)
library(insight)

fit1 <- lmer(
  weight ~ 1 + Time + (1 + Time | Chick),
  data = ChickWeight)

get_predicted(fit1, ci = .95) |> 
    cbind(ChickWeight) |>
    within({CI_width = CI_high - CI_low}) |>
    subset(Time == 4, select = "CI_width") |>
    table()
#> CI_width
#>  4.1810057846375 4.18100578463751 
#>                5               44

I was chatting with @ASKurz and we were wondering if this is what most users would expect/want. In particular, it seems like many would want the random components to be accounted for in the computation. Should we supply CIs at all, issue a warning, or is the status quo just fine?

Curious what everyone thinks (and maybe especially @bwiernik )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Docs 📚Something to be adressed in docs and/or vignettesWhat's your opinion 🙉Collectively discuss something

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions