causalgenerics is the shared generics package for the r-causal ecosystem. It provides a near-zero-dependency home for the S3 generics that packages such as propensity, halfmoon, positively, and balancing register methods on. Owning the generic definitions in one place means that attaching several r-causal packages at once produces no masking: each package contributes methods to a common generic instead of redefining the function.
The package is modeled on the generics package, which provides commonly used S3 generics for the same reason: so that packages can share a definition instead of each defining their own.
You can install the released version of causalgenerics from CRAN with:
install.packages("causalgenerics")You can install the development version from GitHub with:
# install.packages("pak")
pak::pak("r-causal/causalgenerics")Most users will get causalgenerics as a dependency of another r-causal package rather than installing it directly.
causalgenerics owns the following generics:
ipw(): bring-your-own-model inverse probability
weighted estimation of causal effects from a weighting model and a
weighted outcome model.ess(): the effective sample size of a set of weights or
a fitted model.is_causal_wt(), estimand(), and
estimand<-(): accessors for the metadata carried by
causal weight vectors.The generics are intentionally minimal. Method-specific arguments are
passed through ..., and the concrete weight classes live in
the packages that own them.
Packages in the r-causal ecosystem import causalgenerics and register their methods against these generics. Because the generic is defined once, a user can attach any combination of those packages without one masking another.