This article describes how to create a new variable containing the Propensity Weights for each case in the data from a model that is a binary classifier (e.g., a Machine Learning or Regression model that has 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.

Please note these steps require a **Displayr **license.

## Method

- Select the machine learning or regression output on a
**Page**. - Go to the
**object inspector**and click**Data > Save Variable(s) > Propensity Weight**.

## 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 off 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 off 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))\).