MEDIAN Subcommand (NPAR TESTS command)
NPAR TESTS MEDIAN [(value)]=varlist BY variable(value1,value2)
MEDIAN
determines
whether k independent samples
are drawn from populations with the same median. The independent samples
are defined by a grouping variable. For each variable, the output
shows a table of the number of cases that are greater than and less
than or equal to the median in each category in the Frequency table.
The output also shows the number of valid cases, the median, chi-square,
degrees of freedom, and probability in the Test Statistics table.
Syntax
- The minimum specification is a single test variable,
the keyword
BY
, a grouping variable, and two values in parentheses. - If the first grouping value is less than the second value, every value in the range that is defined by the pair of values forms a group, and a k-sample test is performed.
- If the first value is greater than the second value, two groups are formed by using the two values, and a two-sample test is performed.
- By default, the median is calculated
from all cases that are included in the test. To override the default,
specify a median value in parentheses following the
MEDIAN
subcommand keyword.
Operations
- A 2 × k contingency table is constructed with counts of the number of cases that are greater than the median and less than or equal to the median for the k groups.
- Test statistics
are calculated for each variable that is specified before
BY
. - For more than 30 cases, a chi-square statistic is computed. For 30 or fewer cases, Fisher’s exact procedure (two-tailed) is used instead of chi-square.
- For a two-sample test, cases with values other than the two specified values are excluded.
Example
NPAR TESTS MEDIAN(8.5)=V1 BY V2(1,2) /MEDIAN=V1 BY V2(1,2)
/MEDIAN=V1 BY V3(1,4) /MEDIAN=V1 BY V3(4,1).
- The first two
MEDIAN
subcommands test variable V1 grouped by values 1 and 2 of variable V2. The first test specifies a median of 8.5, and the second test uses the observed median. - The third
MEDIAN
subcommand requests a four-samples test, dividing the sample into four groups based on values 1, 2, 3, and 4 of variable V3. - The last
MEDIAN
subcommand requests a two-samples test, grouping cases based on values 1 and 4 of V3 and ignoring all other cases.