Regression Analysis and Simple Linear Regression
โํ๋ฅ ๊ณผ ํต๊ณ(MATH230)โ ์์ ์์ ๋ฐฐ์ด ๊ฒ๊ณผ ๊ณต๋ถํ ๊ฒ์ ์ ๋ฆฌํ ํฌ์คํธ์ ๋๋ค. ์ ์ฒด ํฌ์คํธ๋ Probability and Statistics์์ ํ์ธํ์ค ์ ์์ต๋๋ค ๐ฒ
์ด๋ฒ ํฌ์คํธ์์ <Regression Analysis>์ ์ปจ์ ์ ์ดํด๋ด ๋๋ค. <Regression>์ด deterministic relationship๊ณผ ์ด๋ป๊ฒ ๋ค๋ฅธ์ง, ๋๋ค์ฑ์ ํฌํจํ๊ธฐ ์ํด ์ด๋ค ๊ฐ์ ์ ํ๋์ง๋ฅผ ์ค์ ์ ์ผ๋ก ์ดํด๋ด ์๋ค.
Introduction to Regression
์ฐ๋ฆฌ๊ฐ $n$๋ฒ์ ์คํ์ ํตํด $n$๊ฐ์ ๋ฐ์ดํฐ $\{ (x_i, y_i) \}_n$๋ฅผ ์ป์๋ค๊ณ ํ์. ์ด ๋ฐ์ดํฐ๋ฅผ ์ ์ฌํ ์ดํด๋ณด๋โฆ $n$๊ฐ ๋ฐ์ดํฐ์์ ์๋์ ๊ฐ์ ๊ด๊ณ๋ฅผ ๋ฐ๊ฒฌํ๋ค.
\[Y = \beta_0 + \beta_1 x\]์์ฐ! ์ด ๊ด๊ณ๊ฐ ์ฌ์ค์ด๋ผ๋ฉด, ์ฐ๋ฆฌ๋ $x$ ๊ฐ๋ง์ผ๋ก ์ ํํ $y$ ๊ฐ์ ์ป์ ์ ์๋ค! ์ด๋ฐ ํํ์ ๊ด๊ณ์์ deterministic relationship์ด๋ผ๊ณ ํ๋ค. ์ด๋ฐ ๊ด๊ณ๋ ๋๋ค์ฑ์ด๋ ํ๋ฅ ์ ์ด์ง ์์ ์ํฉ์์๋ง ์ ํจํ ๊ฒ์ด๋ค.
๊ทธ๋ฌ๋ ์ด๋ฐ deterministic ์ผ์ด์ค๋ ํ์น ์๋ค. ์ฐ๋ฆฌ๊ฐ ๋ชจ๋ ์คํ์ ํต์ ํ ์ ์๊ณ , ๋ชจ๋ dependent variable $x_i$๋ฅผ ๋ถ๋ณํ ์ ์์ง ์๊ธฐ ๋๋ฌธ์ ์ฐ๋ฆฌ๊ฐ ์ป์ ๋ฐ์ดํฐ $\{ (x_i, y_i) \}_n$์๋ probabilisticํ ์ฑ์ง์ด ์กด์ฌํ ์ ๋ฐ์ ์๋ค. ๊ทธ๋ฆฌ๊ณ ๊ทธ๋ฌ๋ ํธ์ด generalization ๊ด์ ์์ ๋ ์์ ํ๋ค!
์์ผ๋ก ๊ณต๋ถํ ์ปจ์ ์ ํ ๋ฌธ์ฅ์ผ๋ก ์์ฝํ๋ฉด ์๋์ ๊ฐ๋ค.
Model the relationship btw $x$ and $y$
by finding a function $y = f(x)$
that is a close fit to the given data $\{ (x_i, y_i) \}_n$
์์ ๊ฐ์ ๋ชจ๋ธ๋ง์ <Regression Analysis>๋ผ๊ณ ํ๋ค.
Multiple, Simple, Linear
๋ง์ฝ <Regression Analysis>์์ ๋ ์ด์์ dependent variable์ ๋ค๋ฃจ๋ $y = f(x_1, x_2)$๋ผ๋ฉด, <multiple regression>์ ๋ํ ๋ถ์์ด๋ค. ๋ฐ๋๋ก ํ๋์ dependent variable $y = f(x_1)$๋ผ๋ฉด, <simple regression>์ ๋ํ ๋ถ์์ด๋ค.
๋, <Regression Analysis>์์ ๊ด๊ณ๋ฅผ Linear๋ก ๊ฐ์ ํ๋ค๋ฉด: $y = \beta_0 + \beta_1 x_1 + \beta_2 x_2$ ๋๋ $y = \beta_0 + \beta_1 x_1$๋ผ๋ฉด, <linear regression>์ ๋ํ ๋ถ์์ด๋ค.
์ฐ๋ฆฌ๋ ํต๊ณ์ ์ ๋ฌธ ์์ ์ ๋ฃ๊ณ ์๊ธฐ์ ๊ฐ์ฅ ์ฌ์ด <simple linear regression; SLR>์ ๋ํด ๊ณต๋ถํ ์์ ์ด๋ค.
Simple Linear Regression
์ ๋ฌธ๋จ์์ <Regression Analysis>๊ฐ ๋ ๋ณ์์ non-deterministic relation์ ๋ชจ๋ธ๋งํ๋ ๊ณผ์ ์ด๋ผ๊ณ ์ ์ํ๋ค. ์ด๋ฐ non-deterministic ๊ฒฝ์ฐ๋ฅผ โ<random component>๊ฐ ์๋คโ๋ผ๊ณ ํํํ๊ธฐ๋ ํ๋ค.
๋์ผํ $x$ ๊ฐ์ผ๋ก ์คํ์ ํ๋๋ผ๋ ์ฌ๋ฌ ์์ธ์ ์ํด $y$์ ๋ณํ ์ ์๋ค. ๋ฐ๋ผ์ response $y$์ ๋๋ค์ฑ์ด ์๋ค๊ณ ๋ณด๋ ๊ฒ์ด ์ ์ ํ๋ค. ๋ง์ฝ $y$๋ฅผ $Y$๋ก ํํํ๋ค๋ฉด, random variable๋ก์จ ํํํ ๊ฒ์ด๋ค. $y_i$๋ ๋ฐ์ดํฐ์ $\{ (x_i, y_i) \}_n$์ ํ ๊ฐ์ผ๋ก์จ ํํํ ๊ฒ์ด๋ค. ๋์ ๊ตฌ๋ถํด์ผ ํ๋ค.
์, ์ด์ <Regression Analysis>๋ฅผ ์ํํ๊ธฐ ์ํ Model์ ์ ์ํด๋ณด์. ์ฐ๋ฆฌ๋ Simple Linear Regression Model์ ์ ์ํ ๊ฒ์ด๋ค.
\[Y = \beta_0 + \beta_1 x + \epsilon\]$\beta_0$์ $\beta_1$๋ ์ต์ํ๋ฏ regression parameter์ด๋ค. ๊ฐ๊ฐ intercept์ slope์ ์ญํ ์ด๋ค.
$\epsilon$์ random variable์ด๋ค. ์คํ๊ณผ ๋ฐ์ดํฐ์ ์ ๋๋ค์ฑ, ๋ถํ์ค์ฑ์ ํํํ๋ ์ญํ ์ด๋ค. ์ด๋, random variable $\epsilon$์ ํ๊ท ๊ณผ ๋ถ์ฐ์ด $E(\epsilon) = 0$, $\text{Var}(\epsilon) = \sigma^2$์ผ๋ก ์ ์๋๋ค.
๋ด์ฉ์ ๋ ์งํํ๊ธฐ ์ ์ ๋ช๊ฐ์ง ์ฌ์ค๋ค์ ์ ๋ฆฌํ๊ณ ๊ฐ์.
- $x$๋ not random์ด๊ณ , value์ผ ๋ฟ์ด๋ค.
- $Y$๋ random variable์ด๋ค. ์๋ํ๋ฉด, $\epsilon$์ด random variable์ด๊ธฐ ๋๋ฌธ์ด๋ค.
Random Error
Definition. Simple Linear Regression Model
For $n$ sample points $(x_1, y_1), \dots, (x_n, y_n)$,
\[y_i = \beta_0 + \beta_1 x_i + \epsilon_i\]where $\epsilon_i$ are independent random variables with mean 0 and variance $\sigma^2$.
์์ ๊ฐ์ Regression Modeling์ <Simple Linear Regression Model>์ด๋ผ๊ณ ํ๋ค!!
$y_i$๊ฐ $x_i$์ dependent ํ๋ค๊ณ ๊ฐ์ ํ๋ค. ์ด๋, ๋์ random factor์ ์ํด ์ํฅ์ ๋ฐ๋๋ค. ์ด random factor๋ $\epsilon_i$๋ก ํํ๋๋ค.
Remark.
1. $x_i$ is called the <predictor> or <regressor>, and we assume $x_i$s are non-random.
2. $y_i$ is called the <response>, and it is a random variable with $E[y_i] = \beta_0 + \beta_1 x_i$ and $\text{Var}(y_i) = \sigma^2$.
3. $\epsilon_i$ is called an <error>, and $\sigma^2$ is called the <error variance>. ๐ฅ
์ฌ๊ธฐ์ ์ฐ๋ฆฌ๋ ์ด๋ฐ ์๋ฌธ์ด ๋ ๋ค!
Q. ์ฐ๋ฆฌ๋ ์ฃผ์ด์ง data points์ ๋ง๋ line $y = \beta_0 + \beta_1 x$๋ฅผ ์ฐพ๊ณ ์ถ๋ค. ์ด๋, $\beta_0$, $\beta_1$๋ก ๊ฐ๋ฅํ ๊ฐ์ด ์์ฃผ ๋ง์ ํ ๋ฐ, ์ด๋ค $\beta_0$, $\beta_1$ ๊ฐ์ด ์ข๋ค๊ณ ๋งํ ์ ์์๊น??
์ฐ๋ฆฌ๋ ์ด โLinear Regressionโ์ ์ข์ ์ ๋๋ฅผ ํํํ๊ธฐ ์ํด <residual>๊ณผ ๊ทธ๋ค์ ํฉ์ธ <residual sum>์ ์ ์ํ๋ค.
Definition. residual
For a line $\hat{y} = b_0 + b_1 x$, the <residual> $e_i$ of a data point $(x_i, y_i)$ is defined to be
\[e_i := y_i - \hat{y}_i\]์ฐ๋ฆฌ๋ ์ด residual์ ์ต์ํํ๋ $b_0$, $b_1$์ ๊ฐ์ ์ฐพ๊ณ ์ถ๋ค!! ์ด๋, ์ฐ๋ ๋ฐฉ๋ฒ์ด ๋ฐ๋ก <Least Square Method>๋ค!
Least Square Method
<LS Method>๋ ์ต์ ์ $\beta_0$, $\beta_1$์ ์ป๊ธฐ ์ํด ์๋์ <SSE; Sum of Squares of the Errors>๋ฅผ ์ต์ํํ๋ $b_0$, $b_1$๋ฅผ ์ฐพ๊ณ ์ ํ๋ค!
\[\text{SSE} = \sum_{i=1}^n e_i^2 = \sum_{i=1}^n (y_i - \hat{y}_i)^2 = \sum_{i=1}^n (y_i - b_0 - b_1 x_i)^2\]์์ ์์ ์ต์ ํํ๋ ๊ฑด ์ ๋ง ๊ฐ๋จํ๋ค. ๊ทธ๋ฅ SSE๋ฅผ $b_0$, $b_1$์ ๋ํด ํธ๋ฏธ๋ถ ํด์ 0์ด ๋๋ $b_0$, $b_1$์ ๊ฐ์ ์ฐพ์ผ๋ฉด ๋๋ค.
Let $f(b_0, b_1) = \text{SSE}$, then
\[\frac{\partial f}{\partial b_0} = - 2 \sum_{i=1}^n (y_i - b_0 - b_1 x_i) = 0\] \[\frac{\partial f}{\partial b_1} = - 2 \sum_{i=1}^n (y_i - b_0 - b_1 x_i) x_i = 0\]๋จผ์ , $b_0$์ ๋ํ ์๋ถํฐ ์ ๋ฆฌํด๋ณด์.
์๋ณ์ $n$์ผ๋ก ๋๋๋ฉด,
\[\bar{y} = b_0 + b_1 \bar{x}\]๋ฐ๋ผ์,
\[b_0 = \bar{y} - b_1 \bar{x}\]$\blacksquare$
์ด๋ฒ์๋ $b_1$์ ๋ํ ์์ ์ ๋ฆฌํด๋ณด์.
์์ ์์์ ์๊น ๊ตฌํ $b_0$๋ฅผ ๋์ ํด์ฃผ์!
\[\sum_{i=1}^n (y_i - \bar{y} + b_1 \bar{x} - b_1 x_i) x_i = 0\] \[\sum_{i=1}^n (y_i - \bar{y} + b_1 (\bar{x} - x_i)) x_i = 0\] \[\sum_{i=1}^n (y_i - \bar{y})x_i + \sum_{i=1}^n b_1 (\bar{x} - x_i) x_i= 0\] \[b_1 \cdot \sum_{i=1}^n (\bar{x} - x_i) x_i= - \sum_{i=1}^n (y_i - \bar{y})x_i\] \[b_1 = - \frac{\sum (y_i - \bar{y})x_i}{\sum (\bar{x} - x_i) x_i}\] \[b_1 = \frac{\sum (y_i - \bar{y})x_i}{\sum (x_i - \bar{x}) x_i}\]๋๋ ์์ ์์ ์ฝ๊ฐ ๋ณํํด ์๋์ ๊ฐ์ด ์ฐ๊ธฐ๋ ํ๋ค.
\[b_1 = \frac{\sum (y_i - \bar{y})(x_i - \bar{x})}{\sum (x_i - \bar{x}) (x_i - \bar{x})}\]์ด๊ฒ ๊ฐ๋ฅํ ๊ฒ์ $b_1$์ ๋ํ ์ฒซ๋ฒ์งธ ์์์ $\sum (y_i - \bar{y}) \bar{x}$, $\sum (x_i - \bar{x}) \bar{x}$๋ฅผ ๋นผ์ค ๋, $\sum (y_i - \bar{y}) = \sum (x_i - \bar{x}) = 0$์ด๊ธฐ ๋๋ฌธ์ด๋ค!!
๋ค์ ์ ์ ๋ฆฌํ๋ฉด ์๋์ ๊ฐ๋ค.
In <LS method>, the regression coefficients of $\beta_0$ and $\beta_1$ are estimated by
\[b_1 = \frac{\sum (y_i - \bar{y})(x_i - \bar{x})}{\sum (x_i - \bar{x}) (x_i - \bar{x})} = \frac{S_{xy}}{S_{xx}}\] \[b_0 = \bar{y} - b_1 \bar{x}\]์ฌ๊ธฐ๊น์ง ์งํํ๋ฉด, ์ด์ ์๋์ ๊ฐ์ ์๋ฌธ์ด ๋ ๋ค.
Q. Are $b_1$ and $b_0$ good estimators? ๐ค
A. Yes!!
Theorem.
$b_1$ and $b_0$ are unbiased for $\beta_1$ and $\beta_0$ respectively.
\[E[b_1] = \beta_1 \quad \text{and} \quad E[b_0] = \beta_0\]proof.
์์์ ์์ ๊ฐ์ด $E[y_i]$๊ฐ ๊ฐ๋ฅํ ์ด์ ๋ $x_i$๋ Random Variable์ด ์๋๊ธฐ ๋๋ฌธ์ด๋ค!!
\[\begin{aligned} &= \frac{\sum_{i=1}^n (x_i - \bar{x})E[y_i]}{S_{xx}} \\ &= \frac{\sum_{i=1}^n (x_i - \bar{x})(\beta_0 + \beta_1 x_i )}{S_{xx}} \\ &= \frac{\cancel{\sum_{i=1}^n (x_i - \bar{x})\beta_0} + \sum_{i=1}^n (x_i - \bar{x}) \beta_1 x_i }{S_{xx}} \\ &= \frac{\sum_{i=1}^n (x_i - \bar{x}) \beta_1 x_i }{S_{xx}} \\ &= \beta_1 \cdot \frac{\sum_{i=1}^n (x_i - \bar{x}) x_i }{S_{xx}} \\ &= \beta_1 \cdot \cancelto{1}{\frac{\sum_{i=1}^n (x_i - \bar{x}) (x_i - \bar{x})}{S_{xx}}} \\ &= \beta_1 \end{aligned}\]$\blacksquare$
proof.
$\blacksquare$
Remark.
1. The derivation of LSEs does not depend on the distribution of $\epsilon_i$.
2. If $\epsilon_i$s are iid $N(0, \sigma^2)$, then $b_0$ and $b_1$ are the MLEs for $\beta_0$ and $\beta_1$.
3. $\sum e_i = 0$
4. $\sum x_i e_i = 0$
(Homework ๐)
์์ ๋ช ์ [3, 4]๋ฅผ ํ์ฉํด ์๋์ ๋ฑ์์ ์ป์ ์ ์๋ค.
\[\sum_{i=1}^n (y_i - \bar{y})^2 = \sum_{i=1}^n (\hat{y}_i - \bar{y})^2 + \sum_{i=1}^n (y_i - \hat{y}_i)^2\]์ด๋, ๊ฐ ํ ์ ์๋์ ๊ฐ๋ค.
\[\text{SST} = \text{SSR} + \text{SSE}\]- SST: Total Sum of Squares
- SSR: the Regression Sum of Squares
- SSE: the Residual Sum of Squares
์ฆ๋ช ์ ๋ง์ฐฌ๊ฐ์ง๋ก (Homework ๐)
Definition. R-square; ๊ฒฐ์ ๊ณ์
be the โcoefficient of determination; ๊ฒฐ์ ๊ณ์โ.
- $R^2 = 1$ is equivalent to
- $\text{SSE} = 0$
- $\hat{y_i} = y_i$ for all inputs
- Regression model work very well!
- $R^2 = 0$ is equivalent to
- $\text{SSE} = \text{SST}$
- $\text{SSR} = 0$
- $\hat{y}_i = \bar{y}$ for all inputs
- Regression model outputs a constant.
Remark.
1. $0 \le R^2 \le 1$
2. $R^2$ represents the proportionate reduction of total variation in $Y$ associated with the use of the variable $X$.
(a) If $R^2=1$, then $SSE = 0$, this means $\hat{y}_i = y_i$.
All observations fall on the line.
(b) If $R^2 = 0$, then $\text{SSE} = \text{SST}$ or $\text{SSR} = 0$.
The fitted regression line is the constant, $\bar{y}$.
์ด์ด์ง๋ ํฌ์คํธ์์๋ <Simple Linear Regression>์ ์ฑ์ง์์ ์ด์ด์ ์ดํด๋ณผ ์์ ์ด๋ค. <Linear Regression>์์ ๊ณ์ $b_0$, $b_1$์ ๋ถํฌ๋ฅผ ์ดํด๋ณด๊ณ ์ด๋ฅผ ํตํด ๊ฒ์ (Test)์ ์ํํ๋ค. ๋, Regression์ ํตํด ์ป์ Prediction ๊ฒฐ๊ณผ๋ฅผ ๋ฐํ์ผ๋ก <Prediction Inference>๋ฅผ ์ํํ๋ค!
๐ Test on Regression