Learn R Programming

sjPlot (version 1.8.3)

sjp.glmer: Plot odds ratios or predicted probabilities of generalized linear mixed effects models

Description

By default, this function plots odds ratios (exponentiated coefficients) with confidence intervalls of either fixed effects or random effects of generalized linear mixed effects models (that have been fitted with the glmer-function of the lme4-package). Furthermore, this function also plots predicted probabilities or diagnostic plots.

Usage

sjp.glmer(fit, type = "re", vars = NULL, ri.nr = NULL, emph.grp = NULL,
  title = NULL, geom.size = NULL, geom.colors = "Set1",
  hideErrorBars = FALSE, showIntercept = TRUE,
  stringIntercept = "(Intercept)", sort.coef = NULL, pred.labels = NULL,
  axisTitle.x = NULL, axisTitle.y = NULL, facet.grid = TRUE,
  free.scale = FALSE, interceptLineType = 2,
  interceptLineColor = "grey70", remove.estimates = NULL,
  showValueLabels = TRUE, labelDigits = 2, showPValueLabels = TRUE,
  fade.ns = FALSE, show.se = FALSE, printPlot = TRUE)

Arguments

Value

(Insisibily) returns
  • the ggplot-object (plot), iftype = "fe"or iftype = "re"andfacet.grid = TRUE). Multiple plots (type = "re"and iffacet.grid = FALSE) are returned in the objectplot.list.
  • a list of ggplot-objects (plot.list). Seeplotfor details.
  • a data framemydfwith the data used to build the ggplot-object(s).

Details

[object Object],[object Object],[object Object],[object Object]

See Also

http://www.strengejacke.de/sjPlot/sjp.glmer/{sjPlot manual: sjp.glmer}

Examples

Run this code
library(lme4)
library(sjmisc)
# create binary response
sleepstudy$Reaction.dicho <- dicho(sleepstudy$Reaction, dich.by = "md")
# fit model
fit <- glmer(Reaction.dicho ~ Days + (Days | Subject),
             sleepstudy,
             family = binomial("logit"))

# simple plot
sjp.glmer(fit)

# sort by predictor Days
sjp.glmer(fit, sort.coef = "Days")

data(efc)
# create binary response
efc$hi_qol <- dicho(efc$quol_5)
# prepare group variable
efc$grp = as.factor(efc$e15relat)
levels(x = efc$grp) <- get_labels(efc$e15relat)
# data frame for fitted model
mydf <- data.frame(hi_qol = as.factor(efc$hi_qol),
                   sex = as.factor(efc$c161sex),
                   c12hour = as.numeric(efc$c12hour),
                   neg_c_7 = as.numeric(efc$neg_c_7),
                   grp = efc$grp)
# fit glmer
fit <- glmer(hi_qol ~ sex + c12hour + neg_c_7 + (1|grp),
             data = mydf,
             family = binomial("logit"))

# plot and sort fixed effects
sjp.glmer(fit,
          type = "fe",
          sort.coef = TRUE)

# plot probability curves (predicted probabilities)
# for each covariate, grouped by random intercepts
# in integrated plots, emphasizing groups 1 and 4
sjp.glmer(fit,
          type = "ri.pc",
          emph.grp = c(1, 4),
          facet.grid = FALSE)

# plot probability curve (predicted probabilities)
# of fixed effect, only for coefficient "neg_c_7"
sjp.glmer(fit,
          type = "fe.pc",
          vars = "neg_c_7")

Run the code above in your browser using DataLab