plot_coefs create regression coefficient
plots with ggplot2.
plot_summs(..., ci_level = 0.95, model.names = NULL, coefs = NULL, omit.coefs = "(Intercept)", inner_ci_level = NULL, color.class = "CUD Bright", plot.distributions = FALSE, rescale.distributions = FALSE, exp = FALSE, point.shape = TRUE, legend.title = "Model", groups = NULL, facet.rows = NULL, facet.cols = NULL, facet.label.pos = "top") plot_coefs(..., ci_level = 0.95, inner_ci_level = NULL, model.names = NULL, coefs = NULL, omit.coefs = c("(Intercept)", "Intercept"), color.class = "CUD Bright", plot.distributions = FALSE, rescale.distributions = FALSE, exp = FALSE, point.shape = TRUE, legend.title = "Model", groups = NULL, facet.rows = NULL, facet.cols = NULL, facet.label.pos = "top")
The desired width of confidence intervals for the coefficients. Default: 0.95
If plotting multiple models simultaneously, you can provide a vector of names here. If NULL, they will be named sequentially as "Model 1", "Model 2", and so on. Default: NULL
If you'd like to include only certain coefficients, provide them as a vector. If it is a named vector, then the names will be used in place of the variable names. See details for examples. Default: NULL
If you'd like to specify some coefficients to not include
in the plot, provide them as a vector. This argument is overridden by
Plot a thicker line representing some narrower span
See jtools_colors for more on your color options. Default: 'CUD Bright'
Instead of just plotting the ranges, you may plot normal distributions representing the width of each estimate. Note that these are completely theoretical and not based on a bootstrapping or MCMC procedure, even if the source model was fit that way. Default is FALSE.
If TRUE, all coefficients are exponentiated (e.g., transforms logit coefficents from log odds scale to odds). The reference line is also moved to 1 instead of 0.
When using multiple models, should each model's point estimates use a different point shape to visually differentiate each model from the others? Default is TRUE.
What should the title for the legend be? Default is
"Model", but you can specify it here since it is rather difficult to
change later via
If you would like to have facets (i.e., separate panes) for different groups of coefficients, you can specifiy those groups with a list here. See details for more on how to do this.
The number of rows in the facet grid (the
The number of columns in the facet grid (the
Where to put the facet labels. One of "top" (the default), "bottom", "left", or "right".
A ggplot object.
A note on the distinction between
plot_summs only accepts models supported by
summ() and allows users
to take advantage of the standardization and robust standard error features
(among others as may be relevant).
plot_coefs supports any models that
broom::tidy() method defined in the broom package, but of course
lacks any additional features like robust standard errors. To get a mix
of the two, you can pass
summ objects to
coefs, if you provide a named vector of coefficients, then
the plot will refer to the selected coefficients by the names of the
vector rather than the coefficient names. For instance, if I want to
include only the coefficients for the
mpg but have
the plot refer to them as "Horsepower" and "Miles/gallon", I'd provide
the argument like this:
c("Horsepower" = "hp", "Miles/gallon" = "mpg")
To use the
groups argument, provide a (preferably named) list of
character vectors. If I want separate panes with "Frost" and "Illiteracy"
in one and "Population" and "Area" in the other, I'd make a list like
list(pane_1 = c("Frost", "Illiteracy"), pane_2 = c("Population", "Area"))
states <- as.data.frame(state.x77) fit1 <- lm(Income ~ Frost + Illiteracy + Murder + Population + Area + `Life Exp` + `HS Grad`, data = states, weights = runif(50, 0.1, 3)) fit2 <- lm(Income ~ Frost + Illiteracy + Murder + Population + Area + `Life Exp` + `HS Grad`, data = states, weights = runif(50, 0.1, 3)) fit3 <- lm(Income ~ Frost + Illiteracy + Murder + Population + Area + `Life Exp` + `HS Grad`, data = states, weights = runif(50, 0.1, 3)) # Plot all 3 regressions with custom predictor labels, # standardized coefficients, and robust standard errors plot_summs(fit1, fit2, fit3, coefs = c("Frost Days" = "Frost", "% Illiterate" = "Illiteracy", "Murder Rate" = "Murder"), scale = TRUE, robust = TRUE)