如何获取 R 中单尾自举皮尔逊相关性的置信区间?



我想计算 95% 的自举置信区间,用于R中的单尾、非参数自举皮尔逊相关检验。但是,boot.ci只给出了双尾置信。如何计算单尾自举置信?

这是我使用cor.test进行单尾、自举 Pearson 相关性检验的代码。(它包括末尾的boot.ci,它返回双尾 CI,而不是所需的单尾 CI。输出作为注释(#(包含在内以进行比较。

# Load boot package
library(boot)
# Make the results reproducible
set.seed(7612)
# Define bootstrapped Pearson correlation function and combine output into vector
bootCorTest <- function(data, i){
d <- data[i, ]
results <- cor.test(d$x, d$y, method = "pearson", alternative = "greater")
c(est = results$estimate, stat = results$statistic, param = results$parameter, p.value = results$p.value, CI = results$conf.int)
}
# Define data frame (from first dataset in help("cor.test"))
x <- c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
y <- c( 2.6,  3.1,  2.5,  5.0,  3.6,  4.0,  5.2,  2.8,  3.8)
dat <- data.frame(x, y)
# Perform bootstrapped correlation, 1000 bootstrap replicates
b <- boot(dat, bootCorTest, R = 1000)
#Bootstrap Statistics
#        original     bias    std. error
# t1*  0.57118156 0.05237613  0.21511138
# t2*  1.84108264 1.04457361  3.14416940
# t3*  7.00000000 0.00000000  0.00000000
# t4*  0.05408653 0.01322028  0.09289083
# t5* -0.02223023 0.15123095  0.36338698
# t6*  1.00000000 0.00000000  0.00000000
b
# Original (non-bootstrap) statistics with labels
#    est.cor      stat.t    param.df     p.value         CI1         CI2 
# 0.57118156  1.84108264  7.00000000  0.05408653 -0.02223023  1.00000000
b$t0

# Two-tailed 95% Confidence intervals
# Level      Normal              Basic             
# 95%   ( 0.0972,  0.9404 )   ( 0.1867,  0.9321 ) 
# Level     Percentile            BCa          
# 95%   ( 0.2103,  0.9557 )   (-0.1535,  0.9209 ) 
boot.ci(b, type = c("norm", "basic", "perc", "bca"))

编辑: Carpenter 和 Bithell(2000 年,第 1149-1157 页(概述了使用基本的、学生化的、百分位数的、偏差校正的、偏差校正的加速、测试反转和学生化的测试反转方法计算单侧 95% 自举置信边界的算法,但我不知道如何在R中应用这些算法进行相关测试。

我意识到单尾 95% 自举下限或上限置信区限可以通过在boot.ci(b, conf = 0.90)中指定双尾 90% 置信区间并注意所需的界限(正相关下限或负相关上限(来获得。(对于负单尾相关性,另一个界限为 -1,对于正单尾相关性,另一个界限为 -1。

最新更新