chicdf: The Cumulative Distribution Function for the Chi-Squared...

Description Usage Arguments Details Author(s) See Also Examples

View source: R/chicdf.R

Description

Calculates the CDF for the chi-squared distribution.

Usage

1
chicdf(X, k)

Arguments

X

a vector of input chi-squared values

k

the number of degrees of freedom

Details

The chi-squared distribution is the sum of the squares of k independent standard normal random variables, where k represents the number of degrees of freedom. Typically, k is estimated using the relation k = N - n, where N represents the number of data points (observations) in your data set, and n represents the number of fitted parameters in your model.

This function returns the cumulative distribution for a vector of given chi-squared values with an associated number k degrees of freedom.

Author(s)

Lee Kelvin <lee.kelvin@uibk.ac.at>

See Also

The astronomy package: astro.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
X = seq(0,8,len=1000)
kvals = c(1,2,3,4,6,9)
cols = c("yellow","green","turquoise","blue","purple","red")
aplot(NA, type="n", xlab=bquote(chi^2), 
ylab=bquote(paste(F[k],"(",chi^2,")",sep="")), xlim=c(0,8), 
ylim=c(0,1), main="Chi-Squared Cumulative Distribution Function")
grid(lty=1, col="grey90")
for(i in 1:length(kvals)){
    lines(X, chicdf(X=X, k=kvals[i]), lwd=3, col=cols[i])
}
legend("bottomright", legend=paste("k =",kvals), lwd=3, col=cols, 
bty="o", bg=acol("white",alpha=0.7), inset=0.04, text.font=3, 
box.col=NA)

Example output

Loading required package: MASS
Loading required package: plotrix

astro documentation built on May 2, 2019, 2:14 a.m.

Related to chicdf in astro...