Learn R Programming

sjPlot (version 2.0.0)

sjp.lmm: Plot estimates of multiple fitted lm(er)'s

Description

Plot and compare coefficients (estimates) with confidence intervals of multiple fitted linear (mixed effects) models in one plot. Fitted models may have differing predictors, but only in a "stepwise" sense.

Usage

sjp.lmm(..., type = "lm", remove.estimates = NULL, title = NULL,
  depvar.labels = NULL, legend.title = "Dependent Variables",
  legend.pval.title = "p-level", axis.labels = NULL,
  axis.title = "Estimates", axis.lim = NULL, wrap.title = 50,
  wrap.labels = 25, wrap.legend.title = 20, grid.breaks = NULL,
  geom.size = 3, geom.spacing = 0.4, geom.colors = "Set1",
  show.values = TRUE, show.legend = TRUE, show.intercept = FALSE,
  show.p = TRUE, fade.ns = FALSE, p.shape = FALSE, p.kr = TRUE,
  vline.type = 2, vline.color = "grey70", digits = 2,
  facet.grid = FALSE, coord.flip = TRUE, prnt.plot = TRUE)

Arguments

Value

(Insisibily) returns the ggplot-object with the complete plot (plot) as well as the data frame that was used for setting up the ggplot-object (data).

Examples

Run this code
# prepare dummy variables for binary logistic regression
# Now fit the models. Note that all models share the same predictors
# and only differ in their dependent variable
library(sjmisc)
data(efc)

# fit three models
fit1 <- lm(barthtot ~ c160age + c12hour + c161sex + c172code, data = efc)
fit2 <- lm(neg_c_7 ~ c160age + c12hour + c161sex + c172code, data = efc)
fit3 <- lm(tot_sc_e ~ c160age + c12hour + c161sex + c172code, data = efc)

# plot multiple models
sjp.lmm(fit1, fit2, fit3, facet.grid = TRUE)

# plot multiple models with legend labels and 
# point shapes instead of value labels
sjp.lmm(fit1, fit2, fit3,
        axis.labels = c("Carer's Age", "Hours of Care", "Carer's Sex",
                        "Educational Status"),
        depvar.labels = c("Barthel Index", "Negative Impact", "Services used"),
        show.values = FALSE, show.p = FALSE, fade.ns = TRUE, p.shape = TRUE)

# ------------------------------
# plot multiple models from nested lists argument
# ------------------------------
all.models <- list()
all.models[[1]] <- fit1
all.models[[2]] <- fit2
all.models[[3]] <- fit3

sjp.lmm(all.models)

# ------------------------------
# plot multiple models with different
# predictors (stepwise inclusion),
# standardized estimates
# ------------------------------
fit1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars)
fit2 <- update(fit1, . ~ . + hp)
fit3 <- update(fit2, . ~ . + am)

sjp.lmm(fit1, fit2, fit3, type = "std2")

Run the code above in your browser using DataLab