A statistical method modeling the relationship between independent and dependent variables
Equation:
\[ Y = \beta_0 + \beta_1 X + \epsilon \]
2025-03-14
A statistical method modeling the relationship between independent and dependent variables
Equation:
\[ Y = \beta_0 + \beta_1 X + \epsilon \]
Equation, again:
\[ Y = \beta_0 + \beta_1 X + \epsilon \]
\(\beta_0\) is the intercept
\(\beta_1\) is the slope
\(\epsilon\) is the error term
## x y ## 1 5.037492 8.794434 ## 2 4.631495 9.366618 ## 3 2.257339 4.346065 ## 4 3.801665 8.414071 ## 5 5.589090 9.750422 ## 6 5.779589 11.232558
library(ggplot2)
ggplot(data, aes(x=x, y=y)) +
geom_point(color="yellow") +
geom_smooth(method="lm", color="pink") +
ggtitle("Linear Regression: Scatter Plot with Line") +
theme_minimal()
model <- lm(y ~ x, data=data)
data$residuals <- residuals(model)
ggplot(data, aes(x=x, y=residuals)) +
geom_point(color="purple") +
geom_hline(yintercept=0, linetype="dashed") +
ggtitle("Residual Plot") +
theme_minimal()
library(plotly) plot_ly(data, x=~x, y=~y, z=~residuals, type="scatter3d", mode="markers") %>% layout(title="3D Plot")
Many fields use linear regression!
Finance- to predict stock prices
Engineering- to model strength of materials under varying conditions
Biology- population growth for example
Etc.
Simple Linear Regression is useful for a plethora of fields such as engineering, biology, and finance
Regressions are useful for predictions
Thank you!