What is the smallest value of 'p' in that the KRUSKALWALLIS function can return?
2 views (last 30 days)
Show older comments
I am trying to determine the smallest value of 'p' in the KRUSKALWALLIS function.
Is there a minimum value of 'p' that this function defaults to before it returns 0?
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
The minimum value of 'p' for the KRUSKALWALLIS function can be resolved through two possible methods:
1) The KRUSKALWALLIS function calculates the value of 'p' based on ranks. So the function statistic, and therefore the p-value, is necessarily discrete. For small sample sizes, the p-value will not be able to get very small before it is zero. This is not a numerical precision issue usually present with digital computers; it is a property of the function itself.
2) The p-value is an upper tail of a cumulative distributed function (CDF). The CDF value is approximately a chi-squared distribution and is computed as 1 - CHI2CDF (...). The smallest possible value of ‘p’, before zero, is eps/2 where EPS is the floating-point relative accuracy of a number. Here is an example where it reaches that value:
rand('twister',7);
N = 1000;
x = 1:N;
k = 80;
g = [repmat(1,1,k) randsample(1:2,1000-2*k,true) repmat(2,1,k)];
[p table stats] = kruskalwallis(x,g,'off') = kruskalwallis(x,g,'off');
p
The value of 'p' would be:
p =
1.1102e-16
This is a numerical precision issue which digital computers have. Given the third output of KRUSKALWALLIS, stats, it is possible to take the value of the function and the chi-square state.
For example, if the value of the variables 'df' and 'Chi-sq' are taken to be as:
'df'=3
'Chi-sq'=126
The value of the upper tail is computed directly as:
x = 126;
v = 3;
p = gammainc(x/2,v/2,'upper')
This would give the following output:
p =
3.9353e-27
An important thing to note would be that chi-squared distribution is only an approximation and therefore will never be exact. Secondly, this is a hypothesis test, and there are very few hypothesis-testing applications where one would need to know the difference between a p-value of 1e-6 and 1e-27.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!