使用启动从矩阵返回rowmean和cis
简单的问题。我有一个矩阵foo
,我想使用启动来引导每一行的平均值及其95%CI。我希望输出是data.frame
,nrow(foo)
和三列均值,下CI和上CI。看起来很简单,但是boot
和boot.ci
语法正在避开我。
我想我将使用
与boot
应用,但我不确定如何进一步。任何帮助都赞赏。
首先尝试。
foo <- matrix(rnorm(1000),nrow=10)
getMean <- function(x,ind){
mean(x[ind],na.rm = TRUE)
}
meanBoot <- apply(X = foo,MARGIN = 1, FUN = boot,
statistic = getMean,
R = 200)
编辑:错字
Simple question. I have a matrix foo
and I want to bootstrap the mean value of each row and its 95% CI using boot. I want the output to be a data.frame
with nrow(foo)
and three columns the mean, lower CI, and upper CI. Seems simple but the boot
and boot.ci
syntax is eluding me.
I imagine I use apply
with boot
but I'm not sure how to go further. Any help appreciated.
First try.
foo <- matrix(rnorm(1000),nrow=10)
getMean <- function(x,ind){
mean(x[ind],na.rm = TRUE)
}
meanBoot <- apply(X = foo,MARGIN = 1, FUN = boot,
statistic = getMean,
R = 200)
Edit: typo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们可以做
- 输出
We may do
-output