R中的自举相关性。如何获得自举的r系数,p.value,置信区间

时间:2019-09-25 17:37:21

标签: r correlation statistics-bootstrap

我正在尝试在R中进行自举相关。

根据我在这两篇文章中看到的内容:How can I get confidence intervals for a one-tailed, bootstrapped Pearson correlation in R?Bootstrapped p-value for a correlation coefficient on R,我尝试了以下操作:

x = data$myData1
y = data$myData2
dat <- data.frame(x, y)
set.seed(1)
bootCorTest3 <- function(data, i){
  d <- data[i, ]
  results  <- cor.test(d$x, d$y)
  c(est = results$estimate, stat = results$statistic, param = results$parameter, p.value = results$p.value, CI = results$conf.int)
}

b3 <- boot(dat, bootCorTest3, R = 2000)
b3

OUTPUT:
Bootstrap Statistics :
       original       bias    std. error
t1*  0.29836749 -0.012284427   0.1492960
t2*  2.16580050 -0.013933040   1.2160051
t3* 48.00000000  0.000000000   0.0000000
t4*  0.03532486  0.107464681   0.2207419
t5*  0.02183300 -0.006166465   0.1612371
t6*  0.53249181 -0.014324511   0.1206106

# Original (non-bootstrap) statistics with label
b3$t0

    est.cor      stat.t    param.df     p.value         CI1         CI2 
 0.29836749  2.16580050 48.00000000  0.03532486  0.02183300  0.53249181 

colMeans(b2$t)

2.1395137 0.1298312 0.2854631

boot.ci(b, type = c("norm", "basic", "perc", "bca"))

Intervals : 
Level      Normal              Basic         
95%   (-0.5130,  0.3679 )   (-0.7692,  0.0706 )  

Level     Percentile            BCa          
95%   ( 0.0000,  0.8399 )   ( 0.0000,  0.8581 )  
Calculations and Intervals on Original Scale

因此,我看到我可以通过运行b3$t0来获得非启动统计信息,这对我来说很清楚。但是我不明白如何获得自举的p.value和r系数。另外,如果我键入b3(引导程序统计信息),输出内容对我也不是很清楚。有人可以帮我理解吗?

谢谢您的时间。

0 个答案:

没有答案