Markdown

title: “Simple Linear Regression in Biological Systems” output: ioslides_presentation: mathjax: default —

Introduction to Regression

The Mathematical Model

The population simple linear regression model is expressed as:

\[Y_i = \beta_0 + \beta_1 X_i + \varepsilon_i\]

Where: * \(Y_i\) is the dependent response variable for observation \(i\). * \(X_i\) is the independent predictor variable. * \(\beta_0\) is the \(y\)-intercept parameter. * \(\beta_1\) is the slope parameter representing the rate of change. * \(\varepsilon_i\) represents independent normally distributed error terms with mean zero: \(\varepsilon_i \sim N(0, \sigma^2)\).

Parameter Estimation & Least Squares

To find the optimal estimates \(\hat{\beta}_0\) and \(\hat{\beta}_1\), the method of ordinary least squares (OLS) minimizes the sum of squared residuals (\(SSR\)):

\[SSR = \sum_{i=1}^{n} (Y_i - \hat{Y}_i)^2 = \sum_{i=1}^{n} (Y_i - (\hat{\beta}_0 + \hat{\beta}_1 X_i))^2\]

The resulting formulas for the slope and intercept estimators are:

\[\hat{\beta}_1 = \frac{\sum (X_i - \bar{X})(Y_i - \bar{Y})}{\sum (X_i - \bar{X})^2}, \quad \hat{\beta}_0 = \bar{Y} - \hat{\beta}_1 \bar{X}\]

R Code for Model Fitting

Here is the core code used to simulate biological data and fit a linear model in R:

```{r, eval=FALSE} set.seed(42) body_mass <- runif(50, 10, 100) metabolic_rate <- 2.5 * body_mass + rnorm(50, mean = 0, sd = 15)

Fit the linear model

model <- lm(metabolic_rate ~ body_mass) summary(model)