【问题标题】:Significance test on the difference of two correlation coefficient两个相关系数差异的显着性检验
【发布时间】:2013-01-09 06:02:18
【问题描述】:

如何测试两个相关系数是否显着不同 - 在 GNU R 中?

也就是说,如果相同变量(例如年龄和收入)之间的影响在两个不同的人群(子样本)中不同。

有关背景信息,请参阅 How do I compare correlation coefficients of the same variables across different groupsSignificance test on the difference of Spearman's correlation coefficient(均位于 CrossValidated)。

【问题讨论】:

    标签: r statistics correlation


    【解决方案1】:

    如果您想比较多对系数(基于Significance of the difference between two correlation coefficientsQuantitative Analysis and Politics, PDF),这是一个适用于 GNU R 的即用型函数:

    cor.diff.test = function(r1, r2, n1, n2, alternative = c("two.sided", "less", "greater")) {
    
      Z1 = 0.5 * log( (1+r1)/(1-r1) )
      Z2 = 0.5 * log( (1+r2)/(1-r2) )
    
      diff = Z1 - Z2
      SEdiff = sqrt( 1 / (n1 - 3) + 1 / (n2 - 3))
      diff.Z = diff / SEdiff
    
      if (alternative == "less") {
        return(pnorm(diff.Z, lower.tail=F))
      } else if (alternative == "greater") {
        return(pnorm(-diff.Z, lower.tail=F))
      } else if (alternative == "two.sided") {
        return(2 * pnorm( abs(diff.Z), lower.tail=F))
      } else {
        warning(paste("Invalid alterantive", alternative), domain=NA)
        return(NA)
      }
    }
    

    【讨论】:

    • 基础stats 包中已经有一个cor.test 函数,因此您可以避免使用此名称。
    • 请查看此帖子的修订版 3 (stackoverflow.com/revisions/14519007/3) 以获得在线计算器和原始公式的超链接 - 以防您只想比较几对相关系数。对于另一个用户来说,这些超链接看起来像是广告,这个用户删除了我认为有用的信息。
    • 注意:psych包里还有一个函数r.test()适合这个任务。
    【解决方案2】:

    cocor 包提供了测试两个独立或依赖相关系数是否显着不同的函数。该软件包还有一个 Web 界面:http://comparingcorrelations.org

    【讨论】:

      猜你喜欢
      • 2020-10-03
      • 2020-09-07
      • 2015-11-20
      • 2012-08-30
      • 2022-11-23
      • 2016-06-12
      • 2012-12-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多