Code Monkey home page Code Monkey logo

psweight's Introduction

psweight: IPW- and CBPS-type propensity score reweighting, with various extensions

Description

psweight() is a Mata class that computes inverse-probability weighting (IPW) weights for average treatment effect, average treatment effect on the treated, and average treatment effect on the untreated estimators for observational data. IPW estimators use estimated probability weights to correct for the missing data on the potential outcomes. Probabilities of treatment--propensity scores--are computed for each observation with one of variety of methods, including logistic regression (traditional IPW), covariate-balancing propensity scores (CBPS), penalized covariate-balancing propensity scores (PCBPS), prognostic score-balancing propensity scores, and other methods. It also constructs balance tables and assesses the distribution of the IPW weights.

psweight.ado is a Stata command that offers Stata users easy access to the class. However, the class offers more flexibility and can conduct some analyses unavailable with the Stata command.

The model

psweight::solve() and psweight subcmd solve for propensity score model coefficients, propensity scores, and IPW weights as follows:

The first step involves computing coefficients for the propensity score model, b. The propensity score model takes the form of a logit regression model. Specifically, the propensity score for each row in the data is defined as

     p = invlogit(X * b')

where X is the vector of matching variables (tmvarlist) for the respective row.

You specify a subcmd to control how the vector b is computed in the internal numerical optimization problem. As discussed in Kranker, Blue, and Vollmer Forrow (2019), we can set up optimization problems to solve for the b that produces the best fit in the propensity score model, the b that produces the best balance on matching variables, the b that produces the best balance on prognostic scores, or something else. The subcmd also determines how the term "best balance" is defined in the previous sentence. That is, for a given subcmd, we can generically define b as the vector that solves the problem:

     b = argmin L(X,T,W)

where L(X,T,W) is a "loss function" that corresponds to the specified subcmd (e.g., logit regression or CBPS), given the data (X,T) and a vector of weights (W). (The weights are computed using the propensity scores, as we describe below. The propensity scores are calculated using b, the data, and the formula given above.) The available subcmds are listed in the documentation and include logit regression and CBPS (Imai and Ratkovic 2014).

In Kranker, Blue, and Vollmer Forrow (2019), we proposed adding a "penalty" to the loss function that lets you effectively prespecify the variance (or higher-order moments) of the IPW weight distribution. By constraining the distribution of the weights, you can choose among alternative sets of matching weights, some of which produce better balance and others of which yield higher statistical power. The penalized method solves for b in:

     b = argmin L(X,T,W) + f(W)

where f(W) is a smooth, flexible function that increases as the vector of observation weights (W) becomes more variable. The penalty options control the functional form of f(W); see details below.

Once the b is estimated, we can compute propensity scores (p) for each observation with the formula given above and the observation's matching variables (tmvarlist). The propensity scores are returned in a variable named _pscore.

Once propensity scores are computed for each observation, we can compute IPW "matching weights" for each observation. The formulas for the IPW weights depend on whether you request weights for estimating the average treatment effect (ate), the average treatment effect on the treated (atet), or the average treatment effect on the untreated (ateu).

Next, the weights are normalized to have mean equal to 1 in each group, and returned in the variable named _weight_mtch.

Finally, the final weights (a variable named _weight) are set equal to: _weight = W :* _weight_mtch, where W are the sample weights.

Author

Keith Kranker

The code for implementing the CBPS method is based on work by Fong et al. (2018), namely the CBPS package for R. I also reviewed the Stata CBPS implementation by Filip Premik.

Suggested Citation

  • Kranker, Keith, Laura Blue, and Lauren Vollmer Forrow. “Improving Effect Estimates by Limiting the Variability in Inverse Propensity Score Weights.” The American Statistician, Volume 75, 2021, Issue 3, pp 276-87. https://doi.org/10.1080/00031305.2020.1737229.

or

  • Kranker, Keith. "psweight: IPW- and CBPS-type propensity score reweighting, with various extensions," Statistical Software Components S458657, Boston College Department of Economics, 2019. Available at https://ideas.repec.org/c/boc/bocode/s458657.html.

Source code is available at https://github.com/kkranker/psweight. Please report issues at https://github.com/kkranker/psweight/issues.

Installation

To install official releases from SSC, type this from your Stata command line:

. net describe psweight, from(http://fmwww.bc.edu/RePEc/bocode/p)

To install the latest version from Github, type this from your Stata command line:

. net from https://raw.githubusercontent.com/kkranker/psweight/master/

References

  • Fong, C., M. Ratkovic, K. Imai, C. Hazlett, X. Yang, and S. Peng. 2018. CBPS: Covariate Balancing Propensity Score, Package for the Rprogramming langauage, The Comprehensive R Archive Network.Available at: https://CRAN.R-project.org/package=CBPS

  • Imai, K. and M. Ratkovic. 2014. "Covariate Balancing Propensity Score."Journal of the Royal Statistical Society: Series B (StatisticalMethodology), 76(1): 243–263, doi:10.1111/rssb.12027.

  • Kranker, Keith, Laura Blue, and Lauren Vollmer Forrow. “Improving Effect Estimates by Limiting the Variability in Inverse Propensity Score Weights.” The American Statistician, Volume 75, 2021, Issue 3, pp 276-87. https://doi.org/10.1080/00031305.2020.1737229.

psweight's People

Contributors

kkranker avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

psweight's Issues

Impacts

Once we have standard errors (#1), add impact estimation (single- or multi-outcomes) and/or regression adjusted means ("pomeans" in Stata's teffects lingo) inside optimization.

export table psweight call balanceresults()

Dear Keith,

what a fantastic Stata package. It helps me with my research a lot.

One question I struggle with:
How can I export the balance table produced by psweight call balanceresults() into TeX or excel?

Thanks so much in any case in advance.

Best wishes,
Daniel

Standard errors for propensity score model coefficients

[someone] asks,

... Unfortunately, I am unable to recover the standard errors, nor the test statistic to enable me tell the significance of the estimated Propensity score model coefficients. On with my web search again, I came across your GITHUB page (https://github.com/kkranker/psweight) where you indicated some potential improvements and extensions.

I am by this letter (email) writing to ask if this has been made possible and if so, is there a way I can at least retrieve the standard errors to match the displayed coefficients of the covariates estimated from the propensity score model?....

Predict command

predict command to re-generate predicted values or apply them out-of-sample. Maybe stop generating new variables by default.

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.