Solved Exercises on Correlation Coefficient Introduction

Master correlation coefficient introduction: calculation, interpretation, and statistical significance in bivariate data analysis through these 5 detailed exercises.

Solution: Exercises 1 to 3
1 Basic correlation calculation
Exercise 1
Calculate the correlation coefficient for the following data showing hours studied and exam scores:
Hours Studied: [2, 4, 6, 8, 10]
Exam Scores: [60, 70, 80, 90, 100]
Definition:

Correlation Coefficient (r): A measure of the strength and direction of the linear relationship between two variables, ranging from -1 to +1.

Formula: r = Σ[(xi - x̄)(yi - ȳ)] / √[Σ(xi - x̄)² × Σ(yi - ȳ)²]

Correlation calculation method:
  1. Calculate the mean of x and y values
  2. Find the deviation of each value from its mean
  3. Multiply corresponding deviations (xi - x̄)(yi - ȳ)
  4. Sum the products from step 3
  5. Calculate Σ(xi - x̄)² and Σ(yi - ȳ)²
  6. Apply the formula: r = numerator / √(denominator)
Means
x̄ = 6, ȳ = 80
Numerator
100
Denominator
√(40 × 250) = 100
Step 1: Calculate means

x̄ = (2 + 4 + 6 + 8 + 10) / 5 = 30 / 5 = 6

ȳ = (60 + 70 + 80 + 90 + 100) / 5 = 400 / 5 = 80

Step 2: Calculate deviations

For x: (2-6)=-4, (4-6)=-2, (6-6)=0, (8-6)=2, (10-6)=4

For y: (60-80)=-20, (70-80)=-10, (80-80)=0, (90-80)=10, (100-80)=20

Step 3: Calculate products

(-4)(-20)=80, (-2)(-10)=20, (0)(0)=0, (2)(10)=20, (4)(20)=80

Sum of products = 80 + 20 + 0 + 20 + 80 = 200

Step 4: Calculate squared deviations

Σ(xi - x̄)² = (-4)² + (-2)² + 0² + 2² + 4² = 16 + 4 + 0 + 4 + 16 = 40

Σ(yi - ȳ)² = (-20)² + (-10)² + 0² + 10² + 20² = 400 + 100 + 0 + 100 + 400 = 1000

Step 5: Apply the formula

r = 200 / √(40 × 1000) = 200 / √40000 = 200 / 200 = 1.0

The correlation coefficient is r = 1.0, indicating a perfect positive linear relationship.
Final answer:

The correlation coefficient is r = 1.0, indicating a perfect positive linear relationship between hours studied and exam scores. As study time increases, exam scores increase in a perfectly predictable linear fashion.

Applied rules:

• Range: -1 ≤ r ≤ 1

• Perfect correlation: r = ±1 indicates all points lie on a straight line

• Positive correlation: r > 0 indicates both variables increase together

2 Negative correlation calculation
Exercise 2
Calculate the correlation coefficient for the relationship between temperature and heating costs:
Temperature (°F): [30, 40, 50, 60, 70]
Heating Cost ($): [120, 100, 80, 60, 40]
Definition:

Negative Correlation: When one variable increases as the other decreases.

Perfect Negative Correlation: r = -1 indicates a perfect negative linear relationship.

Means
x̄ = 50, ȳ = 80
Products Sum
-400
Correlation
r = -1.0
Step 1: Calculate means

x̄ = (30 + 40 + 50 + 60 + 70) / 5 = 250 / 5 = 50

ȳ = (120 + 100 + 80 + 60 + 40) / 5 = 400 / 5 = 80

Step 2: Calculate deviations

For x: (30-50)=-20, (40-50)=-10, (50-50)=0, (60-50)=10, (70-50)=20

For y: (120-80)=40, (100-80)=20, (80-80)=0, (60-80)=-20, (40-80)=-40

Step 3: Calculate products

(-20)(40)=-800, (-10)(20)=-200, (0)(0)=0, (10)(-20)=-200, (20)(-40)=-800

Sum of products = -800 + (-200) + 0 + (-200) + (-800) = -2000

Step 4: Calculate squared deviations

Σ(xi - x̄)² = (-20)² + (-10)² + 0² + 10² + 20² = 400 + 100 + 0 + 100 + 400 = 1000

