#For the 97th percentile of the chi-square distribution with
#7 degrees of freedom (d.f.) type qchisq(.97,7)
qchisq(.97,7)
# Display the Chi-Square Distributions for different degrees of freedom
# degrees of freedom and compare to the normal distribution
y <- seq(0, 10, length=100)
hy <- dchisq(y,df=2)
degf <- c(3, 5, 8, 15)
colors <- c(“red”, “blue”, “darkgreen”, “gold”, “black”)
labels <- c(“df=3”, “df=5”, “df=8”, “df=15”, “df=2″)
plot(y, hy, type=”l”, lty=2, xlab=”x value”,
ylab=”Density”, main=”Comparison of Chi Square Distributions”)
for (i in 1:4){
lines(y, dchisq(y,df=degf[i]), lwd=2, col=colors[i])
}
legend(“topright”, inset=.05, title=”Distributions”,
labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors)