Chi-Square Distribution

DESCRIPTION:

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

USAGE:

dchisq(x, df, log=F) 
pchisq(q, df, ncp=0) 
qchisq(p, df) 
rchisq(n, df, bigdata=F) 

REQUIRED ARGUMENTS:

x
vector or bdVector of quantiles. Missing values ( NAs) are allowed.
q
vector or bdVector of (positive) quantiles. Missing values ( NAs) are allowed.
p
vector or bdVector 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 or bdVector of non-negative numbers giving the noncentrality parameter.
bigdata
a logical value; if TRUE, an object of type bdVector is returned. Otherwise, a vector object is returned. This argument can be used only if the bigdata library section has been loaded.
log
a logical scalar; if TRUE, dchisq will return the log of the density, not the density itself.

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.

For details on the uniform random number generator implemented in S-PLUS, see the set.seed help file.

REFERENCES:

Johnson, N. L. and Kotz, S. (1970). Continuous Univariate Distributions, vol. 2. 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:

, , , .

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)