Dataplot Vol 1 Vol 2

# SQUARED RANKS

Name:
SQUARED RANKS
Type:
Analysis Command
Purpose:
Perform a squared ranks test that k samples have equal variances.
Description:
The F test is the standard parameteric test for testing the equality of variances for the two sample case. The squared ranks test is a nonparametric test for either the two sample case or the case of k groups.

The assumptions for using this test are

1. The k samples are random samples from their respective populations.

2. The k samples are mutually independent.

3. The measurement is scale is at least interval (i.e., the data can be ranked).

More formally,

H0: The samples are identically distributed except for possibly different means.
HA: At least two of the variances are not equal
Test Statistic: For the k-sample case, the test statistic is

$$T = \frac{1}{D^2} \left( \sum_{i1}^{k}{\frac{S_{i}^2}{n_i}} - N \bar{S} \right)$$

where

 Si = sum of squared ranks in subsample i ni = number of observations in subsample i D2 = $$\frac{1}{N-1} \left( \sum_{i=1}^{N}{R_{i}^4} - N \bar{S} \right)$$ SBAR = $$\frac{1}{N} \sum_{j=1}^{k}{S_{j}}$$ = $$\frac{1}{N} \sum_{i=1}^{N}{S_{i}}$$ Ri = rank of observation i Si = sum of squared ranks in subsample i

For the 2-sample case, let

$$U_{i} = |X_{i} - \mu|$$
$$V_{i} = |Y_{i} - \mu|$$

where Xi denotes the i-th observation from population 1, Yi denotes the i-th observation from population 2, and $$\mu_{1}$$ and $$\mu_{2}$$ denote the means of populations 1 and 2, respectively.

The test statistic is then

$$T1 = \frac{\sum_{i=1}^{N1}{R(U_i)^2} - n \bar{R^2}} {\sqrt{\frac{N1 N2}{N(N-1)}\sum_{i=1}^{N}{R_{i}^4} - \frac{N1 N2}{N - 1}(\bar{R^2})^2}}$$
where N = N1 + N2 and $$\bar{R}^{2}$$ denotes the average of the squared ranks of the combined samples.

Significance Level: $$\alpha$$
Critical Region: For the k sample case

T > CHIPPF($$\alpha$$,k-1)

where CHIPPF is the chi-square percent point function.

For the 2 sample case,

$$T1 > \Phi^{-1}(1 - \alpha/2)$$
$$T1 < \Phi^{-1}(\alpha/2)$$

where $$\Phi^{-1}$$ is the normal percent point function.

Conclusion: Reject the null hypothesis if the test statistic is in the critical region.

Syntax 1:
<LOWER TAILED/UPPER TAILED> SQUARED RANKS <y> <x>
<SUBSET/EXCEPT/FOR qualification>
where <LOWER TAILED/UPPER TAILED> is an optional keyword for the two sample case;
<y> is the response (= dependent) variable;
<x> is the factor (= independent) variable;
and where the <SUBSET/EXCEPT/FOR qualification> is optional.

The LOWER TAILED and UPPER TAILED options are only available for the two sample case. Only one can be specified and if neither is entered a two-tailed test will be performed.

Syntax 2:
MULTIPLE SQUARED RANKS <y1> ... <yk>
<SUBSET/EXCEPT/FOR qualification>
where <LOWER TAILED/UPPER TAILED> is an optional keyword for the two sample case;
<y1> ... <yk> is a list of 1 to 30 response variables;
and where the <SUBSET/EXCEPT/FOR qualification> is optional.

This syntax is used for the case when the data for each group is stored in a separate variable. This syntax accepts matrix arguments.

The LOWER TAILED and UPPER TAILED options are only available for the two sample case. Only one can be specified and if neither is entered a two-tailed test will be performed.

Examples:
SQUARED RANKS TEST Y X
SQUARED RANKS TEST Y X SUBSET X = 1 TO 4
MULTIPLE SQUARED RANKS TEST Y1 Y2 Y3 Y4
MULTIPLE SQUARED RANKS TEST Y1 TO Y4
LOWER TAILED SQUARED RANKS TEST Y1 Y2
UPPER TAILED SQUARED RANKS TEST Y1 Y2
Note:
The critical values are only approximate. Tables may be available for smaller sample sizes for the two-sample case. However, Dataplot currently only uses the large sample approximations for the critical values.
Note:
For the k sample case and if the hypothesis of identical distributions is rejected, you can perform a multiple comparisons procedure to determine which pairs of populations tend to differ.

The populations i and j seem to have different variances if the following inequality is satisfied:

