Skip to contents

Extracts and standardizes estimates, standard errors, confidence intervals, and p-values from a wide range of causal inference model objects into a consistent tidy data frame. Supports fixest, ivreg, rdrobust, MatchIt, synthdid, grf, and more.

Usage

tidy_causal(model, term = NULL, conf_level = 0.95, add_model_info = TRUE)

Arguments

model

A model object. Supported classes:

  • fixest (from fixest)

  • ivreg (from ivreg)

  • rdrobust (from rdrobust)

  • lm, glm (from base R)

  • causal_forest (from grf)

  • synthdid_estimate (from synthdid)

  • Named numeric list with estimate and se elements

term

Character or NULL. Specific term/coefficient to extract. If NULL, extracts all available terms.

conf_level

Numeric. Confidence level. Default 0.95.

add_model_info

Logical. Add model class, n observations, R-squared if available. Default TRUE.

Value

A data frame with columns:

term

Term name.

estimate

Point estimate.

std_error

Standard error.

t_stat

t-statistic.

p_value

Two-sided p-value.

ci_lower

Lower confidence bound.

ci_upper

Upper confidence bound.

n_obs

Sample size (if available).

model_class

Class of the input model.

Examples

# OLS
mod <- lm(mpg ~ am + wt, data = mtcars)
tidy_causal(mod, term = "am")
#>   term    estimate std_error      t_stat   p_value  ci_lower ci_upper n_obs
#> 1   am -0.02361522  1.545645 -0.01527855 0.9879146 -3.053024 3.005794    32
#>   model_class
#> 1          lm

# fixest
if (FALSE) { # \dontrun{
mod2 <- feols(mpg ~ am + wt | cyl, data = mtcars)
tidy_causal(mod2)
} # }