Simple Linear Regression

Definition

Equation

\[ y = \beta_0 + \beta_1 x + \epsilon \]

Least Squares

\[ \sum (y_i - \hat{y_i})^2 \]

mtcars Example

ggplot scatterplot

Here is a ggplot showing that as weight goes up, mpg goes down

ggplot(mtcars, aes(x = wt, y = mpg))+geom_point()

ggplot with regression line

## `geom_smooth()` using formula = 'y ~ x'

Plotly: Interactive model of linear regression