Simple linear regression is a statistical method that allows us to summarize and study relationships between two continuous (quantitative) variables.
2024-06-02
Simple linear regression is a statistical method that allows us to summarize and study relationships between two continuous (quantitative) variables.
The equation of a simple linear regression line is:
\[ y = \beta_0 + \beta_1 x + \epsilon \]
where: - \(y\) is the dependent variable, - \(x\) is the independent variable, - \(\beta_0\) is the y-intercept, - \(\beta_1\) is the slope, - \(\epsilon\) is the error term.
We will use a dataset that includes heights and weights.
## ## Call: ## lm(formula = weights ~ heights, data = sample_data) ## ## Residuals: ## 1 2 3 4 5 ## -1.5319 2.8485 -0.9383 -4.0104 3.6322 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) -10.5983 21.2310 -0.499 0.6520 ## heights 0.4525 0.1212 3.732 0.0335 * ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 3.68 on 3 degrees of freedom ## Multiple R-squared: 0.8228, Adjusted R-squared: 0.7637 ## F-statistic: 13.93 on 1 and 3 DF, p-value: 0.03353
## `geom_smooth()` using formula = 'y ~ x'
The linear regression model can be mathematically represented as:
\[ \hat{y} = \hat{\beta_0} + \hat{\beta_1} x \]
where \(\hat{y}\) is the predicted value of \(y\), \(\hat{\beta_0}\) and \(\hat{\beta_1}\) are the estimated coefficients.
## ## Call: ## lm(formula = weights ~ heights, data = sample_data) ## ## Residuals: ## 1 2 3 4 5 ## -1.5319 2.8485 -0.9383 -4.0104 3.6322 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) -10.5983 21.2310 -0.499 0.6520 ## heights 0.4525 0.1212 3.732 0.0335 * ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 3.68 on 3 degrees of freedom ## Multiple R-squared: 0.8228, Adjusted R-squared: 0.7637 ## F-statistic: 13.93 on 1 and 3 DF, p-value: 0.03353