Description Usage Arguments Value References Examples
View source: R/sensitivity_stats.R
This function computes the robustness value of a regression coefficient.
The robustness value describes the minimum strength of association (parameterized in terms of partial R2) that omitted variables would need to have both with the treatment and with the outcome to change the estimated coefficient by a certain amount (for instance, to bring it down to zero).
For instance, a robustness value of 1% means that an unobserved confounder that explain 1% of the residual variance of the outcome and 1% of the residual variance of the treatment is strong enough to explain away the estimated effect. Whereas a robustness value of 90% means that any unobserved confounder that explain less than 90% of the residual variance of both the outcome and the treatment assignment cannot fully account for the observed effect. You may also compute robustness value taking into account sampling uncertainty. See details in Cinelli and Hazlett (2020).
The function robustness_value can take as input an lm
object or you may directly pass the t-value and degrees of freedom.
1 2 3 4 5 6 7 | robustness_value(...)
## S3 method for class 'lm'
robustness_value(model, covariates = NULL, q = 1, alpha = 1, ...)
## S3 method for class 'numeric'
robustness_value(t_statistic, dof, q = 1, alpha = 1, ...)
|
... |
arguments passed to other methods. First argument should either be an |
model |
an |
covariates |
model covariates for which the robustness value will be computed. Default is to compute the robustness value of all covariates. |
q |
percent change of the effect estimate that would be deemed problematic. Default is |
alpha |
significance level. |
t_statistic |
|
dof |
residual degrees of freedom of the regression |
The function returns a numerical vector with the robustness value. The arguments q and alpha are saved as attributes of the vector for reference.
Cinelli, C. and Hazlett, C. (2020), "Making Sense of Sensitivity: Extending Omitted Variable Bias." Journal of the Royal Statistical Society, Series B (Statistical Methodology).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # using an lm object
## loads data
data("darfur")
## fits model
model <- lm(peacefactor ~ directlyharmed + age + farmer_dar + herder_dar +
pastvoted + hhsize_darfur + female + village, data = darfur)
## robustness value of directly harmed q =1 (reduce estimate to zero)
robustness_value(model, covariates = "directlyharmed")
## robustness value of directly harmed q = 1/2 (reduce estimate in half)
robustness_value(model, covariates = "directlyharmed", q = 1/2)
## robustness value of directly harmed q = 1/2, alpha = 0.05
## (reduce estimate in half, with 95% confidence)
robustness_value(model, covariates = "directlyharmed", q = 1/2, alpha = 0.05)
# you can also provide the statistics directly
robustness_value(t_statistic = 4.18445, dof = 783)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.