This article describes how to create a new variable containing the Propensity Weights for each case in a dataset from a binary classifier (e.g., a Machine Learning or Regression model with an outcome variable with only two categories, such as a Binary Logit regression).
Requirements
- A machine learning or regression output in your Displayr document that has an outcome variable with only two categories.
Method
- Select the machine learning or regression output on a Page.
- Go to Properties
> Data > Save Variable(s) > Propensity Weight.
A new variable with the propensity weight will appear in the Data Sources tree.
Technical Details
Assume the outcome variable \(Y\) is an ordinal or nominal variable that has two categories (classes) labeled 0 and 1, with 1 being the label for the positive class. The propensity score is calculated based on the estimated probabilities of being in the positive class \(\widehat{p}(x) = P(Y = 1 |X = x)\) where \(X\) denotes all the predictor variables used in the Regression or Machine Learning model and \(x\) being the observed predictors for each case. Then, the propensity weight is calculated based on the observed category each case belongs to in the outcome variable. Cases with \(Y = 1\) are allocated a weight of \(1/\widehat{p}(x)\) while cases with \(Y = 0\) are allocated a weight of \(1/(1 - \widehat{p}(x))\).
UPCOMING WEBINAR: From Thousands of Tables To One Clear Story: using AI in survey analysis