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

时间:2013-01-25 09:36:59

标签: r statistics correlation

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

答案 0 :(得分: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)
  }
}

答案 1 :(得分:2)

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