# 4 Weighting

weight
verb
1. hold (something) down by placing a heavy object on top of it.
2. attach importance or value to.

Propensity score weighting is the approach to using propensity scores as weights in other statistical models such as regression or ANOVA. Like stratification (see Chapter 2), propensity score weighting has the advantage of all observations. In section 1.3.2 we introduced four different treatment estimators. The histograms used to conceptually explain what observations are included, or not included, in their calculation used propensity score weights. In this chapter will discuss the mathematical details of how those weights are calculated and applied, include the R code to generate the estimates.

We will present a formula for each of the treatment effects we wish to estimate. These formulas define the weights. Once we have the weights we can use them in a statistical model or using the following formula to estimate the treatment effect.

\begin{equation} \begin{aligned} Treatment\ Effect = \frac{\sum Y_{i}Z_{i}w_{i}}{\sum Z_{i} w_{i}} - \frac{\sum Y_{i}(1 - Z_{i}) w_{i}}{\sum (1 - Z_{i}) w_{i} } \end{aligned} \tag{4.1} \end{equation}

For equation (4.1), $$w$$ is the weight (as defined in the following sections), $$Z_i$$ is the treatment assignment such that $$Z = 1$$ is treatment and $$Z = 0$$ is control, and $$Y_i$$ is the outcome.

## 4.1 Estimate Propensity Scores

To begin, we estimate the propensity scores, here using logistic regression.

data("lalonde", package = 'Matching')
lr_out <- glm(formula = lalonde.formu,
data = lalonde,
outcome = lalondere78, weights = atc_weights) ## 1391.02 ## 4.6 Average Treatment Effect Among the Evenly Matched (ATM) \begin{equation} \begin{aligned} w_{ATM} = \frac{min\{\pi_i, 1 - \pi_i\}}{Z_i \pi_i (1 - Z_i)(1 - \pi_i)} \end{aligned} \tag{4.5} \end{equation} atm_weights <- psa::calculate_ps_weights(treatment = lalondetreat,
ps = lalonde$lr_ps, estimand = 'ATM') ### 4.6.1 Check Balance with ATM Weights glm(formula = lalonde.formu, data = lalonde, family = quasibinomial(link = 'logit'), weights = atm_weights ) |> summary() ## ## Call: ## glm(formula = lalonde.formu, family = quasibinomial(link = "logit"), ## data = lalonde, weights = atm_weights) ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 1.657e-01 2.129e+00 0.078 0.938 ## age -2.418e-02 8.893e-02 -0.272 0.786 ## I(age^2) 4.192e-04 1.465e-03 0.286 0.775 ## educ 6.308e-02 4.304e-01 0.147 0.884 ## I(educ^2) -3.347e-03 2.420e-02 -0.138 0.890 ## black 1.480e-02 3.577e-01 0.041 0.967 ## hisp -3.495e-02 5.203e-01 -0.067 0.946 ## married -3.486e-03 2.736e-01 -0.013 0.990 ## nodegr -4.659e-02 3.825e-01 -0.122 0.903 ## re74 -2.333e-05 7.526e-05 -0.310 0.757 ## I(re74^2) 8.298e-10 2.510e-09 0.331 0.741 ## re75 -7.419e-06 9.758e-05 -0.076 0.939 ## I(re75^2) 7.957e-10 4.775e-09 0.167 0.868 ## u74 -6.630e-02 4.360e-01 -0.152 0.879 ## u75 -3.051e-02 3.436e-01 -0.089 0.929 ## ## (Dispersion parameter for quasibinomial family taken to be 0.7850194) ## ## Null deviance: 467.94 on 444 degrees of freedom ## Residual deviance: 467.73 on 430 degrees of freedom ## AIC: NA ## ## Number of Fisher Scoring iterations: 3 ### 4.6.2 Estimate ATM lm(formula = re78 ~ treat, data = lalonde, weights = atm_weights) |> summary() ## ## Call: ## lm(formula = re78 ~ treat, data = lalonde, weights = atm_weights) ## ## Weighted Residuals: ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 4504.6 459.8 9.797 < 2e-16 *** ## treat 1707.7 648.8 2.632 0.00878 ** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 5960 on 443 degrees of freedom ## Multiple R-squared: 0.0154, Adjusted R-squared: 0.01318 ## F-statistic: 6.928 on 1 and 443 DF, p-value: 0.008783 psa::treatment_effect(treatment = lalonde$treat,
weights = atm_weights)
## 1707.69