$$\left| \frac{S_{i}}{N_{i}} - \frac{S_{j}}{N_{j}} \right| > \mbox{TPPF}(1 - \alpha/2) \sqrt{D^2 \frac{N-1-T)}{N-k}} \sqrt{\frac{1}{N_i} + \frac{1}{N_j}}$$

with TPPF and T denoting the t percent point function with N - k degrees of freedom and the squared ranks test statistic, respectively.

Note:
The following statistics are also supported:

LET A = SQUARED RANKS TEST Y
LET A = SQUARED RANKS TEST CDF Y
LET A = SQUARED RANKS TEST PVALUE Y
LET A = SQUARED RANKS TEST LOWER TAILED PVALUE Y
LET A = SQUARED RANKS TEST UPPER TAILED PVALUE Y

In addition to the above LET command, built-in statistics are supported for about 20+ different commands (enter HELP STATISTICS for details).

Default:
None
Synonyms:
SQUARED RANKS is a synonym for SQUARED RANKS TEST
Related Commands:
 F TEST = Perform two sample test for equal standard deviations. KLOTZ TEST = Perform two sample test for equal variances. KRUSKAL WALLIS TEST = Perform Kruskal Wallis test for equal locations. ANOVA = Perform an analysis of variance. MEDIAN TEST = Perform a median test for equal variances. BLOCK PLOT = Generate a block plot. DEX ... PLOT = Generates a dex plot for a statistic. T TEST = Performs a t test.
Reference:
W. J. Conover, (1999). "Practical Nonparameteric Statistics," Third Edition, Wiley, pp. 300-310.
Applications:
Nonparametric Analysis
Implementation Date:
2011/6
Program:

. Step 1: Read Data (example 1 from pp. 304-305 of Conover)
.
let y1 = data 10.8 11.1 10.4 10.1 11.3
let y2 = data 10.8 10.5 11.0 10.9 10.8 10.7 10.8
.
. Step 2: Data with more than 2 groups
.
let z1 = data 0.7  1  2  1.4  0.5  0.8  1  1.1  1.9  1.2  1.5
let z2 = data 1.7  2.1  -0.4  0  1  1.1  0.9  2.3  1.3  0.4  0.5
let z3 = data 0.9  0.9  1  0  0.1  -0.6  2.2  -0.3  0.6  2.4  2.5
.
. Step 3: Convert to form needed for "statistic" command
.
let y x = stacked y1 y2
let zy zx = stacked z1 z2 z3
set write decimals 4
.
.  Step 2: Check the statistic
.
.  stat = 5.192, pvalue = 0.0754
.
let stat = squared rank test         zy zx
let pval = squared rank test pvalue  zy zx
let cdf  = squared rank test cdf     zy zx
print stat cdf pval

The following output is generated:
 PARAMETERS AND CONSTANTS--

STAT    --         5.1925
CDF     --         0.9254
PVAL    --         0.0746

.
let stat2 = squared rank test         y x
let cdf2  = squared rank test cdf     y x
let pval2 = squared rank test pvalue  y x
let pvallt = squared rank test lower tailed pvalue  y x
let pvalut = squared rank test upper tailed pvalue  y x
print stat2 cdf2 pval2 pvallt pvalut

The following output is generated:
 PARAMETERS AND CONSTANTS--

STAT2   --         2.3273
CDF2    --         0.9900
PVAL2   --         0.0199
PVALLT  --         0.9900
PVALUT  --         0.0100

.
squared rank test y1 y2

The following output is generated:
            Squared Ranks Test

H0: Samples Have Equal Variability
Ha: Samples Do Not Have Equal Variability

Summary Statistics:
Total Number of Observations:                         12
Number of Groups:                                      2

Squared Ranks Test Statistic Value:               2.3273
CDF of Test Statistic:                            0.9900
Two-Tailed P-Value:                               0.0199
Lower Tailed P-Value:                             0.9900
Upper Tailed P-Value:                             0.0099

Two-Tailed Test: Normal Approximation

H0: Var(Y1) = Var(Y2); Ha: Var(Y1) <> Var(Y2)
------------------------------------------------------------
Null
Significance           Test       Critical     Hypothesis
Level      Statistic    Value (+/-)     Conclusion
------------------------------------------------------------
80.0%         2.3273         1.2815         REJECT
90.0%         2.3273         1.6448         REJECT
95.0%         2.3273         1.9599         REJECT
99.0%         2.3273         2.5758         ACCEPT


NIST is an agency of the U.S. Commerce Department.

Date created: 07/05/2011
Last updated: 11/05/2015

Please email comments on this WWW page to alan.heckert@nist.gov.