Section 7.10 Grouped Correlations
While being a first generation college student may not be a strong correlation, maybe there are differences within the groups, and a grouped correlation should be conducted. To do this, all we need to do is first group by first generation college student, and then run correlations on our desired variables.
examData |>
group_by(first_generation_college_student) |>
summarise(
"Hours & Exam (r)" = cor(studying_hours, exam_score, use = "complete.obs"),
"Anxiety & Exam (r)" = cor(anxiety_score, exam_score, use = "complete.obs")
) |>
kable(digits = 2)
|first_generation_college_student | Hours & Exam (r)| Anxiety & Exam (r)| |:--------------------------------|----------------:|------------------:| |No | 0.45| -0.39| |Yes | 0.34| -0.51|
Our results show that direction does not change within the groups, but the strength of the correlations does. For instance, in students that are a first generation college student, anxiety scores have a deeper impact on exam scores than students who are not a first generation college student.
In chapter (Sectionย 8.1), weโll use what we learned here to build predictive models โ moving from describing relationships to forecasting outcomes.
