Description Usage Arguments Examples
Plots coefficients from a model, along with standard errors. Coefficients that are statistically significant at agiven level are highlighted in darker text. Inspired by https://github.com/jaredlander/coefplot/blob/master/R/coefplot.r but works w/ ggplot2 version > 2.2
1 2 3 4 5 6 | plot_coef(model, negative_ontop = TRUE, negative_good = FALSE,
cluster_col = NA, level = 0.95, CI_factor = 1.96, exclude_terms = NA,
exclude_intercept = TRUE, plot_left_labels = TRUE,
plot_right_labels = FALSE, alpha_insignificant = 0.3, size_point = 3,
x_buffer = 0.1, label_margin = 1, font_normal = "Lato",
font_semi = "Lato Light", font_light = "Lato Light")
|
model |
Fitted model object from a lm or glm |
negative_good |
Should negative coefficients be displayed in red (default) or blue (negative_good = TRUE)? |
cluster_col |
Column in the *original* data frame used to build the model to be used to calculate clustered standards errors using the ‘multiwayvcov' package. By default, no clustering correction is used, and the standard erorrs are those calculated in the model. If using clustered errors, should be specified as: ’orginal_data$clustering_column' |
level |
confidence level for error bars / significance indicator |
CI_factor |
Factor to adjust the standard errors by. By default, 1.96, assuming a normal distribution with sufficient sample size (95 percent of distribution lies within 1.96 standard deviations) |
exclude_terms |
(optional) string of terms to exclude |
exclude_intercept |
whether to include the intercept from the model in the color-coding of coefficients. |
plot_left_labels |
include names of variables on the left side of the y-axis |
plot_right_labels |
include names of variables on the right side of the y-axis |
alpha_insignificant |
alpha (opacity) level for variables that are insignificant |
size_point |
size to plot the coefficients, in mm |
x_buffer |
percentage offset for the y-axis labels |
label_margin |
offset for the y-axis labels |
font_normal |
string containing the name of the font to use in darkest text |
font_semi |
string containing the name of the font to use in medium dark text |
font_light |
string containing the name of the font to use in lightest text |
1 2 3 4 5 6 7 8 9 10 | data(diamonds, package = 'ggplot2')
model1 <- lm(price ~ carat + cut*color, data=diamonds)
plot_coef(model1)
# Sort of a contrived example to show the effect of clustering standard errors.
model2 <- lm(price ~ carat + color, data=diamonds)
# No clustered errors
plot_coef(model2)
# Errors clustered by cut
plot_coef(model2, cluster_col = diamonds$cut)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.