plot_coef_ci: Plot Point Estimates With Confidence Intervals

View source: R/swash.R

plot_coef_ciR Documentation

Plot Point Estimates With Confidence Intervals

Description

Plotting point estimates with confidence intervals from regression results

Usage

plot_coef_ci(
  point_estimates,
  confint_lower,
  confint_upper,
  coef_names,
  p = NULL,
  estimate_colors = NULL,
  confint_colors = NULL,
  auto_color = FALSE,
  alpha = 0.05,
  set_estimate_colors = c("red", "grey", "green"),
  set_confint_colors = c("#ffcccb", "lightgray", "#CCFFCC"),
  skipvars = NULL,
  plot.xlab = "Independent variables",
  plot.main = "Point estimates with CI",
  axis.at = seq(-30, 40, by = 5),
  pch = 15,
  cex = 2,
  lwd = 5,
  y.cex = 0.8
  )

Arguments

point_estimates

numeric vector containing point estimates

confint_lower

numeric vector containing lower confidence intervals

confint_upper

numeric vector containing upper confidence intervals

coef_names

character vector containing coefficient names

p

numeric vector containing p values of the coefficients (optional)

estimate_colors

vector containing colors for the point estimates (optional)

confint_colors

vector containing colors for the confidence intervals (optional)

auto_color

bool value which indicates whether the colors are found automatically based on coef and CI values

alpha

Significance level \alpha for 1-\alpha*100 confidence intervals

set_estimate_colors

Colors for point estimates (significant negative, not significant, significant positive)

set_confint_colors

Colors for confidence intervals (significant negative, not significant, significant positive)

skipvars

List with coefficients to be dropped

plot.xlab

Label of x axis

plot.main

Plot title

axis.at

Position of y axis

pch

Point type

cex

Point size

lwd

Line width (confidence intervals)

y.cex

Font size of y axis

Details

The function checks whether the input vectors have the same length. If auto_color is TRUE, the colors from set_estimate_colors and set_confint_colors are used, and the significance level is determined based on the coefficient and confidence interval values (all three below 0 = significant negative, all three above 0 = significant positive).

Value

Coefficients plot, no returned value

Author(s)

Thomas Wieland

References

Wieland T (2025) Assessing the effectiveness of non-pharmaceutical interventions in the SARS-CoV-2 pandemic: results of a natural experiment regarding Baden-Württemberg (Germany) and Switzerland in the second infection wave. Journal of Public Health 33(11), 2497-2511. \Sexpr[results=rd]{tools:::Rd_expr_doi("https://doi.org/10.1007/s10389-024-02218-x")}

Examples

data(did_fatalities_splm_coef)
# Results of a difference-in-differences model

plot_coef_ci(
  point_estimates = did_fatalities_splm_coef$Estimate,
  confint_lower = did_fatalities_splm_coef$CI_lower_Bonferroni,
  confint_upper = did_fatalities_splm_coef$CI_upper_Bonferroni,
  coef_names = did_fatalities_splm_coef$Var,
  skipvars = c(
    "Alpha_share", 
    "lambda",
    "rho",
    "log(D_Infections_daily_7dsum_per100000_lag2weeks)",
    "vacc_cum_per100000_lag2weeks"
    ),
  lwd = 13,
  pch = 19,
  auto_color = TRUE
)
# Plot with point estimates and confidence intervals

swash documentation built on Feb. 15, 2026, 5:07 p.m.