- Objective: Understanding the relationship between two variables.
- Variables Defined:
- X: Predictor Variable.
- Y: Response Variable.
- Core Concept: We use \(X\) to predict \(Y\) assuming that the relationship can be represented by a straight line.
2026-09-13
The Simple Linear Regression model is:
\[Y = \beta_0 + \beta_1X + \epsilon\] Where:
The scatterplot shows the relationship between:
X: speed(mph) Y: Stopping distance (ft)
Each point represents one observation.
The plot helps us to see whether there is a relationship between speed and stopping distance.
The regression line shows the overall trend in the data:
## `geom_smooth()` using formula = 'y ~ x'
Final sample prediction line equation:
\[\hat{Y}_i = -17.579 + 3.932 X_i\] Where:
## speed dist ## 1 4 2 ## 2 4 10 ## 3 7 4 ## 4 7 22 ## 5 8 16 ## 6 9 10
p = plot_ly(mtcars, x=~wt, y=~mpg, type="scatter", mode="markers",
color = ~disp, width=600, height=350)
p
Takeaway: