Showing posts with label correlation calculation. Show all posts
Showing posts with label correlation calculation. Show all posts

Wednesday, August 28, 2024

Calculating Pearson's Correlation Coefficient with Height and Weight Data

### Example: Height and Weight

Suppose you have data for five people:

| Person | Height (in inches) | Weight (in pounds) |
|--------|---------------------|--------------------|
| A | 60 | 110 |
| B | 62 | 115 |
| C | 64 | 120 |
| D | 66 | 125 |
| E | 68 | 130 |

You want to calculate the correlation between height and weight.

1. **Calculate the mean of each variable:**
   - Mean Height: `(60 + 62 + 64 + 66 + 68) / 5 = 64`
   - Mean Weight: `(110 + 115 + 120 + 125 + 130) / 5 = 120`

2. **Find the deviations from the mean for each variable:**

   For Height: `-4, -2, 0, 2, 4`  
   For Weight: `-10, -5, 0, 5, 10`

3. **Compute the product of these deviations for each pair and average them:**

   - `(-4) * (-10) = 40`
   - `(-2) * (-5) = 10`
   - `0 * 0 = 0`
   - `2 * 5 = 10`
   - `4 * 10 = 40`

   Average of these products: `(40 + 10 + 0 + 10 + 40) / 5 = 20`

4. **Compute the standard deviations:**

   - For Height: `sqrt(((-4)^2 + (-2)^2 + 0^2 + 2^2 + 4^2) / 5) = sqrt((16 + 4 + 0 + 4 + 16) / 5) = sqrt(40 / 5) = sqrt(8) ≈ 2.83`
   - For Weight: `sqrt(((-10)^2 + (-5)^2 + 0^2 + 5^2 + 10^2) / 5) = sqrt((100 + 25 + 0 + 25 + 100) / 5) = sqrt(250 / 5) = sqrt(50) ≈ 7.07`

5. **Calculate Pearson’s r:**

   `r = 20 / (2.83 * 7.07) ≈ 20 / 20 = 1`

In this simplified example, Pearson's r = 1, indicating a perfect positive linear relationship between height and weight. As height increases, weight increases proportionally.

Featured Post

How HMT Watches Lost the Time: A Deep Dive into Disruptive Innovation Blindness in Indian Manufacturing

The Rise and Fall of HMT Watches: A Story of Brand Dominance and Disruptive Innovation Blindness The Rise and Fal...

Popular Posts