Multiple Factor Experiments
We tested whether the purpose of a loan affects loan amount funded and found that it does. However, we also know that it's unlikely that loans are funded based only on their intended purpose. It's more likely that the company is looking at a holistic picture of an applicant before they decide to issue a loan.
We can examine more than one explanatory factor in a multiple factor experiment. Like our experiments on ToothGrowth
from Chapter 1, an experimenter can try and control two (or more!) different factors and see how they affect the outcome. We're using open data, so we can't quite control the factors here (they're submitted as someone fills out their loan application), but let's look at how a few other factors affect loan amount funded.
This exercise is part of the course
Experimental Design in R
Exercise instructions
- Use
aov()
to build a linear model and ANOVA in one step, examining howpurpose_recode
and employment length (emp_length
) affect the funded amount. Save as an objectpurpose_emp_aov
and print the result out. - The printed
purpose_emp_aov
does not show p-values, which we might be interested in. Display those by callingsummary()
on theaov
object.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Use aov() to build purpose_emp_aov
___ <- aov(funded_amnt ~ ___ + ___, ___ = ___)
# Print purpose_emp_aov to the console
purpose_emp_aov
# Call summary() to see the p-values
summary(___)