DAT 301 — Homework 3
Presented by: Saud Alatwi
Topics: - Correlation in biological data - Pearson correlation coefficient - Simple linear regression - Biological applications
2026-10-17
Presented by: Saud Alatwi
Topics: - Correlation in biological data - Pearson correlation coefficient - Simple linear regression - Biological applications
Correlation and linear regression are statistical methods used to study relationships between variables.
The Pearson correlation coefficient (r) measures the strength and direction of a linear relationship between two numerical variables.
Height and weight may show a positive correlation because taller individuals often weigh more.
We will examine the relationship between height and weight using the built-in women dataset in R.
## [1] 0.9954948
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.
Linear regression is used to predict a response variable based on an explanatory variable.
The general equation is:
\[ Y = \beta_0 + \beta_1 X \]
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
The linear regression model shows a strong positive relationship between height and weight.
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.
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:
The coefficient ranges from -1 to +1.
Simple linear regression describes the relationship between two variables.
The regression equation is:
\[ \hat{y} = \beta_0 + \beta_1 x \]
Where:
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.