Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Spearman

Spearman's rho


Description

Density, distribution function, quantile function, random generator and summary function for Spearman's rho.

Usage

dSpearman(x, r, log=FALSE)
pSpearman(q, r,  lower.tail=TRUE, log.p=FALSE)
qSpearman(p, r,  lower.tail=TRUE, log.p=FALSE)
rSpearman(n, r)
sSpearman(r)

Arguments

x,q

vector of non-negative quantities

p

vector of probabilities

n

number of values to generate. If n is a vector, length(n) values will be generated

r

(r >= 3) vector of number of observations

log, log.p

logical vector; if TRUE, probabilities p are given as log(p)

lower.tail

logical vector; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]

Details

Spearman's rho is the rank correlation coefficient between r pairs of items. It ranges from -1 to 1. Denote by d, the sum of squares of the differences between the matched ranks, then x is given by:

1-6 d /(r(r^2-1))

This is, in fact, the product-moment correlation coefficient of rank differences. See Kendall (1975), Chapter 2. It is identical to Friedman's chi-squared for two treatments scaled to the -1, 1 range – if X is the Friedman statistic, then rho = X/(r-1) -1.

Exact calculations are made for r <= 100

These exact calculations are made using the algorithm of Kendall and Smith (1939).

The incomplete beta, with continuity correction, is used for calculations outside this range.

Value

The output values conform to the output from other such functions in R. dSpearman() gives the density, pSpearman() the distribution function and qSpearman() its inverse. rSpearman() generates random numbers. sSpearman() produces a list containing parameters corresponding to the arguments – mean, median, mode, variance, sd, third cental moment, fourth central moment, Pearson's skewness, skewness, and kurtosis.

Author(s)

Bob Wheeler

References

Kendall, M. (1975). Rank Correlation Methods. Griffin, London.

Kendall, M. and Smith, B.B. (1939). The problem of m rankings. Ann. Math. Stat. 10. 275-287.

Examples

pSpearman(.95, 10)
pSpearman(c(-0.55,0,0.55), 10) ## approximately 5% 50% and 95% 
sSpearman(10)
plot(function(x)dSpearman(x, 10),-.9,.9)

SuppDists

Supplementary Distributions

v1.1-9.5
GPL (>= 2)
Authors
Bob Wheeler [aut], Thorsten Pohlert [ctb, cre] (<https://orcid.org/0000-0003-3855-3025>)
Initial release
2020-01-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.