ate_weights: Calculate average treatment effect using inverse propensity...

View source: R/ate_weights.R

ate_weightsR Documentation

Calculate average treatment effect using inverse propensity score weighting

Description

Propensity scores (PS) are calculated using fitted values obtained in a logistic regression. The inverse propensity score weighting is subsequently conducted by 1/PS for the factor level that corresponds to 1 and by 1/(1-PS) for the factor level that corresponds to 0.

Usage

ate_weights(data, vars, prop.var)

Arguments

data

Character vector specifying rownames of the table (empty columns should be named with "").

vars

variables tested for Influence on outcome. NAs within vars should be replaced with a pseudocategory, e.g. "missing". A more sophisticated approach with multiple imputation of missing values followed by propensity score calculation is provided with the mi_PS function of this package.

prop.var

variable for which propensity scores should be calculated

Examples

# example weights calculation with the lung dataset
df <- survival::lung
df$sex <- factor(df$sex)
df$ph.ecog <- ifelse(is.na(df$ph.ecog), "Missing", df$ph.ecog)
df$ph.karno <- ifelse(is.na(df$ph.karno), "Missing", df$ph.karno)
df$weights.ate <- ate_weights(data = df, vars = c("age", "ph.ecog", "ph.karno"), prop.var = "sex")

MBender1992/emR documentation built on Feb. 18, 2025, 9:21 a.m.