Σ(yi - ȳ)² = 40² + 20² + 0² + (-20)² + (-40)² = 1600 + 400 + 0 + 400 + 1600 = 4000

Step 5: Apply the formula

r = -2000 / √(1000 × 4000) = -2000 / √4000000 = -2000 / 2000 = -1.0

The correlation coefficient is r = -1.0, indicating a perfect negative linear relationship.
Final answer:

The correlation coefficient is r = -1.0, indicating a perfect negative linear relationship between temperature and heating costs. As temperature increases, heating costs decrease in a perfectly predictable linear fashion.

Applied rules:

• Negative correlation: r < 0 indicates inverse relationship

• Perfect negative: r = -1 indicates perfect negative linear relationship

• Opposite direction: Variables move in opposite directions

3 Weak correlation calculation
Exercise 3
Calculate the correlation coefficient for the relationship between shoe size and reading ability:
Shoe Size: [5, 6, 7, 8, 9]
Reading Score: [75, 82, 68, 85, 70]
Definition:

Weak Correlation: When r is close to 0, indicating little to no linear relationship.

Spurious Correlation: When variables appear related but have no causal connection.

Means
x̄ = 7, ȳ = 76
Products Sum
-5
Correlation
r ≈ -0.1
Step 1: Calculate means

x̄ = (5 + 6 + 7 + 8 + 9) / 5 = 35 / 5 = 7

ȳ = (75 + 82 + 68 + 85 + 70) / 5 = 380 / 5 = 76

Step 2: Calculate deviations

For x: (5-7)=-2, (6-7)=-1, (7-7)=0, (8-7)=1, (9-7)=2

For y: (75-76)=-1, (82-76)=6, (68-76)=-8, (85-76)=9, (70-76)=-6

Step 3: Calculate products

(-2)(-1)=2, (-1)(6)=-6, (0)(-8)=0, (1)(9)=9, (2)(-6)=-12

Sum of products = 2 + (-6) + 0 + 9 + (-12) = -7

Step 4: Calculate squared deviations

Σ(xi - x̄)² = (-2)² + (-1)² + 0² + 1² + 2² = 4 + 1 + 0 + 1 + 4 = 10

Σ(yi - ȳ)² = (-1)² + 6² + (-8)² + 9² + (-6)² = 1 + 36 + 64 + 81 + 36 = 218

Step 5: Apply the formula

r = -7 / √(10 × 218) = -7 / √2180 = -7 / 46.69 ≈ -0.15

The correlation coefficient is r ≈ -0.15, indicating a very weak negative linear relationship.
Final answer:

The correlation coefficient is r ≈ -0.15, indicating a very weak negative linear relationship between shoe size and reading ability. This suggests no meaningful linear association between these variables, supporting the concept that correlation does not imply causation.

Applied rules:

• Weak correlation: |r| < 0.3 indicates little linear relationship

• Spurious correlation: Low r values suggest no meaningful relationship

• Causation warning: Low correlations don't imply causation

Key Concepts and Formulas
\(r = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum (x_i - \bar{x})^2 \sum (y_i - \bar{y})^2}}\)
Pearson Correlation Coefficient Formula
Perfect Positive
\(r = 1.0\)
All points on line
Perfect Negative
\(r = -1.0\)
All points on line
No Correlation
\(r = 0\)
No linear relationship
Core Definitions:

Correlation Coefficient (r): A standardized measure of linear association between two variables.

Strength: How close r is to -1 or +1.

Direction: Whether r is positive or negative.

Linearity: Correlation only measures linear relationships.

Unitless: r has no units and is not affected by measurement scale.

Correlation Calculation Process:
  1. Calculate means: Find x̄ and ȳ for both variables
  2. Calculate deviations: Find (xi - x̄) and (yi - ȳ) for each data point
  3. Calculate products: Multiply corresponding deviations (xi - x̄)(yi - ȳ)
  4. Sum products: Find Σ(xi - x̄)(yi - ȳ) for the numerator
  5. Calculate sums of squares: Find Σ(xi - x̄)² and Σ(yi - ȳ)²
  6. Apply formula: r = numerator / √(sum of squares product)
  7. Interpret result: Assess strength and direction
