在GNU R中,如何测试两个相关系数是否有显著不同?
也就是说,如果相同变量(例如,年龄和收入)之间的影响在两个不同的总体(子样本)中不同。
有关背景信息,请参阅How do I compare correlation coefficients of the same variables across different groups和Significance test on the difference of Spearman's correlation coefficient (均位于CrossValidated)。
发布于 2013-01-25 17:36:59
如果您想要比较多对系数(基于Significance of the difference between two correlation coefficients和Quantitative 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)
}
}发布于 2013-12-05 18:29:48
cocor包提供了测试两个独立的或相关的相关系数是否显著不同的函数。还有一个可用于软件包的web界面:http://comparingcorrelations.org
https://stackoverflow.com/questions/14519006
复制相似问题