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

Friedman

Friedman's chi-square


Description

Density, distribution function, quantile function, random generator and summary function for Friedman's chi square.

Usage

dFriedman(x, r, N, log=FALSE)
pFriedman(q, r, N, lower.tail=TRUE, log.p=FALSE)
qFriedman(p, r, N, lower.tail=TRUE, log.p=FALSE)
rFriedman(n, r, N)
sFriedman(r, N)

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

vector of number of treatments

N

(N >= 2) vector of number of replications of each treatment

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

The Freidman chi-squared is used for nonparametric ANOVA. The data in N rows of an N x r table are ranked separately such that the ranks take the values from 1 to r in the N different rows. The distributions are obtained on the assumption that there is no relationship between the N rows.

Formulae:

Let Rj be the sum of ranks for treatment j (j=1 … r), then the Friedman statistic is

x=[12/(N r (r+1))]Sum(1 … r)(Rj^2) - 3 N (r+1)

this is asymptotically equivalent to a chi squared random variable. One may also calculate the chi squared statistic for the usual analysis of variance which gives

F=((N-1) x)/(N (r-1)-x)

which may be used with the F distribution functions in R for degrees of freedom (r-1) and (N-1)(r-1).

Value

The output values conform to the output from other such functions in R. dFriedman() gives the density, pFriedman() the distribution function and qFriedman() its inverse. rFriedman() generates random numbers. sFriedman() 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.

Note

Exact calculations are made for the following values of the parameters:

r N
2 100
3 30
4 15
5 8

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

The incomplete beta, with continuity correction, is used for calculations outside these ranges. Some appreciation for the accuracy of the approximation may be obtained by comparing the calculated values with exact tables such as Odeh (1977). Iman and Davenport (1980) have studied the accuracy of various approximations.

Author(s)

Bob Wheeler

References

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

Iman, R.L. and Davenport, J.M. (1980). Approximations of the critical region of the Friedman statistic. Comm. Stat. Theor. Meth. A9(6). 571-595.

Odeh, R.E. (1977). Extended tables of the distribution of Friedman's S-statistic in the two-way layout. Commun. Statist.-Simula. Computa. B6(1). 29-48.

Examples

pFriedman(2, r=5, N=10)
pFriedman(c(.8,3.5,9.3), r=5, N=10) ## approximately 5% 50% and 95%
sFriedman(r=5, N=10)
plot(function(x)dFriedman(x, r=5, N=10),0,10)

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.