Description Usage Arguments Details Value Author(s) References See Also Examples

This function calculates weighted means of covariates where weights in inverse propensity weights and then examines the differences in the weighted means across treated and control units as a diagnostic for covariate balance.

1 2 3 4 5 |

`pscore.formula` |
A formula expression for the propensity score model. See the documentation of |

`pscore.family` |
A description of the error distribution and link function to be used for the propensity score model. See the documentation of |

`treatment.var` |
A character variable giving the name of the binary treatment variable in |

`outcome.var` |
A character variable giving the name of the outcome variable in |

`data` |
A |

`divby0.action` |
A character variable describing what action to take when some estimated propensity scores are less than |

`divby0.tol` |
A scalar in |

`nboot` |
Number of bootrap replications used for calculating bootstrap standard errors. If |

`suppress.warnings` |
Logical value indicating whether warnings from the |

`...` |
Further arguments to be passed. |

This function provides diagnostic information that allows a
user to judge whether the inverse propensity weights generated from a
particular generalized additive model specification result in
covariate balance across treated and control groups. The function is
intended to be used before the `estimate.ATE`

function in order
to find a specification for the propensity score model that results in
sufficient covariate balance.

The weighted mean differences between all variables in the dataset
passed to `balance.IPW`

are reported along with a z-statistics
for these weighted differences. Univariate mean covariate balance is
decreasing in the absolute value of the z-statistics (z-statistics
closer to 0 imply better univariate mean balance).

Printing the output from `balance.IPW`

will result in a table
with *k-2* rows (one for each variable other than the treatment
and outcome variables) and *6* columns. The columns are (from left
to right) the observed mean of the covariate among the treated units,
the observed mean of the covariate among the control units, the
weighted mean of the covariate among the treated units, the weighted
mean of the covariate among the control units, the weighted mean
difference, and the z-statistic for the difference.

It is often useful to include interactions and powers of the covariates in the dataset so that balance can be checked for these quantities as well.

Means, mean differences, and z-statistics are only reported for numeric covariates.

An object of class `balance`

with the following attributes:

`obs.mean.control` |
The observed mean of each of the covariates within the control units. |

`obs.mean.treated` |
The observed mean of each of the covariates within the treated units. |

`weighted.mean.control` |
The weighted mean of each of the covariates within the control units. |

`weighted.mean.treated` |
The weighted mean of each of the covariates within the treated units. |

`weighted.diff.SE` |
The bootstrap standard errors for the differences betwen |

Adam Glynn, Harvard University

Kevin Quinn, UC Berkeley

Adam N. Glynn and Kevin M. Quinn. 2010. "An Introduction to the Augmented Inverse Propensity Weighted Estimator." *Political Analysis*.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | ```
## Not run:
set.seed(1234)
## number of units in sample
n <- 2000
## measured potential confounders
z1 <- rnorm(n)
z2 <- rnorm(n)
z3 <- rnorm(n)
z4 <- rnorm(n)
## treatment assignment
prob.treated <- pnorm(-0.5 + 0.75*z2)
x <- rbinom(n, 1, prob.treated)
## potential outcomes
y0 <- z4 + rnorm(n)
y1 <- z1 + z2 + z3 + cos(z3*2) + rnorm(n)
## observed outcomes
y <- y0
y[x==1] <- y1[x==1]
## put everything in a data frame
examp.data <- data.frame(z1, z2, z3, z4, x, y)
## augment data with interactions and powers of covariates
examp.data$z1z1 <- examp.data$z1^2
examp.data$z2z2 <- examp.data$z2^2
examp.data$z3z3 <- examp.data$z3^2
examp.data$z4z4 <- examp.data$z4^2
examp.data$z1z2 <- examp.data$z1 * examp.data$z2
examp.data$z1z3 <- examp.data$z1 * examp.data$z3
examp.data$z1z4 <- examp.data$z1 * examp.data$z4
examp.data$z2z3 <- examp.data$z2 * examp.data$z3
examp.data$z2z4 <- examp.data$z2 * examp.data$z4
examp.data$z3z4 <- examp.data$z3 * examp.data$z4
## check balance of a propensity score model that is not sufficient to
## control confounding bias
bal.1 <- balance.IPW(pscore.formula=x~s(z3)+s(z4),
pscore.family=binomial(probit),
treatment.var="x",
outcome.var="y",
data=examp.data,
nboot=250)
print(bal.1) ## some big z-statistics here indicating balance not so great
## try again
bal.2 <- balance.IPW(pscore.formula=x~z1+z2+z3+z4,
pscore.family=binomial(probit),
treatment.var="x",
outcome.var="y",
data=examp.data,
nboot=250)
print(bal.2) ## balance looks much better--
## only 1 out of 14 zs > 2.0 in absval
## End(Not run)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.