2024-06-05

Introduction to Simple Linear Regression

Simple Linear Regression is a statistical method that allows us to summarize and study relationships between two continuous (quantitative) variables.

Mathematical Formulation

The simple linear regression equation is given by: \[ 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 of the regression line - \(\epsilon\) is the error term

Example Dataset

Let’s consider an example dataset with variables X (independent) and Y (dependent).

##          X        Y
## 1 44.39524 21.64559
## 2 47.69823 28.13353
## 3 65.58708 34.56008
## 4 50.70508 26.61483
## 5 51.29288 23.88835
## 6 67.15065 36.35019

## 
## Call:
## lm(formula = Y ~ X, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.5367 -3.4175 -0.4375  2.9032 16.4520 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.79778    2.76324   1.374    0.172    
## X            0.47376    0.05344   8.865  3.5e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.854 on 98 degrees of freedom
## Multiple R-squared:  0.4451, Adjusted R-squared:  0.4394 
## F-statistic:  78.6 on 1 and 98 DF,  p-value: 3.497e-14

## 
## 다음의 패키지를 부착합니다: '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
## 
## Call:
## lm(formula = Y ~ X, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.5367 -3.4175 -0.4375  2.9032 16.4520 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.79778    2.76324   1.374    0.172    
## X            0.47376    0.05344   8.865  3.5e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.854 on 98 degrees of freedom
## Multiple R-squared:  0.4451, Adjusted R-squared:  0.4394 
## F-statistic:  78.6 on 1 and 98 DF,  p-value: 3.497e-14