NAG CL Interface
g08acc (test_​median)

Settings help

CL Name Style:

1 Purpose

g08acc performs the Median test on two independent samples of possibly unequal size.

2 Specification

#include <nag.h>
void  g08acc (Integer n1, const double x[], Integer n2, const double y[], Integer *below, Integer *above, double *p, NagError *fail)
The function may be called by the names: g08acc, nag_nonpar_test_median or nag_median_test.

3 Description

The Median test investigates the difference between the medians of two independent samples of sizes n 1 and n 2 , denoted by:
x 1 , x 2 , , x n 1  and  x n 1 + 1 , x n 1 + 2 , , x n ,   n = n 1 + n 2 .  
The hypothesis under test, H 0 , often called the null hypothesis, is that the medians are the same, and this is to be tested against the alternative hypothesis H 1 that they are different.
The test proceeds by forming a 2×2 frequency table, giving the number of scores in each sample above and below the median of the pooled sample:
Sample 1 Sample 2 Total
Scores pooled median i 1 i 2 i 1 + i 2
Scores pooled median n 1 - i 1 n 2 - i 2 n - ( i 1 + i 2 )
Total n 1 n 2 n
Under the null hypothesis, H 0 , 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 i 1 to be about n 1 / 2 and i 2 to be about n 2 / 2 .
g08acc returns:
  1. (a)the frequencies i 1 and i 2 ;
  2. (b)the probability, p , of observing a table at least as ‘extreme’ as that actually observed, given that H 0 is true. If n<40 , p is computed directly (‘Fisher's exact test’); otherwise a χ 1 2 approximation is used.
H 0 is rejected by a test of chosen size α if p<α .

4 References

Siegel S (1956) Non-parametric Statistics for the Behavioral Sciences McGraw–Hill

5 Arguments

1: n1 Integer Input
On entry: the size of the first sample, n 1 .
Constraint: n11 .
2: x[n1] const double Input
On entry: the elements of x must be set to the data values in the first sample.
3: n2 Integer Input
On entry: the size of the second sample, n 2 .
Constraint: n21 .
4: y[n2] const double Input
On entry: the elements of y must be set to the data values in the second sample.
5: below Integer * Output
On exit: the number of scores in the first sample which lie below the pooled median, i 1 .
6: above Integer * Output
On exit: the number of scores in the first sample which lie above the pooled median, i 2 .
7: p double * Output
On exit: the tail probability, p , corresponding to the observed dichotomy of the two samples.
8: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

Dynamic memory allocation failed.
On entry, n1 must not be less than 1: n1=value .
On entry, n2 must not be less than 1: n2=value .

7 Accuracy

The probability returned should be accurate enough for practical use.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
g08acc is not threaded in any implementation.

9 Further Comments

The time taken by g08acc is small, and increases with n .

10 Example

This example is taken from page 112 of Siegel (1956). The data relate to scores of ‘oral socialisation anxiety’ in 39 societies, which can be separated into groups of size 16 and 23 on the basis of their attitudes to illness.

10.1 Program Text

Program Text (g08acce.c)

10.2 Program Data

Program Data (g08acce.d)

10.3 Program Results

Program Results (g08acce.r)