knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
nawtilus provides a procedure for the navigated weighting (NAWT) proposed by Katsumata (2020), which estimates a pre-specified parameter of interest (e.g., the average treatment effects or the average treatment effects on the treated) with the inverse probability weighting where propensity scores are estimated using estimating equations suitable for the parameter of interest. It also provides several tools for summarizing and checking the estimation results, including a covariate balance check and an inverse probability weights plot.
Katsumata, Hiroto. 2020. "Navigated Weighting to Improve Inverse Probability Weighting for Missing Data Problems and Causal Inference." Working Paper, arxiv:2005.10998.
Katsumata, Hiroto. 2020. nawtilus: Navigated Weighting for the Inverse Probability Weighting. R package version 0.1.4. https://CRAN.R-project.org/package=nawtilus.
You can install the released version of nawtilus from CRAN with:
install.packages("nawtilus")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("hirotokatsumata/nawtilus")
This example shows how to use nawtilus for estimation of parameter of interest.
First, load the package and make toy data.
# Load the package library(nawtilus) # Make toy data # ATT estimation # True ATT is 10 tau <- 10 set.seed(12345) n <- 1000 X <- matrix(rnorm(n * 4, mean = 0, sd = 1), nrow = n, ncol = 4) prop <- 1 / (1 + exp(X[, 1] - 0.5 * X[, 2] + 0.25 * X[, 3] + 0.1 * X[, 4])) treat <- rbinom(n, 1, prop) y <- 210 + 27.4 * X[, 1] + 13.7 * X[, 2] + 13.7 * X[, 3] + 13.7 * X[, 4] + tau * treat + rnorm(n) # Data frame df <- data.frame(X, treat, y) colnames(df) <- c("x1", "x2", "x3", "x4", "treat", "y")
Then, specify a model for propensity score estimation.
formula_c <- as.formula(treat ~ x1 + x2 + x3 + x4)
Fit the model for the average treatment effects on the treated (ATT) estimation using nawt()
with the default setting (a power weighting function with α = 2).
# Power weighting function with alpha = 2 fit <- nawt(formula = formula_c, outcome = "y", estimand = "ATT", method = "score", data = df, alpha = 2)
You can summarize the results easily with summary()
.
summary(fit)
Note that the estimated coefficients except for est
are for the propensity score estimation.
Check covariate balance between the treatment and control groups before and after the NAWT with cbcheck()
.
oldpar <- par(no.readonly = TRUE) # Just for adjusting plot margins par(mar = c(5.1, 5.1, 4.1, 2.1)) # Just for adjusting plot margins cbcheck(fit) par <- oldpar # Just for adjusting plot margins
Let's compare the inverse probability weights estimated by the nawt with those estimated by the standard logistic regression with plot()
.
plot(fit)
Finally, check the weights used in propensity score estimation and distribution of the estimated propensity scores in the NAWT with plot_omega()
.
plot_omega(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.