One-tailed test using the ranksum function
显示 更早的评论
In the ‘Increase in the Median’ example for the ranksum function (please see: https://uk.mathworks.com/help/stats/ranksum.html) it mentions that: “The weather data shows the daily high temperatures taken in the same month in two consecutive years. Perform a left-sided test to assess the increase in the median at the 1% significance level.” [p,h,stats] = ranksum(year1,year2,'alpha',0.01,'tail','left')”
The output of the function gives: h=0 i.e. the Null hypothesis cannot be rejected.
My question is the following: I have calculated that the Median value of temperatures for Year 1 [median(year1)] is: 60.5 and the Median value of temperatures for Year 2 [median(year2)] is: 62. Consequently, if in the previous function we exchange year2 with year1 i.e.: [p,h,stats] = ranksum(year2,year1,'alpha',0.01,'tail','left') then we should always get h=0, irrespective of the value of ‘alpha’, given that the Median value of temperatures for Year 1 is lower compared to the Median value of temperatures for Year 2. However, if we select any value of ‘alpha’ greater than 0.87 (e.g. 0.88) we get h=1 instead of h=0. I know that this value of ‘alpha’ is ridiculously high however, the value of h should be equal to 0 for any value of ‘alpha’ between 0 and 1 given that the Median value of temperatures for Year 1 is less than the Median value of temperatures for Year 2.
Is there an explanation for this strange result which occurs for values of alpha which are greater than 0.87?
Thank you very much,
Iasonas
采纳的回答
更多回答(2 个)
Kaushik Lakshminarasimhan
2017-11-28
0 个投票
Your premise that "we should always get h=0, irrespective of the value of ‘alpha’" is not correct. Please see the definition of p-value and rethink your argument: https://en.wikipedia.org/wiki/P-value
p-value is the probability of finding data that are at least as extreme as what you have, under the assumption that your null hypothesis is true. Depending on your data (entire data, not just the median), if that probability happens to be smaller than alpha, then the null hypothesis is rejected. For your data, the probability was around 0.87, so alpha greater than that gives you h=1. There is no reason to suppose that the probability should be 1, simply because the one median is less than the other.
类别
在 帮助中心 和 File Exchange 中查找有关 Hypothesis Tests 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!