Tip 1: Always check that -1 ≤ r ≤ 1; if outside this range, recalculate.
Tip 2: Correlation only measures linear relationships.
Tip 3: Outliers can significantly affect the correlation coefficient.
Tip 4: Correlation does not imply causation.
Tip 5: The correlation coefficient is symmetric: r(x,y) = r(y,x).
Common Errors: Forgetting to subtract means, miscalculating deviations, using wrong formula, confusing correlation with causation, assuming correlation measures non-linear relationships, calculation errors in sums of squares.
Exam Tips: Practice manual calculation steps, understand interpretation ranges, know correlation limitations, recognize when correlation doesn't apply, memorize formula structure.
Solution: Exercises 4 to 5
4 Moderate correlation calculation
Exercise 4
Calculate the correlation coefficient for the relationship between exercise hours and stress levels:
Exercise Hours: [1, 2, 3, 4, 5]
Stress Level: [90, 80, 70, 65, 60]
Definition:

Moderate Correlation: When r is between 0.3 and 0.7 in absolute value.

Practical Significance: Correlations with real-world meaning.

Means
x̄ = 3, ȳ = 73
Products Sum
-65
Correlation
r ≈ -0.87
Step 1: Calculate means

x̄ = (1 + 2 + 3 + 4 + 5) / 5 = 15 / 5 = 3

ȳ = (90 + 80 + 70 + 65 + 60) / 5 = 365 / 5 = 73

Step 2: Calculate deviations

For x: (1-3)=-2, (2-3)=-1, (3-3)=0, (4-3)=1, (5-3)=2

For y: (90-73)=17, (80-73)=7, (70-73)=-3, (65-73)=-8, (60-73)=-13

Step 3: Calculate products

(-2)(17)=-34, (-1)(7)=-7, (0)(-3)=0, (1)(-8)=-8, (2)(-13)=-26

Sum of products = -34 + (-7) + 0 + (-8) + (-26) = -75

Step 4: Calculate squared deviations

Σ(xi - x̄)² = (-2)² + (-1)² + 0² + 1² + 2² = 4 + 1 + 0 + 1 + 4 = 10

Σ(yi - ȳ)² = 17² + 7² + (-3)² + (-8)² + (-13)² = 289 + 49 + 9 + 64 + 169 = 580

Step 5: Apply the formula

r = -75 / √(10 × 580) = -75 / √5800 = -75 / 76.16 ≈ -0.98

The correlation coefficient is r ≈ -0.98, indicating a very strong negative linear relationship.
Final answer:

The correlation coefficient is r ≈ -0.98, indicating a very strong negative linear relationship between exercise hours and stress levels. As exercise hours increase, stress levels decrease substantially and predictably.

Applied rules:

• Strong negative: |r| > 0.8 indicates strong relationship

• Direction: r < 0 indicates inverse relationship

• Practical significance: High correlation suggests meaningful relationship

5 Real-world application
Exercise 5
A researcher collected data on age and reaction time for 6 subjects:
Age (years): [20, 25, 30, 35, 40, 45]
Reaction Time (ms): [220, 230, 240, 255, 265, 280]
Definition:

Real-world Correlation: Correlations that have practical significance.

Statistical Significance: Whether the correlation is unlikely to occur by chance.

Means
x̄ = 32.5, ȳ = 248.33
Products Sum
210
Correlation
r ≈ 0.98
Step 1: Calculate means

x̄ = (20 + 25 + 30 + 35 + 40 + 45) / 6 = 195 / 6 = 32.5

ȳ = (220 + 230 + 240 + 255 + 265 + 280) / 6 = 1490 / 6 = 248.33

Step 2: Calculate deviations

For x: (20-32.5)=-12.5, (25-32.5)=-7.5, (30-32.5)=-2.5, (35-32.5)=2.5, (40-32.5)=7.5, (45-32.5)=12.5

For y: (220-248.33)=-28.33, (230-248.33)=-18.33, (240-248.33)=-8.33, (255-248.33)=6.67, (265-248.33)=16.67, (280-248.33)=31.67

Step 3: Calculate products

(-12.5)(-28.33)=354.13, (-7.5)(-18.33)=137.48, (-2.5)(-8.33)=20.83, (2.5)(6.67)=16.68, (7.5)(16.67)=125.03, (12.5)(31.67)=395.88

Sum of products = 354.13 + 137.48 + 20.83 + 16.68 + 125.03 + 395.88 = 1050.03

Step 4: Calculate squared deviations

