View source: R/calculate_weights.R

calculate_weights | R Documentation |

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)

`mod` |
The linear model object from |

`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 |

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

In short, this calculates the weights for a coefficient *β* such that:

*\frac{\mathrm{E}[w_i β_i]}{\mathrm{E}[w_i]} \to β*

where *β_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")`

An object of class `regweight`

containing:

`term` | The term in the regression for which weights were calculated. |

`model` | The partial regression model object. |

`weights` | The implicit regression weights. |

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

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

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.