在 excel 中计算 spearman 排名统计的 p 值(是否使用 vba)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20829052/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Calculating a p-value for the spearman's rank statistic in excel (using vba or not)
提问by user3084100
For long reasons I cannot use SPSS or another statistical package for this part of the analysis. I have two questions.
由于很长的原因,我不能在这部分分析中使用 SPSS 或其他统计包。我有两个问题。
Is there way of automatically ranking the data (from which i can later analyse). My variables go in one column (1,2,3,4,5,6....) which is already ranked by itself. My other variable can have a discrete value from 1 to 5 (e.g. 1 or 2 or 3 or 4 or 5). Even though in a way these are already ranked, it is not ranked in the way spearman wants. I think i could write some vba code to rank this myself, but if there was an automatic way it would be good to know!
有没有自动对数据进行排名的方法(我以后可以从中分析)。我的变量放在一列(1,2,3,4,5,6....)中,该列已经单独排名。我的另一个变量可以有一个从 1 到 5 的离散值(例如 1 或 2 或 3 或 4 或 5)。尽管在某种程度上这些已经排名,但它并没有按照 spearman 想要的方式进行排名。我想我可以自己写一些 vba 代码来对它进行排名,但是如果有一种自动的方式,那就太好了!
Importantly, the only reason i would want to work out the spearman correlation is that it allows me to calculate a p value which is not biased from nonnormality. However, all the guides online tell me to use a table to see if the test value is below a certain level for P<.05 or whatever. How can i calculate a specific p value based on N and Rho in excel? im assuming there is a formula somewhere (I couldn't find one in my textbooks!).
重要的是,我想要计算 spearman 相关性的唯一原因是它允许我计算 ap 值,该值不会因非正态性而产生偏差。但是,所有在线指南都告诉我使用表格来查看测试值是否低于 P <.05 或其他的某个水平。如何根据excel中的N和Rho计算特定的p值?我假设某处有一个公式(我在教科书中找不到一个公式!)。
回答by lori_m
Referring to the Wikipedia Example, we can use the formulas below to calculate the degrees of freedom (ν), Spearman rank correlation coefficient (ρ) and p-Value (using t-distribution).
参考Wikipedia Example,我们可以使用下面的公式来计算自由度 (ν)、Spearman 等级相关系数 (ρ) 和 p 值(使用 t 分布)。
x y
106 7
86 0
100 27
101 50
99 28
103 29
97 20
113 12
112 6
110 17
ν 8 =COUNT(x)-2
ρ -0.175757576 =CORREL(RANK.AVG(x,x,1),RANK.AVG(y,y,1))
Pval 0.686405828 =T.DIST(SQRT(ν*ρ^2/(1-ρ^2)),ν,1)
In the formulas above Defined Nameshave been used in place of cell references. Relative to A1
the references are: x=A2:A11, y=B2:B11, ν=B13, ρ=B14
. (greek letters can be used via Insert > Symbol)
在上面的公式中,已使用定义的名称代替单元格引用。相对A1
参考文献有:x=A2:A11, y=B2:B11, ν=B13, ρ=B14
。(希腊字母可以通过插入 > 符号使用)
Note: This assumes Excel 2010/13 for the RANK.AVG / T.DIST functions (use rank_avg / t_dist in VBA)
注意:这里假设 RANK.AVG/T.DIST 函数使用 Excel 2010/13(在 VBA 中使用 rank_avg/t_dist)