NAG Library Routine Document
G08ACF performs the Median test on two independent samples of possibly unequal size.
||N, N1, I1, I2, IFAIL
||X(N), W(N), P
The Median test investigates the difference between the medians of two independent samples of sizes
, denoted by:
The hypothesis under test, , often called the null hypothesis, is that the medians are the same, and this is to be tested against the alternative hypothesis that they are different.
The test proceeds by forming a
frequency table, giving the number of scores in each sample above and below the median of the pooled sample:
|Scores pooled median
|Scores pooled median
Under the null hypothesis,
, we would expect about half of each group's scores to be above the pooled median and about half below, that is, we would expect
, to be about
to be about
||the frequencies and ;
||the probability, , of observing a table at least as ‘extreme’ as that actually observed, given that is true. If , is computed directly (‘Fisher's exact test’); otherwise a approximation is used (see G01AFF).
is rejected by a test of chosen size if .
Siegel S (1956) Non-parametric Statistics for the Behavioral Sciences McGraw–Hill
- 1: X(N) – REAL (KIND=nag_wp) arrayInput
: the first
elements of X
must be set to the data values in the first sample, and the next
) elements to the data values in the second sample.
- 2: N – INTEGERInput
On entry: the total of the two sample sizes, ().
- 3: N1 – INTEGERInput
On entry: the size of the first sample .
- 4: W(N) – REAL (KIND=nag_wp) arrayWorkspace
- 5: I1 – INTEGEROutput
On exit: the number of scores in the first sample which lie below the pooled median, .
- 6: I2 – INTEGEROutput
On exit: the number of scores in the second sample which lie below the pooled median, .
- 7: P – REAL (KIND=nag_wp)Output
On exit: the tail probability corresponding to the observed dichotomy of the two samples.
- 8: IFAIL – INTEGERInput/Output
must be set to
. If you are unfamiliar with this parameter you should refer to Section 3.3
in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
. When the value is used it is essential to test the value of IFAIL on exit.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
The probability returned should be accurate enough for practical use.
The time taken by G08ACF is small, and increases with .
This example is taken from page 112 of Siegel (1956)
. The data relate to scores of ‘oral socialisation anxiety’ in
societies, which can be separated into groups of size
on the basis of their attitudes to illness.
9.1 Program Text
Program Text (g08acfe.f90)
9.2 Program Data
Program Data (g08acfe.d)
9.3 Program Results
Program Results (g08acfe.r)