2025-04-12

Introduction

What is Simple Linear Regression?

  • A statistical method to model the relationship between two variables
  • One independent (predictor) variable and one dependent (response) variable
  • \[ Y_i = \beta_0 + \beta_1 X_i + \epsilon_i \] where:
    – \(Y_i\) = Petal Length (response)
    – \(X_i\) = Sepal Length (predictor)
    – \(\epsilon_i\) (errors)

Dataset

Goal is to predict petal length using sepal length.

##   Sepal.Length Petal.Length
## 1          5.1          1.4
## 2          4.9          1.4
## 3          4.7          1.3
## 4          4.6          1.5
## 5          5.0          1.4
## 6          5.4          1.7

Scatterplot: Visualizing the Relationship

3D Plot: Exploring Species Differences

Regression Assumptions

\[ \epsilon_i \sim N(0, \sigma^2) \quad \text{(QQ-plot)} \] \[ \text{Var}(\epsilon_i) = \sigma^2 \quad \forall \; i \]

Residual Plot

Conclusion

Key Findings:

  • Strong linear relationship (\(R^2\) = 0.76)
  • Species differences matter

R Code:

summary(lm(Petal.Length ~ Sepal.Length, data = iris))

Conclusion Cont.

## 
## Call:
## lm(formula = Petal.Length ~ Sepal.Length, data = iris)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.47747 -0.59072 -0.00668  0.60484  2.49512 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -7.10144    0.50666  -14.02   <2e-16 ***
## Sepal.Length  1.85843    0.08586   21.65   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8678 on 148 degrees of freedom
## Multiple R-squared:   0.76,  Adjusted R-squared:  0.7583 
## F-statistic: 468.6 on 1 and 148 DF,  p-value: < 2.2e-16