Tip:
Highlight text to annotate it
X
Hi! I am Mike Marin and in this video
we'll talk about conducting one-way analysis of variance
and kruskal-Wallis one-way analysis of variance using R.
One-way analysis of variance
is a parametric method appropriate for comparing the Means
of two or more independent populations. We will work with a set of data
that compares Weight Loss for four different Diets. I've already gone ahead
and imported the data into R and attached it.
We will explore the relationship between Weight Loss
and Diet type. We can conduct an analysis of variance
using the "aov" command in R. To access the Help menu
type "help" and in brackets the name of the command you would like help for
or simply throw a question mark (?) in front of the command name.
Before conducting the test, it can be useful
to examine a box plot of the data. Here we would like to compare Weight Loss
separated by Diet type. In one way analysis of variance
we are testing the "null hypothesis that
the Mean Weight Loss is the same
for all Diets". we can conduct the analysis of variance
using the "aov" command. Here we'd like to compare Weight Losses
separated by Diet type. As noted in earlier videos in this series
we may like to save the output of this test
in an object; here I'll save it in an object
called ANOVA1.
We can have R return to us
a bit more informative summary using the "summery" command.
Here we would like a summary of the analysis of variance we fit.
We can see that we are returned the Sum of Squares
the Mean Squares,
the f-statistic of 6.118 and the p-value of 0.00113;
Recall
in earlier videos in this series we learned the "attributes" command.
We can use this command
to ask R to let us know all that is stored
in this object ANOVA1. We've also seen
that we can extract certain attributes from this objects using the dollar sign ($).
Here we can pull out the coefficients.
Now back to our analysis of variance:
here we can see that we will reject the null hypothesis and conclude that we have
evidence to believe
not all means are equal. We can use multiple comparisons
to help us decide which Means or Diets may differ from the others.
One option is to use the "TukeyHSD" command.
Here we would like to conduct all possible
pair-wise comparisons for this analysis of variance fit.
We are returned overall ninety-five percent (95%)
confidence intervals for the difference in Means of all possible pairs.
We're also returned an adjusted p-value;
if we would like a visual display of this table
we can add a "plot" command around this
"TukeyHSD" command. Here we can now see a visual display
which helps us identify which Means or Diets differ from each other and which do not.
We can edit this plot in the same way that we saw
in earlier videos in this series when discussing plotting.
For example we can set the
"las" argument equal to 1 to rotate the labels on the y-axis.
Let's now talk about producing the
kruskal-Wallis one-way analysis of variance using ranks.
Kruskal-Wallis one-way analysis of variance
is a nonparametric equivalent to the one-way analysis of variance;
we can conduct this test in R
using the "kruskal.test" command, just make sure to not let Wallace know
they left his name out of this command! here again
we would like to compare the Weight Loss for different Diet types.
Once again we will reject the null. In the next video in this series
we will discuss Pearson's chi-square test of independence.
thanks for watching this video and make sure to check out my other instructional videos.