I would like to bootstrap the p-value and standard errors from weighted Mann-Whitney U test.
I can run the test as: weighted_mannwhitney(c12hour ~ c161sex + weight, efc) which works fine, but am not entirely sure how I can run a bootstrapped version of the same to obtain a bootstrapped p-value for instance.
library(sjstats) # weighted Mann-Whitney
library(tidyverse) # main workflow, which has purrr and forcats (IIRC)
# library(broom) # for tidying model output, but not directly loaded
library(modelr) # for bootstrap
data(efc)
efc$weight <- abs(rnorm(nrow(efc), 1, .3))
# weighted Mann-Whitney-U-test ----
weighted_mannwhitney(c12hour ~ c161sex + weight, efc)
# Bootstrapping
set.seed(1000) # for reproducibility
boot_efc <- efc %>% bootstrap(1000)
# Throws error!
boot_efc %>%
dplyr::mutate(c12hour = map(strap, ~weighted_mannwhitney(c12hour ~ c161sex + weight, data = .)),
tidy = map(c12hour, broom::tidy)) -> boot_efc_out
SIDE NOTE: The package for the weighted Mann-Whitney test has its own bootstrap function which can be used as shown below to obtain bootstrapped standard error and bootstrapped p-value, but this is running a different function (mean), I could not adapt that for the weighted Mann-Whitney. Not sure if this helps
# or as tidyverse-approach
if (require("dplyr") && require("purrr")) {
bs <- efc %>%
bootstrap(100) %>%
mutate(
c12hour = map_dbl(strap, ~mean(as.data.frame(.x)$c12hour, na.rm = TRUE))
)
# bootstrapped standard error
boot_se(bs, c12hour)
# bootstrapped p-value
boot_p(bs, c12hour)
}