Exercise

# Generate density plot of the F-distribution

The test statistic associated with ANOVA is the F-test (or F-ratio). Recall that when carrying out a t-test, you computed an observed t-value, then compared that with a critical value derived from the relevant t-distribution. That t-distribution came from a family of t-distributions, each of which was defined entirely by its degrees of freedom.

ANOVA uses the same principle, but instead an observed F-value is computed and compared to the relevant F-distribution. That F-distribution comes from a family of F-distributions, each of which is defined by two numbers (i.e. degrees of freedom), which we'll refer to as `df1`

and `df2`

. The F-distribution has a different shape than the t-distribution and in this exercise, you'll generate a few density plots of the F-distribution to help visualize this.

Instructions

**100 XP**

- Use the
`seq()`

function to create a variable`x`

containing 200 numbers between 0 and 2. See`?seq`

if you need help with this. - Use
`df()`

to evaluate the densities for seven different t-distributions at these values of`x`

. The t-distributions should have the following degrees of freedom (`df1`

,`df2`

): (1,1), (3,1), (6,1), (3,3), (6,3), (3,6) and (6,6). For example,`dt(x, 5, 5)`

would evaluate the t-distribution with degrees of freedom (5,5) at all 200 values of`x`

. - Create line plots of these densities, using different colors for each. Use
`plot()`

to create the first (with argument`type = "l"`

for "line"), then use`lines()`

to create the rest, so that the lines get added to the original plot instead of overwriting it. - Add a legend to the topright corner of your plot with the title
`"F distributions"`

. In the script, you only have to fill in the first two arguments:`"topright"`

and`title = "___"`

.