Skip to contents

Computes the weighted mean outcome, average treatment effect (ATE), or average treatment effect on the treated (ATT). Y must be provided, and users can either supply an `lbc_net` object (which automatically extracts weights and treatment assignments) or manually provide `Tr` and `wt`.

Usage

# S3 method for class 'lbc_net'
est_effect(object = NULL, Y, Tr = NULL, wt = NULL, type = "ATE", ...)

Arguments

object

Optional. An object of class `"lbc_net"` generated by lbc_net. If provided, `Tr` and `wt` will be extracted automatically.

Y

Numeric vector of observed outcomes.

Tr

Optional. Numeric binary vector (0/1) indicating treatment assignment. Required if `object` is NULL.

wt

Optional. Numeric vector of inverse probability weights. Required if `object` is NULL.

type

Character string specifying the desired estimate. The default is `"ATE"`, which computes the average treatment effect. Setting `type = "ATT"` estimates the average treatment effect on the treated, while `type = "Y"` returns the weighted mean outcome for the treated group (`Tr = 1`). If an object is provided, the estimate will be consistent with the object's specification, but users can also select `"Y"`.

...

Additional arguments passed to the specific method.

Value

A numeric value representing the estimated quantity.

Details

It is designed for estimating causal effects in settings with continuous or binary outcomes. For survival outcomes, users should apply appropriate survival analysis models, such as a weighted Cox model or other time-to-event estimation methods.

Inverse Probability Weighting (IPW) is used to estimate the treatment effect, where the weight for subject \(i\) is: $$ W_i = \frac{\omega^*(p_i)}{ T_i p_i + (1 - T_i)(1 - p_i) }. $$

The frequency weight function \(\omega^{*}(p_i)\) determines the target population: setting \(\omega^{*}(p_i) = 1\) yields the Average Treatment Effect (ATE), while choosing \(\omega^{*}(p_i) = p_i\) results in the Average Treatment Effect on the Treated (ATT).

The population-level treatment effect is estimated as: $$ \Delta = \frac{E(\omega^*(p_i) \Delta_i)}{E(\omega^*(p_i))}, $$ where \(\Delta_i = E[Y_i(1) - Y_i(0) \mid \mathbf{Z}_i]\) represents the individual conditional treatment effect.

The inverse probability weighted (IPW) estimator for ATE or ATT follows: $$ \hat{\Delta} = \frac{\sum_{i=1}^N T_i W_i Y_i}{\sum_{i=1}^N T_i W_i} - \frac{\sum_{i=1}^N (1-T_i) W_i Y_i}{\sum_{i=1}^N (1-T_i) W_i}. $$

Note

This function does not compute variance estimates due to computational cost. Users can obtain variance estimates via bootstrapping, ensuring that inverse probability weights (`wt`) are recomputed using `lbc_net()` for each resampled dataset. To improve efficiency, consider using parallel computing with the `foreach` and `doParallel` package.

Examples

# Simulated example
set.seed(123)
Y <- rnorm(100)  # Random outcome
Tr <- rbinom(100, 1, 0.5)  # Random treatment assignment
wt <- runif(100, 0.5, 1.5)  # Random inverse probability weights

# Manually specify Tr and wt
est_effect(Y = Y, Tr = Tr, wt = wt, type = "Y")
#> [1] 0.1200686
est_effect(Y = Y, Tr = Tr, wt = wt, type = "ATE")
#> [1] 0.1134007
est_effect(Y = Y, Tr = Tr, wt = wt, type = "ATT")
#> [1] 0.1009665

if (FALSE) { # \dontrun{
# Use an lbc_net object
model <- lbc_net(data = data, formula = Tr ~ X1 + X2 + X3 + X4)
est_effect(object = model, Y, type = "Y")

} # }