Source: R/plot_models.R
plot_models.Rd
Plot and compare regression coefficients with confidence intervals of multiple regression models in one plot.
plot_models(..., transform, std.est = NULL, rm.terms = NULL, title = NULL, m.labels = NULL, legend.title = "Dependent Variables", legend.pval.title = "p-level", axis.labels = NULL, axis.title = NULL, axis.lim = NULL, wrap.title = 50, wrap.labels = 25, wrap.legend.title = 20, grid.breaks = NULL, dot.size = 3, spacing = 0.4, colors = "Set1", show.values = FALSE, show.legend = TRUE, show.intercept = FALSE, show.p = TRUE, p.shape = FALSE, ci.lvl = 0.95, vline.color = NULL, digits = 2, grid = FALSE, auto.label = TRUE, prefix.labels = c("none", "varname", "label"))
Arguments
... | One or more regression models, including glm's or mixed models.May also be a |
---|---|
transform | A character vector, naming a function that will be appliedon estimates and confidence intervals. By default, |
std.est | For linear models, choose whether standardized coefficients shouldbe used for plotting. Default is no standardization.
|
rm.terms | Character vector with names that indicate which terms shouldbe removed from the plot. Counterpart to |
title | Character vector, used as plot title. By default, |
m.labels | Character vector, used to indicate the different modelsin the plot's legend. If not specified, the labels of the dependentvariables for each model are used. |
legend.title | Character vector, used as title for the plot legend. Note thatonly some plot types have legends (e.g. |
legend.pval.title | Character vector, used as title of the plot legend thatindicates the p-values. Default is |
axis.labels | Character vector with labels for the model terms, used asaxis labels. By default, |
axis.title | Character vector of length one or two (depending on theplot function and type), used as title(s) for the x and y axis. If notspecified, a default labelling is chosen. Note: Some plot typesmay not support this argument sufficiently. In such cases, use the returnedggplot-object and add axis titles manually with |
axis.lim | Numeric vector of length 2, defining the range of the plotaxis. Depending on plot-type, may effect either x- or y-axis. ForMarginal Effects plots, |
wrap.title | Numeric, determines how many chars of the plot title aredisplayed in one line and when a line break is inserted. |
wrap.labels | Numeric, determines how many chars of the value, variableor axis labels are displayed in one line and when a line break is inserted. |
wrap.legend.title | numeric, determines how many chars of the legend's titleare displayed in one line and when a line break is inserted. |
grid.breaks | Numeric value or vector; if |
dot.size | Numeric, size of the dots that indicate the point estimates. |
spacing | Numeric, spacing between the dots and error bars of theplotted fitted models. Default is 0.3. |
colors | May be a character vector of color values in hex-format, validcolor value names (see
|
show.values | Logical, whether values should be plotted or not. |
show.legend | For Marginal Effects plots, shows or hides thelegend. |
show.intercept | Logical, if |
show.p | Logical, adds asterisks that indicate the significance level ofestimates to the value labels. |
p.shape | Logical, if |
ci.lvl | Numeric, the level of the confidence intervals (error bars).Use |
vline.color | Color of the vertical "zero effect" line. Default color isinherited from the current theme. |
digits | Numeric, amount of digits after decimal point when roundingestimates or values. |
grid | Logical, if |
auto.label | Logical, if |
prefix.labels | Indicates whether the value labels of categorical variablesshould be prefixed, e.g. with the variable name or variable label. Seeargument |
Value
A ggplot-object.
Examples
data(efc)# fit three modelsfit1 <- 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 modelsplot_models(fit1, fit2, fit3, grid = TRUE)
# plot multiple models with legend labels and# point shapes instead of value labelsplot_models( fit1, fit2, fit3, axis.labels = c( "Carer's Age", "Hours of Care", "Carer's Sex", "Educational Status" ), m.labels = c("Barthel Index", "Negative Impact", "Services used"), show.values = FALSE, show.p = FALSE, p.shape = TRUE)
# plot multiple models from nested lists argumentall.models <- list()all.models[[1]] <- fit1all.models[[2]] <- fit2all.models[[3]] <- fit3plot_models(all.models)
# plot multiple models with different predictors (stepwise inclusion),# standardized estimatesfit1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars)fit2 <- update(fit1, . ~ . + hp)fit3 <- update(fit2, . ~ . + am)plot_models(fit1, fit2, fit3, std.est = "std2")