
Unified Causal Model Summary
causal_summary.RdReturns a clean one-row data frame with the key causal estimate, standard error, confidence interval, p-value, number of observations, and outcome variable name. This is useful for programmatic comparison of many models.
Arguments
- model
A fitted model object. Supported:
lm,glm,fixest,ivreg, and any model class with asummary()method that returns a coefficient table.- method_name
Character or
NULL. Label for the estimation method. IfNULL, the model class is used.- digits
Integer. Number of decimal places for display. Default
3.- conf_level
Numeric. Confidence level for the interval. Default
0.95.- ...
Additional arguments passed to
broom::tidy()if available.
Value
An object of class "causal_summary" inheriting from "data.frame".
Columns: method, term, estimate, std_error, ci_lower,
ci_upper, p_value, n_obs, outcome.
Details
One-Line Tidy Summary for Any Causal Model
Extracts a standardised single-row data frame from any causal inference model (lm, glm, fixest, ivreg, etc.). Works via broom if available, with manual fallback extraction for common model classes. A custom S3 print method provides a clean, console-friendly summary.
Examples
set.seed(1)
n <- 300
x <- rnorm(n)
y <- 2 * x + rnorm(n)
df <- data.frame(y = y, x = x)
m_lm <- lm(y ~ x, data = df)
cs <- causal_summary(m_lm, method_name = "OLS")
print(cs)
#>
#> === Causal Summary ===
#> Method : OLS
#> Outcome : y
#> Term : x
#> Estimate: 2.026 (SE: 0.063)
#> 95% CI : [1.902, 2.149]
#> p-value : 0.0000
#> N obs : 300
#> ======================
#>
if (requireNamespace("fixest", quietly = TRUE)) {
m_fe <- fixest::feols(y ~ x, data = df)
cs2 <- causal_summary(m_fe, method_name = "OLS (fixest)")
print(cs2)
}
#>
#> === Causal Summary ===
#> Method : OLS (fixest)
#> Outcome : y
#> Term : x
#> Estimate: 2.026 (SE: 0.063)
#> 95% CI : [1.902, 2.149]
#> p-value : 0.0000
#> N obs : 300
#> ======================
#>