Skip to contents

Takes a named list of treatment effect estimates (either model objects or manual estimate/SE pairs) and produces a formatted comparison data frame with point estimates, standard errors, confidence intervals, and significance stars.

Usage

compare_estimators(estimators, coef_name = NULL, conf_level = 0.95, digits = 3)

Arguments

estimators

A named list where each element is either:

  • A model object (from lm, fixest::feols, etc.) from which the coefficient specified by coef_name will be extracted.

  • A list with elements $estimate (numeric) and $se (numeric standard error).

coef_name

Character string. The coefficient name to extract from model objects. Required when any element of estimators is a model object. Ignored for manual estimate/SE pairs.

conf_level

Numeric. Confidence level for intervals. Default is 0.95.

digits

Integer. Number of digits for rounding. Default is 3.

Value

A data frame with columns:

model

Character. Name of the estimator.

estimate

Numeric. Point estimate.

se

Numeric. Standard error.

ci_lower

Numeric. Lower bound of the confidence interval.

ci_upper

Numeric. Upper bound of the confidence interval.

stars

Character. Significance stars ("***" p < 0.001, "**" p < 0.01, "*" p < 0.05, "." p < 0.10).

Examples

if (FALSE) { # \dontrun{
# From model objects
m1 <- lm(mpg ~ am, data = mtcars)
m2 <- lm(mpg ~ am + wt, data = mtcars)

compare_estimators(
  estimators = list("Bivariate" = m1, "Adjusted" = m2),
  coef_name = "am"
)

# From manual estimates
compare_estimators(
  estimators = list(
    "DID"    = list(estimate = 2.5, se = 0.8),
    "SC"     = list(estimate = 2.1, se = 1.0),
    "SDID"   = list(estimate = 2.3, se = 0.9)
  )
)
} # }