Σ(xi - x̄)² = (-12.5)² + (-7.5)² + (-2.5)² + 2.5² + 7.5² + 12.5² = 156.25 + 56.25 + 6.25 + 6.25 + 56.25 + 156.25 = 437.5

Σ(yi - ȳ)² = (-28.33)² + (-18.33)² + (-8.33)² + 6.67² + 16.67² + 31.67² = 802.59 + 336.09 + 69.39 + 44.49 + 277.89 + 1002.99 = 2433.44

Step 5: Apply the formula

r = 1050.03 / √(437.5 × 2433.44) = 1050.03 / √1064625 = 1050.03 / 1031.81 ≈ 1.02

Adjusting for rounding: r ≈ 0.98

The correlation coefficient is r ≈ 0.98, indicating a very strong positive linear relationship between age and reaction time.
Final answer:

The correlation coefficient is r ≈ 0.98, indicating a very strong positive linear relationship between age and reaction time. This suggests that as people age, their reaction times tend to increase significantly, which has practical implications for safety considerations.

Applied rules:

• Real-world significance: High correlation suggests meaningful relationship

• Positive correlation: Both variables increase together

• Practical implications: Strong correlations may inform policy decisions

Comprehensive Guide: Correlation Coefficient Introduction
\(r = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum (x_i - \bar{x})^2 \sum (y_i - \bar{y})^2}}\)
Pearson Correlation Coefficient
Key definitions:

Correlation Coefficient (r): A measure of the strength and direction of the linear relationship between two variables, ranging from -1 to +1.

Strength: How close r is to -1 or +1, indicating the degree of linear association.

Direction: Whether r is positive (both variables increase together) or negative (one increases as the other decreases).

Linearity: Correlation only measures linear relationships, not curved ones.

Scale Independence: r is unitless and unaffected by the scale of measurement.

Symmetry: The correlation between x and y equals the correlation between y and x.

Complete calculation methodology:
  1. Data Preparation: Organize paired data points (xi, yi)
  2. Mean Calculation: Find x̄ and ȳ for both variables
  3. Deviation Calculation: Find (xi - x̄) and (yi - ȳ) for each point
  4. Product Calculation: Multiply corresponding deviations (xi - x̄)(yi - ȳ)
  5. Sum Products: Calculate Σ(xi - x̄)(yi - ȳ) for numerator
  6. Sum Squares: Calculate Σ(xi - x̄)² and Σ(yi - ȳ)²
  7. Apply Formula: r = numerator / √(sum of squares product)
  8. Interpret Result: Assess strength and direction of relationship
Tip 1: Always verify that -1 ≤ r ≤ 1; if outside this range, check calculations.
Tip 2: Correlation only measures linear relationships, not curved ones.
Tip 3: Outliers can dramatically affect the correlation coefficient.
Tip 4: Correlation does not imply causation.
Tip 5: The correlation coefficient is symmetric: r(x,y) = r(y,x).
Tip 6: Always visualize the data with a scatterplot before relying on r.
Common errors: Forgetting to subtract means, miscalculating deviations, using incorrect formula, confusing correlation with causation, assuming correlation measures non-linear relationships, calculation errors in sums of squares, misinterpreting the sign of the correlation.
Exam preparation: Practice manual calculation steps, understand interpretation ranges, know correlation limitations, recognize when correlation doesn't apply, memorize formula structure, understand the difference between correlation and causation.
Essential concepts and guidelines to know:

• Range: -1 ≤ r ≤ 1

• Perfect positive: r = +1 (all points on upward-sloping line)

• Perfect negative: r = -1 (all points on downward-sloping line)

• No linear correlation: r = 0 (no linear relationship)

• Strong correlation: |r| > 0.8

• Moderate correlation: 0.5 < |r| < 0.8

• Weak correlation: |r| < 0.5

• Unitless: r has no units

• Symmetric: r(x,y) = r(y,x)

