Which loan purpose mean is different?
Before we examine other factors besides purpose_recode that might influence the amount of loan funded, let's examine which means of purpose_recode are different. This is the post-hoc test referred to in the last exercise.
The result of that ANOVA test was statistically significant with a very low p-value. This means we can reject the null hypothesis and accept the alternative hypothesis that at least one mean was different. But which one?
We should use Tukey's HSD test, which stands for Honest Significant Difference. To conduct Tukey's HSD test in R, you can use TukeyHSD():
TukeyHSD(aov_model, "independent_variable_name", conf.level = 0.9)
This would conduct Tukey's HSD test on some aov_model, looking at a specific "independent_variable_name", with a conf.level of 90%.
This exercise is part of the course
Experimental Design in R
Exercise instructions
- Build a model using
aov()that examinesfunded_amntbypurpose_recode. Save it aspurpose_aov. - Use
TukeyHSD()to conduct the Tukey's HSD test onpurpose_aovwith a confidence level of 0.95. Save as an object calledtukey_output. - Tidy
tukey_outputwithtidy()from thebroompackage (which has been loaded for you.)
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Use aov() to build purpose_aov
___ <- aov(___ ~ ___, data = ___)
# Conduct Tukey's HSD test to create tukey_output
___ <- TukeyHSD(___, "___", conf.level = ___)
# Tidy tukey_output to make sense of the results
tidy(___)