Chi-Square Distribution

DESCRIPTION:
Density, cumulative probability, quantiles and random generation for the chi-square distribution.

USAGE:
dchisq(x, df)
pchisq(q, df, ncp=0)
qchisq(p, df)
rchisq(n, df)

REQUIRED ARGUMENTS:
x:
vector of quantiles. Missing values (NAs) are allowed.
q:
vector of (positive) quantiles. Missing values (NAs) are allowed.
p:
vector of probabilities. Missing values (NAs) are allowed.
n:
sample size. If length(n) is larger than 1, then length(n) random values are returned.
df:
degrees of freedom (> 0). This is replicated to be the same length as p or q or the number of deviates generated. Non-integer values are allowed, but missing values are not.

OPTIONAL ARGUMENTS:
ncp:
vector of non-negative numbers giving the noncentrality parameter.

VALUE:
density (dchisq), probability (pchisq), quantile (qchisq), or random sample (rchisq) for the chi-square distribution with df degrees of freedom.

SIDE EFFECTS:
The function rchisq causes creation of the dataset .Random.seed if it does not already exist, otherwise its value is updated.

DETAILS:
Elements of q or p that are missing will cause the corresponding elements of the result to be missing.

Assume that the noncentral chisquare is the sum of df independent Gaussian random variables, then the noncentrality parameter is equal to the sum of the squared means of the Gaussian variables. See Posten (1989) for a description of the computing algorithm for noncentrality in pf.


BACKGROUND:
The chi-square distribution takes on positive real values. A specialization of the gamma distribution (see Gamma), it is important because many quadratic forms follow the chi-square distribution under the assumption that the data follow the Gaussian (normal) distribution. In particular the sample variance is a scaled chi-square variable. Likelihood ratio statistics are also approximately distributed as a chi-square.

REFERENCES:
Johnson, N. L. and Kotz, S. (1970). Continuous Univariate Distributions, vol. 1. Houghton-Mifflin, Boston.

Posten, H. O. (1989). An effective algorithm for the noncentral chi-squared distribution function. The American Statistician 43 261-263.


SEE ALSO:
set.seed , Gamma , Normal , F .

EXAMPLES:
1-pchisq(stat,df) # p-value for stat

# power of a test for several noncentrality values 1 - pchisq(qchisq(.95, 8), 8, 0:10)