- According to Newcastle University, a linear regression aims to find a linear relationship that describes the correlation between an independent and possibly dependent variable.
- it can also be represented by the following formula: y=+ x
2024-10-16
## Warning: package 'plotly' was built under R version 4.4.1
## Loading required package: ggplot2
## ## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2': ## ## last_plot
## The following object is masked from 'package:stats': ## ## filter
## The following object is masked from 'package:graphics': ## ## layout
library(ggplot2) data(mtcars) ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + geom_smooth(method="lm", col="blue") + labs(title="Linear Regression: MPG vs. Weight", x="Weight (1000 lbs)", y="Miles Per Gallon") + theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
\[ Y = \beta_0 + \beta_1 X + \epsilon \]
\[ \text{RSS} = \sum_{i=1}^{n} (Y_i - \hat{Y}_i)^2 \]
Where:
\[ \hat{Y}_i = \beta_0 + \beta_1 X_i \]