@@ -59,21 +59,25 @@ pkonfound(est_eff = 2,
59
59
n_obs = 100 ,
60
60
n_covariates = 3 )
61
61
# > Robustness of Inference to Replacement (RIR):
62
- # > To invalidate an inference, 60.29 % of the estimate would have to be due to bias.
63
- # > This is based on a threshold of 0.794 for statistical significance (alpha = 0.05).
62
+ # > TO INVALIDATE:
64
63
# >
65
- # > To invalidate an inference, 60 observations would have to be replaced with cases
66
- # > for which the effect is 0 (RIR = 60).
64
+ # > RIR = 60
65
+ # >
66
+ # > The estimated effect is 2. To invalidate the inference of an effect using
67
+ # > the threshold of 0.794 for statistical significance with alpha = 0.05, 60.295% of
68
+ # > the (2) estimate would have to be due to bias. This implies that to invalidate
69
+ # > the inference one would expect to have to replace 60 (60.295%) observations
70
+ # > with cases for which the treatment effect is 0 (RIR = 60).
67
71
# >
68
72
# > See Frank et al. (2013) for a description of the method.
69
73
# >
70
74
# > Citation: Frank, K.A., Maroulis, S., Duong, M., and Kelcey, B. (2013).
71
75
# > What would it take to change an inference?
72
- # > Using Rubin's causal model to interpret the
73
- # > robustness of causal inferences .
74
- # > Education, Evaluation and
75
- # > Policy Analysis, 35 437-460 .
76
- # > For other forms of output, run
76
+ # > Using Rubin's causal model to interpret the robustness of causal inferences.
77
+ # > Education, Evaluation and Policy Analysis, 35 437-460 .
78
+ # >
79
+ # > Accuracy of results increases with the number of decimals reported .
80
+ # > For other forms of output, run
77
81
# > ?pkonfound and inspect the to_return argument
78
82
# > For models fit in R, consider use of konfound().
79
83
```
@@ -85,35 +89,35 @@ are the coefficients for a linear model fit with `lm()` using the
85
89
built-in dataset ` mtcars ` :
86
90
87
91
``` r
88
- m1 <- lm(mpg ~ wt + hp , data = mtcars )
92
+ m1 <- lm(mpg ~ wt + disp , data = mtcars )
89
93
m1
90
94
# >
91
95
# > Call:
92
- # > lm(formula = mpg ~ wt + hp , data = mtcars)
96
+ # > lm(formula = mpg ~ wt + disp , data = mtcars)
93
97
# >
94
98
# > Coefficients:
95
- # > (Intercept) wt hp
96
- # > 37.22727 -3.87783 -0.03177
99
+ # > (Intercept) wt disp
100
+ # > 34.96055 -3.35083 -0.01772
97
101
summary(m1 )
98
102
# >
99
103
# > Call:
100
- # > lm(formula = mpg ~ wt + hp , data = mtcars)
104
+ # > lm(formula = mpg ~ wt + disp , data = mtcars)
101
105
# >
102
106
# > Residuals:
103
- # > Min 1Q Median 3Q Max
104
- # > -3.941 -1.600 -0.182 1.050 5.854
107
+ # > Min 1Q Median 3Q Max
108
+ # > -3.4087 -2.3243 -0.7683 1.7721 6.3484
105
109
# >
106
110
# > Coefficients:
107
111
# > Estimate Std. Error t value Pr(>|t|)
108
- # > (Intercept) 37.22727 1.59879 23.285 < 2e -16 ***
109
- # > wt -3.87783 0.63273 -6.129 1.12e-06 ***
110
- # > hp -0.03177 0.00903 -3.519 0.00145 **
112
+ # > (Intercept) 34.96055 2.16454 16.151 4.91e -16 ***
113
+ # > wt -3.35082 1.16413 -2.878 0.00743 **
114
+ # > disp -0.01773 0.00919 -1.929 0.06362 .
111
115
# > ---
112
116
# > Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
113
117
# >
114
- # > Residual standard error: 2.593 on 29 degrees of freedom
115
- # > Multiple R-squared: 0.8268 , Adjusted R-squared: 0.8148
116
- # > F-statistic: 69.21 on 2 and 29 DF, p-value: 9.109e-12
118
+ # > Residual standard error: 2.917 on 29 degrees of freedom
119
+ # > Multiple R-squared: 0.7809 , Adjusted R-squared: 0.7658
120
+ # > F-statistic: 51.69 on 2 and 29 DF, p-value: 2.744e-10
117
121
```
118
122
119
123
Sensitivity analysis for the effect for ` wt ` on ` mpg ` can be carried out
@@ -122,20 +126,24 @@ as follows, specifying the fitted model object:
122
126
``` r
123
127
konfound(m1 , wt )
124
128
# > Robustness of Inference to Replacement (RIR):
125
- # > To invalidate an inference, 66.521 % of the estimate would have to be due to bias.
126
- # > This is based on a threshold of -1.298 for statistical significance (alpha = 0.05).
129
+ # > TO INVALIDATE:
127
130
# >
128
- # > To invalidate an inference, 21 observations would have to be replaced with cases
129
- # > for which the effect is 0 (RIR = 21).
131
+ # > RIR = 9
132
+ # >
133
+ # > The estimated effect is -3.351. To invalidate the inference of an effect using
134
+ # > the threshold of -2.381 for statistical significance with alpha = 0.05, 28.946% of
135
+ # > the (-3.351) estimate would have to be due to bias. This implies that to invalidate
136
+ # > the inference one would expect to have to replace 9 (28.946%) observations
137
+ # > with cases for which the treatment effect is 0 (RIR = 9).
130
138
# >
131
139
# > See Frank et al. (2013) for a description of the method.
132
140
# >
133
141
# > Citation: Frank, K.A., Maroulis, S., Duong, M., and Kelcey, B. (2013).
134
142
# > What would it take to change an inference?
135
- # > Using Rubin's causal model to interpret the
136
- # > robustness of causal inferences .
137
- # > Education, Evaluation and
138
- # > Policy Analysis, 35 437-460 .
143
+ # > Using Rubin's causal model to interpret the robustness of causal inferences.
144
+ # > Education, Evaluation and Policy Analysis, 35 437-460 .
145
+ # >
146
+ # > Accuracy of results increases with the number of decimals reported .
139
147
# > NULL
140
148
```
141
149
0 commit comments