0

I've run a generalized linear mixed model with a binomial distribution with success of taking a seed as the response (Yes/No). Individual id is a random effect. Is it possible to not just calculate predicted probabilities based on the fixed effects but for each individual as well?

I want to be able to say what the predicted probability, with 95% CI, of being successful is for each individual.

Rachael
  • 33
  • 7

1 Answers1

0

You could use the ggeffects package. Predicted probabilities for different subjects should work in the same way as for linear models, and is described in detail here.

However, currently you can't get confidence intervals for random effects when calculating predicted values for group levels / subjects... (any hints how to implement this are welcome!)

Example:

library(lme4)
#> Loading required package: Matrix
library(ggeffects)

data("cbpp")
set.seed(123)
cbpp$cont <- rnorm(nrow(cbpp))

# categorical predictor
m1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd), 
            data = cbpp, family = binomial)

me <- ggpredict(m1, terms = c("period", "herd [1,5,10,15]"), type = "re")
plot(me)
#> Loading required namespace: ggplot2


# continuous predictor
m2 <- glmer(cbind(incidence, size - incidence) ~ I(cont^2) + (1 | herd), 
            data = cbpp, family = binomial)

me <- ggpredict(m2, terms = c("cont", "herd [1,5,15]"), type = "re")
#> Model contains polynomial or cubic / quadratic terms. Consider using `terms="cont [all]"` to get smooth plots. See also package-vignette 'Marginal Effects at Specific Values'.
plot(me)

Created on 2020-06-17 by the reprex package (v0.3.0)

Daniel
  • 7,252
  • 6
  • 26
  • 38
  • Thanks for your answer, @Daniel! Why can't you get confidence intervals for random effects when calculating predicted values for group levels / subjects? – Rachael Jun 22 '20 at 14:53