GithubHelp home page GithubHelp logo

crazyoumashu / multilevelmatching Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shuyang-stat/multilevelmatching

0.0 1.0 0.0 575 KB

Propensity score Matching and Subclassification with 3 or more Treatments

Home Page: https://shuyang1987.github.io/multilevelMatching/

R 100.00%

multilevelmatching's Introduction

CRAN_Status_Badge lifecycle Travis-CI Build Status AppveyorCI Build status Coverage status

multilevelMatching

Propensity Score Matching and Subclassification in Observational Studies with Multi-Level Treatments

Installation:

devtools::install_github("shuyang1987/multilevelMatching")

Visit the package website

Description

This package implements methods to estimate causal effects from observational studies when there are 2+ distinct levels of treatment (i.e., “multilevel treatment”) using matching estimators, as introduced in Yang et al. (2016) Biometrics. Matching on covariates, and matching or stratification on modeled propensity scores, are made available. These methods require matching on only a scalar function of generalized propensity scores. For more information, see the Extended Description below or the main paper:

  • Yang, S., Imbens G. W., Cui, Z., Faries, D. E., & Kadziola, Z. (2016) Propensity Score Matching and Subclassification in Observational Studies with Multi-Level Treatments. Biometrics, 72, 1055-1065. https://doi.org/10.1111/biom.12505

Visit the package website

Estimators available

  • Matching on raw covariates: via multiMatch() and multilevelMatchX()
  • Matching on estimated propensity scores: via multiMatch() and multilevelGPSMatch()
    • using ordinal logistic regression
    • using multinomial logistic regression
      • This method also provides two types of variance estimates
    • using user-provided propensity score values
      • This method does not provide variance estimates
  • Stratification on propensity scores: via multilevelGPSStratification()

Tutorial

This is a brief tutorial; an extended tutorial is provided in the vignette for version 1.0.0. We will use the dataset provided with this package

library(multilevelMatching)
simulated_data <- multilevelMatching::simulated_data
knitr::kable(head(simulated_data), digits = 2)
outcome treatment covar1 covar2 covar3 covar4 covar5 covar6
-5.13 1 -0.87 0.24 0.23 -2.89 0.21 0
-3.03 1 0.27 -0.35 -0.40 -2.21 0.07 1
3.05 1 1.42 1.32 -1.20 0.06 1.26 1
-6.09 1 -1.39 -1.07 1.12 -2.36 0.00 0
-2.46 1 -1.15 0.95 0.51 -2.68 0.07 0
-0.32 1 0.27 0.42 -0.45 2.43 0.60 0

We restructure the dataframe slightly, and use identifying names for the observations:

outcome <- simulated_data$outcome
treatment <- simulated_data$treatment
covar_matrix <- as.matrix(
  simulated_data[ ,names(simulated_data) %in% paste0("covar", 1:6)]
)
identifying_names <- paste0(
  rep(letters[1:25],each = 12), rep(letters[1:25], 12)
)
names(treatment) <- identifying_names

Matching on covariates

set.seed(123)
fit <- multiMatch(
  Y = outcome,
  W = treatment,
  X = covar_matrix,
  match_on = "covariates"
)

fit
#> -------------- Causal estimates ---------------
#>         Param Trt1 Trt2   Estimate  Variance
#> 1 EY(2)-EY(1)    1    2 0.07927361 0.1792186
#> 2 EY(3)-EY(1)    1    3 0.86264929 0.1634754
#> 3 EY(3)-EY(2)    2    3 0.78337567 0.3221616
#> --- Matching on 'covariates' with M=1, J=1 ---

Matching on the Estimated Generalized Propensity Score (GPS)

Propensity scores can be estimated with either of the following options

  • match_on="multinom" for multinomial logistic regression from nnet::multinom()
  • match_on="polr" for ordinal logistic regression from MASS::polr()
  • Or, estimated propensity scores can be supplied via the X argument when match_on="existing"
match_on <- "multinom"
# match_on <- "polr" 

set.seed(123)
fit2 <- multiMatch(
  Y = outcome,
  W = treatment,
  X = covar_matrix,
  match_on = match_on,
  trimming = FALSE
)

fit
#> -------------- Causal estimates ---------------
#>         Param Trt1 Trt2   Estimate  Variance
#> 1 EY(2)-EY(1)    1    2 0.07927361 0.1792186
#> 2 EY(3)-EY(1)    1    3 0.86264929 0.1634754
#> 3 EY(3)-EY(2)    2    3 0.78337567 0.3221616
#> --- Matching on 'covariates' with M=1, J=1 ---

Please see the vignette for an extended tutorial.

Extended Description

Matching with 3 or more levels of treatment

In setting with where 3 or more levels of treatment (i.e., multilevel treatment), our goal is to estimate pairwise average treatment effects from a common population using matching methods.

This goal can not be acheived by matching one treatment with another one at a time, since the pairwise matched samples may differ from the target population systematically, and thus they are not compatitable. One implication is that from this approach, it is possible that treatment A is better than treatment B, treatment B is better than treatment C, and treatment C is better than treatment A.

We focus on estimating the average values of potential outcomes for each treatment level by matching methods, which facilitate estimation of pairwise average treatment effects for a common population.

The estimation methods include generalized propensity score (GPS) matching, GPS stratification, matching with the full set of covariates, matching with the full set of GPS vector. Note that GPS matching and GPS straticication only require matching on a scalar function when estimating the average value of the potential outcome at a particular treatment level, which reduces the matching dimension to one, regardless of the number of covariates and the number of treatment levels.

In order to ensure sufficient overlap, Crump et al. (2009)’s trimming method can be extended to this setting as well.

News

See the News site for the changelog.

A note on multiMatch()

The multiMatch() function may return slightly different estimates than the original 2 matching functions in certain circumstances. We attempt to ensure that the functions implement are identical methods up to perhaps random number generation. Please file an issue if you have any questions or concerns.

multilevelmatching's People

Contributors

barkleybg avatar shuyang-stat avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.