Simple linear regression studies the relationship between two variables using a straight line.
- The predictor variable (x) is used to predict another variable.
- The response variable (y) is what we want to predict.
2026-10-17
Simple linear regression studies the relationship between two variables using a straight line.
The fitted regression line has the equation:
\[ \hat{y} = a + bx \]
We will use the built in ‘iris’ dataset.
We want to see whether petal length can help predict petal width.
The colors represent the three iris species.
We use ‘lm()’ to predict petal width from petal length.
mod = lm(Petal.Width ~ Petal.Length, data = iris) mod
## ## Call: ## lm(formula = Petal.Width ~ Petal.Length, data = iris) ## ## Coefficients: ## (Intercept) Petal.Length ## -0.3631 0.4158
The fitted regression equation is:
\[ \hat{y} = -0.3631 + 0.4158x \]
Here, \(x\) is petal length and \(\hat{y}\) is predicted petal width.
For each 1 cm increase in petal length, predicted petal width increases by approximately 0.4158 cm.
The positive slope indicates a positive relationship between petal length and petal width.
Petal width generally increases as petal length increases.