首页 文章

什么是能够分别为您提供相关系数的下限和上限的函数?

提问于
浏览
2
m=c(1,2,5,4,6,8)
h=c(1,2,9,8,7,3)
cor(m,h)
#[1] 0.4093729

如果您估计相关系数(R),那么您还可以估计相关系数(R)的置信区间,从而产生例如像

R = 0.40  [0.33 0.56]

R的"best"估计为 0.40 ,并且有一个 95% 机会,真正的R在 0.30.56 之间 . (请注意,这些数字是完全组成的 . )

我正在寻找一个函数,它将分别提供R的下限和上限 . 有类似的东西:

R = 0.40
upper  [0.33]
 lower [0.56]

_2619229中与此类似的东西:

[R,P,RLO,RUP]=corrcoef(...) also returns matrices RLO and RUP, of the same size as R,            
         containing lower and upper bounds for a 95% confidence interval for each coefficient.

1 回答

  • 5

    cor 帮助页面的"see also"部分,它说

    置信区间(和测试)的cor.test

    > cor.test(m, h)
    
        Pearson's product-moment correlation
    
    data:  m and h
    t = 0.8974, df = 4, p-value = 0.4202
    alternative hypothesis: true correlation is not equal to 0
    95 percent confidence interval:
     -0.6022868  0.9164582
    sample estimates:
          cor 
    0.4093729
    

    或者更直接地获得间隔:

    > x = cor.test(m, h)
    > x$conf.int
    [1] -0.6022868  0.9164582
    attr(,"conf.level")
    [1] 0.95
    

相关问题