deli provides M-estimation and empirical sandwich variance estimation in R.
M-estimators express a wide range of statistical procedures as the solution to a set of estimating equations, and the empirical sandwich estimator supplies their variance without further derivation. deli offers a general interface for both custom and built-in estimating equations, covering basic statistics, regression, causal inference, survival analysis, measurement error, and pharmacokinetics.
deli is an R port of the Python delicatessen library. The Translating from Python article maps the Python interface onto deli and documents where the R surface differs by convention.
Install deli from CRAN with:
install.packages("deli")Install the development version of deli from GitHub with:
# install.packages("pak")
pak::pak("r-causal/deli")The quickest way to fit a model is m_estimate(), which takes a
formula, a data frame, and a built-in estimating equation, then
constructs and solves the estimator in a single call. Here is a linear
regression on the mtcars data:
library(deli)
fit <- m_estimate(
mpg ~ wt + hp,
data = mtcars,
.ee = ee_regression,
model = "linear"
)
fit
#> <MEstimator>
#> Parameters: 3
#> Observations: 32
#> Coefficients:
#> (Intercept): 37.2273
#> wt: -3.8778
#> hp: -0.0318Standard errors come from the sandwich variance estimator, so the usual accessors report robust inference without additional arguments:
summary(fit)
#> ── MEstimator Results ──────────────────────────────────────────────────────────
#> Observations: 32
#> Parameters: 3
#>
#> Estimate Std.Err Z-score 95% LCL 95% UCL P-value S-value
#> (Intercept) 37.2273 1.9389 19.2000 33.4271 41.0275 <2e-16 270.5101
#> wt -3.8778 0.6199 -6.2553 -5.0929 -2.6628 3.97e-10 31.2310
#> hp -0.0318 0.0066 -4.7807 -0.0448 -0.0187 1.75e-06 19.1269vcov() returns the sandwich variance-covariance matrix and confint()
returns Wald confidence intervals. deli also supplies
broom tidiers, tidy(), augment(),
and glance().
The package website collects the reference documentation and articles. Start with Getting Started, then see the articles on custom estimating equations, regression models, and causal inference for worked examples.