作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 2 x 2 阶乘数据集,我使用 mean_cl_boot
绘制了置信区间功能。我想使用适当的函数在 R 中计算它。我怎样才能做到这一点?
我的数据集示例如下:
df <- data.frame(
fertilizer = c("N","N","N","N","N","N","N","N","N","N","N","N","P","P","P","P","P","P","P","P","P","P","P","P","N","N","N","N","N","N","N","N","N","N","N","N","P","P","P","P","P","P","P","P","P","P","P","P"),
level = c("low","low","high","high","low","low","high","high","low","low","high","high","low","low","high","high","low","low","high","high","low","low","high","high","low","low","high","high","low","low","high","high","low","low","high","high","low","low","high","high","low","low","high","high","low","low","high","low"),
repro = c(0,90,2,4,0,80,1,90,2,33,56,0,99,100,66,80,1,0,2,33,0,0,1,2,90,5,2,2,5,8,0,1,90,2,4,66,0,0,0,0,1,2,90,5,2,5,8,55)
)
最佳答案
mean_cl_boot
建立在 Hmisc::smean.cl.boot()
.
如果要计算所有值(无论级别如何)的自举 CI,smean.cl.boot(df$repro)
应该这样做。
这就是在基 R 中执行拆分-应用-组合的方式:
library(Hmisc)
ss <- with(df, split(df, list(fertilizer,level)))
bb <- lapply(ss, function(x) smean.cl.boot(x$repro))
do.call(rbind,bb)
Mean Lower Upper
N.high 19.00000 5.747917 36.58750
P.high 26.09091 8.631818 47.27273
N.low 33.75000 12.416667 58.26042
P.low 20.38462 1.615385 42.69423
library(tidyverse)
(df
%>% group_split(fertilizer,level)
%>% map_dfr(~as_tibble(rbind(smean.cl.boot(.[["repro"]]))))
关于r - 如何使用ggplot2中使用的mean_CI_boot计算自举置信区间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59129637/
我是一名优秀的程序员,十分优秀!