R 中的引导包简单帮助
如果我想使用 R 的 boot
包中的 boot()
函数来计算两个向量之间的皮尔逊相关系数的显着性,我应该这样做
boot(re1, cor, R = 1000)
: re1
是这两个观察向量的两列矩阵?我似乎无法正确理解这一点,因为这些向量的 cor
是 0.8
,但上面的函数返回 -0.2
作为 t0
。
If I want to use the the boot()
function from R's boot
package for calculating the significance of the Pearson correlation coefficient between two vectors, should I do it like this:
boot(re1, cor, R = 1000)
where re1
is a two column matrix for these two observation vectors? I can't seem to get this right because cor
of these vectors is 0.8
, but the above function returns -0.2
as t0
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是为了强调 R 中引导的总体思路,尽管@caracal 已经通过他的评论回答了你的问题。使用
boot
时,需要有一个可以按行采样的数据结构(通常是矩阵)。统计数据的计算通常在一个函数中完成,该函数接收该数据矩阵并返回重采样后计算出的感兴趣的统计数据。然后,您调用boot()
来负责将此函数应用于R
复制并以结构化格式收集结果。这些结果可以依次使用boot.ci()
进行评估。以下是
MASS
包中的低出生婴儿
研究的两个工作示例。Just to emphasize the general idea on bootstrapping in R, although @caracal already answered your question through his comment. When using
boot
, you need to have a data structure (usually, a matrix) that can be sampled by row. The computation of your statistic is usually done in a function that receives this data matrix and returns the statistic of interest computed after resampling. Then, you call theboot()
that takes care of applying this function toR
replicates and collecting results in a structured format. Those results can be assessed usingboot.ci()
in turn.Here are two working examples with the
low birth baby
study in theMASS
package.