Scatterplot with Regression Line
## `geom_smooth()` using formula = 'y ~ x'
2024-03-21
## `geom_smooth()` using formula = 'y ~ x'
Simple linear regression is a statistical method used to model the relationship between two variables. It assumes that there is a linear relationship between the independent variable \(X\) and the dependent variable \(Y\).
The simple linear regression model equation is given by:
\[Y = \beta_0 + \beta_1 X + \varepsilon\]
Where: - \(Y\) is the dependent variable - \(X\) is the independent variable - \(\beta_0\) is the intercept - \(\beta_1\) is the slope - \(\varepsilon\) is the error term
Let’s consider an example where we have a dataset with two variables \(X\) and \(Y\). We want to model the relationship between them using simple linear regression.
## ## Call: ## lm(formula = y ~ x) ## ## Residuals: ## Min 1Q Median 3Q Max ## -10.0560 -3.1111 -0.4097 3.3295 10.7983 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 0.34508 1.34274 0.257 0.798 ## x 1.99321 0.04583 43.494 <2e-16 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 4.676 on 48 degrees of freedom ## Multiple R-squared: 0.9753, Adjusted R-squared: 0.9747 ## F-statistic: 1892 on 1 and 48 DF, p-value: < 2.2e-16
The intercept (\(\beta_0\)) represents the estimated mean value of \(Y\) when \(X = 0\). In this example, the intercept is approximately \(0.688\).
The slope (\(\beta_1\)) represents the change in \(Y\) for a one-unit increase in \(X\). In this example, the slope is approximately \(1.98\). This means that for every one-unit increase in \(X\), the estimated mean value of \(Y\) increases by \(1.98\).
Simple linear regression is a useful tool for understanding and modeling the relationship between two variables. By fitting a linear regression model, we can estimate the effect of changes in the independent variable on the dependent variable.
This statistical technique serves as a foundation for more advanced regression analyses and has applications in various fields such as economics, engineering, social sciences, and more.