Skip to content

Commit f190f97

Browse files
committed
update the example in the readme
now the example is consistent with stata
1 parent f34e244 commit f190f97

File tree

2 files changed

+39
-31
lines changed

2 files changed

+39
-31
lines changed

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pkonfound(est_eff = 2,
6060
`konfound()` calculates the same for models fit in R. For example, here are the coefficients for a linear model fit with `lm()` using the built-in dataset `mtcars`:
6161

6262
```{r}
63-
m1 <- lm(mpg ~ wt + hp, data = mtcars)
63+
m1 <- lm(mpg ~ wt + disp, data = mtcars)
6464
m1
6565
summary(m1)
6666
```

README.md

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,25 @@ pkonfound(est_eff = 2,
5959
n_obs = 100,
6060
n_covariates = 3)
6161
#> 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:
6463
#>
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).
6771
#>
6872
#> See Frank et al. (2013) for a description of the method.
6973
#>
7074
#> Citation: Frank, K.A., Maroulis, S., Duong, M., and Kelcey, B. (2013).
7175
#> 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
7781
#> ?pkonfound and inspect the to_return argument
7882
#> For models fit in R, consider use of konfound().
7983
```
@@ -85,35 +89,35 @@ are the coefficients for a linear model fit with `lm()` using the
8589
built-in dataset `mtcars`:
8690

8791
``` r
88-
m1 <- lm(mpg ~ wt + hp, data = mtcars)
92+
m1 <- lm(mpg ~ wt + disp, data = mtcars)
8993
m1
9094
#>
9195
#> Call:
92-
#> lm(formula = mpg ~ wt + hp, data = mtcars)
96+
#> lm(formula = mpg ~ wt + disp, data = mtcars)
9397
#>
9498
#> Coefficients:
95-
#> (Intercept) wt hp
96-
#> 37.22727 -3.87783 -0.03177
99+
#> (Intercept) wt disp
100+
#> 34.96055 -3.35083 -0.01772
97101
summary(m1)
98102
#>
99103
#> Call:
100-
#> lm(formula = mpg ~ wt + hp, data = mtcars)
104+
#> lm(formula = mpg ~ wt + disp, data = mtcars)
101105
#>
102106
#> 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
105109
#>
106110
#> Coefficients:
107111
#> 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 .
111115
#> ---
112116
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
113117
#>
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
117121
```
118122

119123
Sensitivity analysis for the effect for `wt` on `mpg` can be carried out
@@ -122,20 +126,24 @@ as follows, specifying the fitted model object:
122126
``` r
123127
konfound(m1, wt)
124128
#> 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:
127130
#>
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).
130138
#>
131139
#> See Frank et al. (2013) for a description of the method.
132140
#>
133141
#> Citation: Frank, K.A., Maroulis, S., Duong, M., and Kelcey, B. (2013).
134142
#> 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.
139147
#> NULL
140148
```
141149

0 commit comments

Comments
 (0)