首页 文章

两个相关系数差异的显着性检验

提问于
浏览
7

如何测试两个相关系数是否显着不同 - 在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) .

2 回答

  • 6

    如果要比较多对系数(基于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)
      }
    }
    
  • 2

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

相关问题