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

KruskalWallis

Kruskall-Wallis distribution


Description

Density, distribution function, quantile function, random generator and summary function for the Kruskal-Wallis test.

Usage

dKruskalWallis(x, c, N, U, log=FALSE)
pKruskalWallis(q, c, N, U, lower.tail=TRUE, log.p=FALSE)
qKruskalWallis(p, c, N, U, lower.tail=TRUE, log.p=FALSE)
rKruskalWallis(n, c, N, U)
sKruskalWallis(c, N, U)

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

c

vector number of treatments

N

vector total number of observations

U

vector sum of reciprocals of the number of the c sample sizes

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

This is a one-way layout with, perhaps, unequal sample sizes for each treatment. There are c treatments with sample sizes nj, j=1 … c. The total sample size is N=Sum(1 … c)nj. The distribution depends on c, N, and U, where U=Sum(1 … c)(1/nj).

Let Rj be the sum of the ranks for treatment j (j=1 … c) then the Kruskal-Wallis statistic is

x=(12/(N (N-1))Sum(1 … c)(Rj/nj) - 3 (N+1)

This is asymptotically equivalent to a chi-squared variable with c-1 degrees of freedom.

The original paper is Kruskal and Wallis (1952) with errata appearing in Kruskal and Wallis (1953). No attempt is made to calculate exact values, rather an incomplete beta approximation is used following Wallace (1959).

Value

The output values conform to the output from other such functions in R. dKruskalWallis() gives the density, pKruskalWallis() the distribution function and qKruskalWallis() its inverse. rKruskalWallis() generates random numbers. sKruskalWallis() 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

Kruskal, W.H. and Wallis, W.A. (1952) Use of ranks in one-criterion variance analysis. Jour. Am. Stat. Assoc. 47. 583-634

Kruskal, W.H. and Wallis, W.A. (1953) Errata to Use of ranks in one-criterion variance analysis. Jour. Am. Stat. Assoc. 48. 907-911.

Wallace, D.L. (1959). Simplified beta-approximations to the Kruskal-Wallis H test. Jour. Am. Stat. Assoc. 54. 225-230.

Examples

# Assuming three treatments, each with a sample size of 5.
pKruskalWallis(1, 3, 15, 0.6)
pKruskalWallis(c(.1,1.5,5.7), 3, 15, 0.6) ## approximately 5% 50% and 95%
sKruskalWallis(3, 15, 0.6)
plot(function(x)dKruskalWallis(x, 3, 15, 0.6),0.5,8)

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.