Skip to main content

Section 8.6 Understanding Correlation

Before we get to a linear regression, it is best to first understand how (if at all) our variables are correlated with each other. For a review on correlation, go back to SectionΒ 7.1 of the textbook.
We are first trying to figure out what variables, if any, should be included in our linear regression model, and this is exactly where correlation comes into play.
cor.test(pizza_sales$volume,pizza_sales$price)
Pearson's product-moment correlation

data:  pizza_sales$volume and pizza_sales$price
t = -10.8, df = 154, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.7375315 -0.5567684
sample estimates:
       cor 
-0.6564736
When we run a correlation, we are looking for three things:
  1. The direction: is a positive or negative interaction?
  2. The strength: how close is it to -1, 0, 1?
  3. The p-value: Is it statistically significant?
The code above answers all three questions:
  1. The direction: is negative.
  2. The strength: about βˆ’0.66, indicating a moderately strong negative correlation.
  3. The p-value: < 0.05 indicates that the relationship between price and volume is unlikely due to chance.
With a correlation coefficient of -0.66, we have a moderately strong negative correlation between price and volume. As price goes up, volume goes down - just what we saw in our graphs!