问题描述
我试图用https://www.tidymodels.org/learn/statistics/主题上的行函数替换purrr :: map。我能够在前2个中做到这一点,但是在bootstrap主题上,它在int_pctl函数处中断,因为它希望将数据作为rset对象。
这是我的代码:
library(tidyverse); library(tidymodels); library(rsample)
boots <- bootstraps(mtcars,times = 2000,apparent = T)
fit_nls_on_bootstrap <- function(split) {
nls(mpg ~ k / wt + b,analysis(split),start = list(k = 1,b = 0))
}
boot_models <-
boots %>%
rowwise() %>%
mutate(model = list(fit_nls_on_bootstrap(splits)),coef_info = list(tidy(model))) %>%
ungroup()
boot_coefs <-
boot_models %>%
unnest(coef_info)
percentile_intervals <- int_pctl(boot_models,coef_info)
percentile_intervals
以下观察可能会帮助您回答我的问题。
当我与该网页上的purrr :: map代码进行比较时,它可以正确生成boot_models对象的rset类,但是我的按行尝试未呈现rset类?
在此计算期间如何保留rset类?或者,通常,假设我想使用按行函数,如何获取int_pctl值?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)