Chi-Square, t and F Distribution

The Chi-Square Distribution

Recall that the Gamma distribution has several special cases depending on its parameters α and β. Using the dgamma function in R, we can graph a few cases. The dgamma commonly takes in a vector, a rate (alpha) and a shape (Beta).

exp_seq <- seq(0, 7, .001) #sequence from 0 to 5 by .001
plot(exp_seq, dgamma(exp_seq, 1,1), col="red", main="Gamma Density Distribution",
     xlab="x", ylab="f(x)", cex=0.02)
lines(exp_seq, dgamma(exp_seq, 2, 1), col="orange")
lines(exp_seq, dgamma(exp_seq, 3, 1), col="yellow")
lines(exp_seq, dgamma(exp_seq, 4, 1), col="green")
lines(exp_seq, dgamma(exp_seq, 5, 1), col="blue")
legend(4.5, 1, legend=c("α=1, β=1", "α=2, β=1", "α=3, β=1", "α=4, β=1", "α=5, β=1"),
 col=c("red", "orange", "yellow", "green", "blue"), 
 lty=1, 
 cex=0.8)

plot_zoom_pngThe Exponential is a special case of the Gamma Distribution with Γ(α=1, β=1/λ) .Screen Shot 2017-08-06 at 1.24.42 PM
The Chi-square (χ²) is also special case of the Gamma distribution, with Γ(α=½, β=2). To see this, let Z be a standard normal random variable from ~N(0,1). If you square Z, then Z² is a chi-square variable with degrees of freedom 1 notated here as χ²₁ .
Take a look at the transformation of a standard normal graph squared.

# z is standard normal N(0,1)

z <- rnorm(n = 10000, mean = 0, sd = 1)
hist(z)

Unknown

# Creating a chi-square distribution by squaring the values
x = z^2
hist(x, bins=5)

Unknown-1

Notice the shape of the chi-square distribution is similar to a gamma density distribution. This can be proved using the definition above and the Distribution Function Technique. If Z~N(0,1) and X=Z², then x~χ²₁.

Screen Shot 2017-08-06 at 2.08.27 PM
Take the derivative of the cdf to find the pdf.

Screen Shot 2017-08-06 at 2.08.37 PM
Since Z follows a standard normal distribution:
Screen Shot 2017-08-06 at 2.08.10 PM
This simplifies to:
Screen Shot 2017-08-06 at 2.04.54 PM.png
This is the pdf for Γ(α=½, β=2) and it is called a chi-square of degrees of freedom 1.

The t Distribution

A t distribution is created using the ratio of a standard normal and the square root of a chi-square divided by its degrees of freedom.

Z ~ N(0,1)
U ~χ²n
Screen Shot 2017-08-06 at 2.17.40 PMis a t distribution with n degrees of freedom.
The following graph shows how several t distributions compare to the standard normal curve.

curve(dnorm(x), -4.5, 4.5, col = "red")
curve(dt(x, df = 1), add = TRUE)
curve(dt(x, df = 5), add = TRUE)
curve(dt(x, df = 15), add = TRUE)

Unknown-2
The pdf of the t distribution with n degrees of freedom is quite complicated, but its expected value is 0 and the variance is n/n-2. As the degrees of freedom increase, the t distribution tends toward the standard normal (notice the variance approaches 1 as n⇒∞). This can be seen in the graph as well. The tails of the t distribution as higher but they approach N(0,1) as the degrees of freedom increase.

The F Distribution

Let U ~ χ²n and V ~ χ²m. If U and V are independent then the ratio of

Screen Shot 2017-08-06 at 2.28.37 PM.png  is an F distribution notated n,m.

f_seq <- seq(0, 7, .001) 
f_dist <- df(f_seq, df1 = 3, df2 = 4)
plot(f_dist, main = "F-Distribution w/ df1=3 and df2=4")

plot_zoom_png-1.png

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s