Test the hypothesis of an increase in the population median.
Load the sample data.
load('weather.mat');
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')
p = 0.1271
h = logical
0
stats = struct with fields:
zval: -1.1403
ranksum: 837.5000
Both the p-value of 0.1271 and h = 0 indicate that there is not enough evidence to reject the null hypothesis and conclude that there is a positive shift in the median of observed high temperatures in the same month from year 1 to year 2 at the 1% significance level. Notice that ranksum uses the approximate method to calculate the p-value due to the large sample sizes.
Use the exact method to calculate the p-value.
[p,h,stats] = ranksum(year1,year2,'alpha',0.01,...
'tail','left','method','exact')
p = 0.1273
h = logical
0
stats = struct with fields:
ranksum: 837.5000
The results of the approximate and exact methods are consistent with each other.