1
- n <- 1000
2
- mu <- 10
3
- sigma <- 1
4
-
5
- set.seed(888 )
6
- rand_nums <- rnorm(n , mu , sigma )
7
- dat <- data.frame (x = rand_nums )
8
-
9
- set.seed(456765 )
10
- bt_norm <-
11
- bootstraps(dat , times = 1000 , apparent = TRUE ) %> %
12
- dplyr :: mutate(
13
- stats = purrr :: map(splits , ~ get_stats(.x ))
14
- )
15
-
16
1
test_that(" Bootstrap estimate of mean is close to estimate of mean from normal distribution" , {
17
2
skip_if_not_installed(" broom" )
18
3
skip_on_cran()
4
+
5
+ set.seed(888 )
6
+ rand_nums <- rnorm(n = 1000 , mean = 10 , sd = 1 )
7
+ dat <- data.frame (x = rand_nums )
8
+
9
+ set.seed(456765 )
10
+ bt_norm <- bootstraps(dat , times = 1000 , apparent = TRUE ) %> %
11
+ dplyr :: mutate(
12
+ stats = purrr :: map(splits , ~ get_stats(.x ))
13
+ )
14
+
19
15
ttest <- broom :: tidy(t.test(rand_nums ))
20
16
ttest_lower_conf <- broom :: tidy(t.test(rand_nums , conf.level = 0.8 ))
21
17
single_pct_res <- int_pctl(bt_norm , stats )
@@ -156,6 +152,9 @@ test_that("Upper & lower confidence interval does not contain NA", {
156
152
test_that(
157
153
" Sufficient replications needed to sufficiently reduce Monte Carlo sampling Error for BCa method" ,
158
154
{
155
+ set.seed(888 )
156
+ rand_nums <- rnorm(n = 1000 , mean = 10 , sd = 1 )
157
+ dat <- data.frame (x = rand_nums )
159
158
set.seed(456765 )
160
159
bt_small <-
161
160
bootstraps(dat , times = 10 , apparent = TRUE ) %> %
@@ -172,8 +171,12 @@ test_that(
172
171
test_that(
173
172
" Sufficient replications needed to sufficiently reduce Monte Carlo sampling Error for BCa method" ,
174
173
{
175
- skip(" until we don't get a message about loading purrr in the snapshot in R CMD check hard" )
174
+ skip(" #539 message about loading purrr in the snapshot in R CMD check hard" )
176
175
# unskip this by moving the expectation back into the test_that block above
176
+
177
+ set.seed(888 )
178
+ rand_nums <- rnorm(n = 1000 , mean = 10 , sd = 1 )
179
+ dat <- data.frame (x = rand_nums )
177
180
set.seed(456765 )
178
181
bt_small <-
179
182
bootstraps(dat , times = 10 , apparent = TRUE ) %> %
@@ -187,6 +190,9 @@ test_that(
187
190
)
188
191
189
192
test_that(" bad input" , {
193
+ set.seed(888 )
194
+ rand_nums <- rnorm(n = 1000 , mean = 10 , sd = 1 )
195
+ dat <- data.frame (x = rand_nums )
190
196
set.seed(456765 )
191
197
bt_small <-
192
198
bootstraps(dat , times = 10 , apparent = TRUE ) %> %
@@ -220,6 +226,16 @@ test_that("bad input", {
220
226
int_bca(vfold_cv(mtcars ))
221
227
})
222
228
229
+ set.seed(888 )
230
+ rand_nums <- rnorm(n = 1000 , mean = 10 , sd = 1 )
231
+ dat <- data.frame (x = rand_nums )
232
+
233
+ set.seed(456765 )
234
+ bt_norm <- bootstraps(dat , times = 1000 , apparent = TRUE ) %> %
235
+ dplyr :: mutate(
236
+ stats = purrr :: map(splits , ~ get_stats(.x ))
237
+ )
238
+
223
239
bad_bt_norm <-
224
240
bt_norm %> %
225
241
mutate(stats = purrr :: map(stats , ~ .x [, 1 : 2 ]))
0 commit comments