Thin wrapper around WeightIt::weightit() exposing the full
WeightIt method palette ("glm", "cbps",
"ebal", "ps", "energy", "optweight",
and any future additions). Provides MORIE callers with a stable
morie_* entry point for balancing weights while preserving
the underlying object so callers can pipe into
survey::svyglm or cobalt::bal.tab downstream.
Usage
morie_causal_weighting(
data,
treatment,
covariates,
method = "glm",
estimand = c("ATE", "ATT", "ATC"),
...
)Arguments
- data
A data frame.
- treatment
Name of the treatment column (binary, multinomial, or continuous depending on
method).- covariates
Character vector of covariate names.
- method
One of
"glm","cbps","ebal","ps","energy","optweight", or any other method accepted byWeightIt::weightit().- estimand
One of
"ATE","ATT","ATC"; defaults to"ATE".- ...
Additional arguments forwarded to
WeightIt::weightit().
Value
Named list with elements weights (numeric vector),
propensity_scores (numeric vector or NULL),
method, estimand, ess (effective sample
size), and weightit (the original WeightIt object).
Details
Hard-errors if WeightIt is not installed – the multi-method weighting machinery has no compact inline equivalent.
References
Greifer N (2024). WeightIt: Weighting for Covariate Balance in Observational Studies. R package version 1.4.0.
Examples
set.seed(1)
df <- data.frame(d = rbinom(80, 1, 0.4), x1 = rnorm(80), x2 = rnorm(80))
df$y <- df$d + df$x1 + rnorm(80)
res <- try(morie_causal_weighting(df, "d", c("x1", "x2")))
if (!inherits(res, "try-error")) str(res, max.level = 1)
#> List of 6
#> $ weights : num [1:80] 1.78 1.61 1.76 2.33 1.73 ...
#> $ propensity_scores: num [1:80] 0.437 0.38 0.431 0.43 0.422 ...
#> $ method : chr "glm"
#> $ estimand : chr "ATE"
#> $ ess : num 77.9
#> $ weightit :List of 10
#> ..- attr(*, "Mparts")=List of 6
#> ..- attr(*, "class")= chr "weightit"
