2026-10-17

Correlation and Linear Regression in Biology

DAT 301 — Homework 3

Presented by: Saud Alatwi

Topics: - Correlation in biological data - Pearson correlation coefficient - Simple linear regression - Biological applications

Introduction

Correlation and linear regression are statistical methods used to study relationships between variables.

  • Correlation measures the strength and direction of a relationship.
  • Linear regression models the relationship between an explanatory variable and a response variable.
  • Both methods are useful for analyzing biological data.

Pearson Correlation Coefficient

The Pearson correlation coefficient (r) measures the strength and direction of a linear relationship between two numerical variables.

  • r = +1: Perfect positive correlation.
  • r = -1: Perfect negative correlation.
  • r = 0: No linear correlation.
  • Positive correlation: Both variables tend to increase together.
  • Negative correlation: One variable tends to decrease as the other increases.

Biological Example

Height and weight may show a positive correlation because taller individuals often weigh more.

Biological Example: Height vs. Weight

We will examine the relationship between height and weight using the built-in women dataset in R.

## [1] 0.9954948

Interpretation of Correlation Results

The Pearson correlation coefficient between height and weight is approximately 0.9955.

This indicates a very strong positive linear relationship between the two variables.

As height increases, weight also tends to increase in this dataset.

However, correlation does not necessarily imply causation.

Simple Linear Regression

Linear regression is used to predict a response variable based on an explanatory variable.

The general equation is:

\[ Y = \beta_0 + \beta_1 X \]

  • Y: Predicted response variable
  • X: Explanatory variable
  • β₀: Intercept
  • β₁: Slope

Biological Example

We will use height to predict weight.

## 
## Call:
## lm(formula = weight ~ height, data = women)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7333 -1.1333 -0.3833  0.7417  3.1167 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -87.51667    5.93694  -14.74 1.71e-09 ***
## height        3.45000    0.09114   37.85 1.09e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.525 on 13 degrees of freedom
## Multiple R-squared:  0.991,  Adjusted R-squared:  0.9903 
## F-statistic:  1433 on 1 and 13 DF,  p-value: 1.091e-14

Interpretation of Linear Regression

The linear regression model shows a strong positive relationship between height and weight.

  • The R-squared value is 0.991.
  • Approximately 99.1% of the variation in weight is explained by height in this dataset.
  • The p-value is less than 0.001, indicating a statistically significant linear relationship.
  • The regression line closely follows the observed data points.

Biological Significance

This example demonstrates how linear regression can be used to describe and predict relationships between biological measurements.

However, predictions should be limited to the range of heights represented in the dataset.

Mathematics of Pearson Correlation

The Pearson correlation coefficient is calculated using:

\[ r = \frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})} {\sqrt{\sum_{i=1}^{n}(x_i-\bar{x})^2 \sum_{i=1}^{n}(y_i-\bar{y})^2}} \]

Where:

  • \(x_i\) and \(y_i\) are individual observations.
  • \(\bar{x}\) and \(\bar{y}\) are the sample means.
  • \(n\) is the number of observations.

The coefficient ranges from -1 to +1.

Mathematics of Linear Regression

Simple linear regression describes the relationship between two variables.

The regression equation is:

\[ \hat{y} = \beta_0 + \beta_1 x \]

Where:

  • \(\hat{y}\) = Predicted value of the response variable.
  • \(\beta_0\) = Intercept of the regression line.
  • \(\beta_1\) = Slope of the regression line.
  • \(x\) = Explanatory variable.

The slope can be calculated using:

\[ \hat{\beta}_1 = \frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})} {\sum_{i=1}^{n}(x_i-\bar{x})^2} \]

Biological Application:

In our example, height is the explanatory variable and weight is the response variable.

The regression model predicts weight based on height.