7.4 Correlation
With linear regression, we designate one variable as the exposure variable and one as the outcome. We might also wish to know how two variables are related without this specification. To do that, we can use the correlation coefficient. The correlation coefficient is a measure of how much two variables vary together, and it takes values between -1 and 1. Values towards 0 are indicative of no correlation. Values towards 1 are indicative of positive correlation, where both variables increase together, and values towards -1 are indicative of negative correlation, where one variable decreases as the other increases.
#--- Get correlation coefficient
bab9 %$% cor(bweight, gestwks)
## [1] 0.738
Exercise 16.4: What is the value of the correlation coefficient? What does this mean?