-
Notifications
You must be signed in to change notification settings - Fork 305
Closed
Description
As per title, tidy.boot(..., conf.method = "norm")
will error on any boot object that does not have exactly two results, since apparently that was hardcoded
Line 119 in 7f3d795
ci.tab <- cbind(ci.list[[1]][ci.pos][[1]][2:3], ci.list[[2]][ci.pos][[1]][2:3]) |
Additionally, the rows/columns of the 2x2 confidence interval matrix are also incorrectly transposed, i.e. in the example below, the result should be (-0.0901, 0.2716) and (-0.294, 0.0794). Should be a rbind
and not a cbind
I believe?
library(boot)
library(broom)
set.seed(123)
d = data.frame(v1 = rnorm(100), v2=rnorm(100))
boot1 = function(d, i) {
d = d[i,]
c(mean(d$v1), mean(d$v2), cor(d$v1, d$v2))
}
boot2 = function(d, i) {
d = d[i,]
c(mean(d$v1), mean(d$v2))
}
boot3 = function(d, i) {
d = d[i,]
c(mean(d$v1))
}
r1 = boot(d, boot1, 1000)
r2 = boot(d, boot2, 1000)
r3 = boot(d, boot3, 1000)
tidy(r1, conf.int = T, conf.method = "norm")
#> Error in data.frame(..., check.names = FALSE): arguments imply differing number of rows: 3, 2
tidy(r2, conf.int = T, conf.method = "norm")
#> # A tibble: 2 x 5
#> statistic bias std.error conf.low conf.high
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.0904 -0.000358 0.0923 -0.0901 -0.294
#> 2 -0.108 -0.000230 0.0953 0.272 0.0794
tidy(r3, conf.int = T, conf.method = "norm")
#> Error in ci.list[[2]]: subscript out of bounds
### Other methods work correctly ###
tidy(r1, conf.int = T, conf.method = "basic")
#> # A tibble: 3 x 5
#> statistic bias std.error conf.low conf.high
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.0904 0.00188 0.0889 -0.0906 0.264
#> 2 -0.108 -0.000687 0.0983 -0.304 0.0864
#> 3 -0.0495 0.000840 0.0964 -0.248 0.137
tidy(r2, conf.int = T, conf.method = "basic")
#> # A tibble: 2 x 5
#> statistic bias std.error conf.low conf.high
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.0904 -0.000358 0.0923 -0.0932 0.282
#> 2 -0.108 -0.000230 0.0953 -0.290 0.0826
tidy(r3, conf.int = T, conf.method = "basic")
#> # A tibble: 1 x 5
#> statistic bias std.error conf.low conf.high
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.0904 0.00119 0.0913 -0.0951 0.269
Metadata
Metadata
Assignees
Labels
No labels