Calculates Spearman’s rank correlation coefficient (S.J. Welham, N.M. Maclaren & H.R. Simpson).
Options
PRINT = string tokens |
Output required (test , correlations , ranks ): test produces the correlation coefficient/matrix and relevant test statistics, correlations prints out just the correlation coefficients for each pair of variates; ranks produces the vectors of ranks for each sample; default test |
---|---|
GROUPS = factor |
Defines the sample membership if only one variate is specified by DATA |
CORRELATION = scalar or symmetric matrix |
Scalar to save the rank correlation coefficient if there are two samples, or symmetric matrix to save the coefficients between all pairs of samples if there are several |
T = scalar or symmetric matrix |
Scalar to save the Student’s t approximation to the correlation coefficient if there are two samples, or symmetric matrix to save the t approximations for all pairs of samples if there are several (calculated only if the sample size is 8 or more) |
DF = scalars |
Scalar to save the degrees of freedom for each t-statistic |
Parameters
DATA = variates |
List of variates containing the data for each sample, or a single variate containing the data from all the samples (the GROUPS option must then be set to indicate the sample to which each unit belongs) |
---|---|
RANKS = variates |
Saves the ranks |
Description
SPEARMAN
calculates Spearman’s rank correlation coefficient between pairs of samples. The samples can be stored in different variates and supplied in a list with the DATA
parameter. Alternatively, they can all be placed in a single variate, and the GROUPS
option set to a factor to indicate the sample to which each unit belongs.
If the sample size is less than 20, an exact two-sided probability is calculated using the PRSPEARMAN
procedure. Note, though, that the probability will be approximate if the variates contain ties; the probability is calculated for the adjusted correlation, but the calculation itself takes no account of the ties. SPEARMAN
also calculates a Student’s t approximation if the sample size is 8 or more (i.e. large enough for the approximation to be valid).
Printed output is controlled by the PRINT option, with settings:
correlation |
to display correlations; |
---|---|
test |
to display tests and correlations; and |
ranks |
to display the ranks for each sample. |
The results can also be saved using the CORRELATION
, T
and DF
options and the RANKS
parameter.
Options: PRINT
, GROUPS
, CORRELATION
, T
, DF
.
Parameters: DATA
, RANKS
.
Method
Spearman’s rank correlation coefficient is a measure of association between the rankings of two variables measured on N individuals (i.e. two vectors of length N). The correlation coefficient is calculated from the two vectors of ranks for the samples: let { Xi ; i=1…N } and { Yi ; i=1…N } be the vectors of ranks for sample 1 and sample 2 respectively, then the coefficient r is based on the vector of differences between ranks: { Di = Xi – Yi ; i=1…N } and is calculated by
r = 1 – 6 × ∑ i=1…N Di2 / [ N(N2-1) ].
If ties are present, then the statistic will be biased, and must be recalculated taking account of ties by:
r = ( ∑Xi2 + ∑Yi2 – ∑Di2 ) / ( 2 × √( ∑Xi2 × ∑Yi2 ) )
where ∑Xi2 = (N3–N)/12 – Tx ;
∑Yi2 = (N3–N)/12 – Ty ;
Tk = ∑ ( tj3 – tj )/12
and tj is the number of observations in the group with rank j.
The t-approximation for this statistic, T, is valid for samples of size 8 upwards, and is calculated by
T = r × √[ (N-2)/(1-r2) ].
It has approximately a t-distribution on N-2 degrees of freedom, and can be used for a test of the null hypothesis of independance between samples. (See for example Siegel 1956, pages 202-213, or Siegel & Castellan 1988, pages 235-244.)
Action with RESTRICT
If any of the variates in DATA
is restricted, the statistic is calculated only for the set of units not excluded by the restriction.
References
Siegel, S. (1956). Nonparametric Statistics for the Behavioural Sciences. McGraw-Hill, New York.
Siegel, S. & Castellan, N.J. (1988). Nonparametric Statictics for the Behavioural Sciences (second edition). McGraw-Hill, New York.
See also
Procedures: PRSPEARMAN
, CMHTEST
, FCORRELATION
, KCONCORDANCE
, KTAU
, LCONCORDANCE
.
Commands for: Basic and nonparametric statistics.
Example
CAPTION 'SPEARMAN example',!t(\ 'Data from Siegel (1956), Nonparametric Statistics, p. 205.',\ '2 variables are measured on N individuals.'); STYLE=meta,plain VARIATE [VALUE= 82, 98, 87, 40,116,113,111, 83, 85,126,106,117] Authority & [VALUE= 42, 46, 39, 37, 65, 88, 86, 56, 62, 92, 54, 81] Status PRINT Authority,Status; DECIMALS=0 CAPTION 'Calculate Spearman''s Rank Correlation Coefficient for the samples.' SPEARMAN [PRINT=test,ranks; CORRELATION=Correlation; T=t]\ Authority,Status; RANKS=RAuthority,RStatus PRINT Correlation,t & RAuthority,RStatus; DECIMALS=0