degfree <- c(1,2,3,4,6,9)
x <- seq(0.01,10,0.01)
#pre-allocating output to store the density
output <- vector("list", length(degfree))
for(i in 1:length(degfree)){
output[[i]] <- dchisq(x, degfree[i])
}
output <- data.frame(output)
colnames(output) <- c("df1", "df2", "df3", "df4", "df6", "df9")
output <- as.tibble(output) %>%
mutate(x = x)
output %>%
gather(key = "df", value = "y", "df1":"df9") %>%
ggplot() +
geom_line(aes(x, y, color = df)) +
coord_cartesian(ylim = c(0,.6))
As a result, the curves tends to flatten as the degree of freedom increase. The height is lower, the center shift from left to the right.
x <- seq(-5,5,0.01)
k <- c(3,5,10, 30)
output <- vector("list", length(k + 1))
for(i in 1:length(k)){
output[[i]] <- dt(x, k[i])
}
output[[5]] <- dnorm(x)
output <- data.frame(output)
colnames(output) <- c("df3", "df5", "df10", "df30", "normal")
output <- as.tibble(output) %>%
mutate(x = x) %>%
gather(key = "df", value = "y", "df3":"normal")
output %>%
ggplot() +
geom_line(aes(x,y, color = df)) +
coord_cartesian(xlim = c(-3,3))
As we can see, when degree of freedom is relatively small, the t distribution would have a fatter tail, and more spread in general. When the degree of freedom start to increase, the shape of the t distribution start to resemble more of the shape of a normal distribution.