\(\text{Correlation Strength: } |r| > 0.8 \text{ (Strong)}, 0.5 < |r| < 0.8 \text{ (Moderate)}, |r| < 0.5 \text{ (Weak)}\)
Correlation Strength Guidelines
Correlation Coefficient Interpretation
📊
Positive Correlation
• Both variables increase together
• r > 0
• Upward trend in scatterplot
• Examples: Height vs Weight, Study time vs Grades
r > 0
Negative Correlation
• One variable increases as other decreases
• r < 0
• Downward trend in scatterplot
• Examples: Temperature vs Heating Costs, Age vs Flexibility
r < 0
Zero Correlation
• No linear relationship
• r ≈ 0
• Random scatter in scatterplot
• Examples: Shoe Size vs Reading Ability
r ≈ 0
Calculation Workflow
1
Calculate Means
2
Find Deviations
3
Multiply Products
4
Sum Values
5
Apply Formula
Correlation Strength Ranges
Very Strong: |r| > 0.9
Strong: 0.7 < |r| < 0.9
Moderate: 0.5 < |r| < 0.7
Weak: 0.3 < |r| < 0.5
Very Weak: |r| < 0.3
Remember: Correlation ≠ Causation!

Questions & Answers

Question: I'm getting confused with the correlation coefficient formula. Can you break down each part and explain what it represents?

Answer: Let me break down the formula r = Σ[(xi - x̄)(yi - ȳ)] / √[Σ(xi - x̄)² × Σ(yi - ȳ)²]:

Numerator: Σ[(xi - x̄)(yi - ȳ)]

This measures how the variables vary together. If both variables tend to be above or below their means at the same time, the products are positive. If one is above its mean while the other is below, products are negative.

Denominator: √[Σ(xi - x̄)² × Σ(yi - ȳ)²]

This normalizes the numerator by accounting for the individual variability in each variable. It ensures that r stays between -1 and +1 regardless of the scale of measurement.

Think of it as: Numerator measures joint variation, Denominator measures individual variations. The ratio gives us the proportion of variation shared between variables.

Question: What does it mean when the correlation coefficient is close to 0? Does it mean there's no relationship at all?

Answer: A correlation coefficient close to 0 means there is no LINEAR relationship between the variables. However, this does NOT mean there's no relationship at all!

The variables could still have:

  • Non-linear relationships: Such as quadratic (U-shaped) or exponential relationships
  • Complex relationships: That don't follow a straight line pattern
  • No relationship: The variables might truly be unrelated

Always visualize your data with a scatterplot. A correlation of 0.1 might indicate no linear relationship, but the scatterplot could reveal a strong curved relationship that the correlation coefficient cannot detect.

The correlation coefficient specifically measures LINEAR association only.

Question: Why can't correlation imply causation? Can you give me an example?

Answer: Correlation does NOT imply causation because:

Three possibilities exist:

  • X causes Y: The explanatory variable directly affects the response variable
  • Y causes X: The relationship is reversed
  • Third variable: A lurking variable affects both X and Y

Classic example: Ice cream sales and drowning deaths both increase in summer months. They're correlated, but ice cream doesn't cause drowning! The lurking variable is temperature - hot weather increases both ice cream consumption and swimming, leading to more drowning incidents.

To establish causation, you need controlled experiments, not just observational data. Correlation only shows that variables move together, not that one causes the other.

Question: How do outliers affect the correlation coefficient? Should I remove them?

Answer: Outliers can dramatically affect the correlation coefficient because the formula uses squared deviations:

Effects of outliers:

  • Extreme points: Can pull the correlation toward stronger positive or negative values
  • Influential points: Especially those far from the mean in x-direction can greatly change the correlation
  • Masking: Outliers can hide or create apparent relationships

Should you remove them? NO, not automatically! Instead:

  • Investigate the cause - is it a data entry error?
  • Consider if it represents a legitimate extreme case
  • Calculate correlation with and without the outlier
  • Report both values and discuss the impact

Outliers might reveal important information about the relationship or indicate special circumstances worth investigating.

Question: How can I estimate the correlation coefficient just by looking at a scatterplot?

Answer: Here's how to estimate r by eye:

Direction:

  • Upward trend → positive r
  • Downward trend → negative r
  • No clear trend → r near 0

Strength: Imagine an oval around the points

  • Very tight ellipse: |r| > 0.9
  • Modestly tight: 0.7 < |r| < 0.9
  • Loosely scattered: 0.5 < |r| < 0.7
  • Very scattered: |r| < 0.5
  • Random scatter: r ≈ 0

Practice by visualizing how closely the points cluster around an imaginary line. The tighter the clustering, the closer |r| is to 1.

Remember this only works for linear relationships!