Shared Generics for the 'r-causal' Ecosystem

A home for the S3 generics shared across the 'r-causal' ecosystem, including 'propensity', 'halfmoon', 'positively', and 'balancing'. Owning the generic definitions in one place lets those packages register methods without masking one another when several are attached at once. The generics cover inverse probability weighted estimation, effective sample size, and the metadata carried by causal weight vectors, and the package supplies the abstract causal weight class and the result class those estimates are returned in, together with the methods both classes carry, so that the ecosystem packages inherit them rather than writing their own. The design follows that of the 'generics' package, which provides commonly used S3 generics for the same purpose: letting packages share a single definition instead of each defining its own.


causalgenerics

R-CMD-check

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.

Installation

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.

Generics

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.

How ecosystem packages depend on it

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.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("causalgenerics")

0.1.0 by Malcolm Barrett, 3 months ago


https://github.com/r-causal/causalgenerics, https://r-causal.github.io/causalgenerics/


Report a bug at https://github.com/r-causal/causalgenerics/issues


Browse source code at https://github.com/cran/causalgenerics


Authors: Malcolm Barrett [aut, cre, cph] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports stats, vctrs

Suggests testthat, withr


See at CRAN