Given a model and a term of interest, calculate the Aronow and Samii (2015) doi:10.1111/ajps.12185 regression weights and return an object which can be used to diagnose these implicit weights.

calculate_weights(mod, term)

Arguments

mod

The linear model object from lm or lm_robust.

term

String indicating the term for which to calculate the implicit regression weights. This must uniquely match a coefficient name (i.e. it must be a string which appears in only one element of coef(mod)).

Value

An object of class regweight containing:

termThe term in the regression for which weights were calculated.
modelThe partial regression model object.
weightsThe implicit regression weights.

Details

This calculates the implicit regression weights for a particular term in a given regression model.

In short, this calculates the weights for a coefficient \(\beta\) such that:

$$\frac{\mathrm{E}[w_i \beta_i]}{\mathrm{E}[w_i]} \to \beta$$

where \(\beta_i\) is the unit level effect. The expectation of \(w_i\) is the conditional variance of the variable of interest.

For details and examples, view the vignette: vignette("example-usage", package = "regweight")

References

Aronow, P.M. and Samii, C. (2016), "Does Regression Produce Representative Estimates of Causal Effects?". American Journal of Political Science, 60: 250-267. doi:10.1111/ajps.12185

Examples

y <- rnorm(100)
a <- rbinom(100, 1, 0.5)
x <- rnorm(100)
m1 <- stats::lm(y ~ a + x)

w1 <- calculate_weights(m1, "a")