class: center, middle, inverse, title-slide .title[ # STATS101 ] .subtitle[ ## Probabilities, Distribution, and Hypotheses ] .author[ ### Sanghoon Park ] .date[ ### University of South Carolina ] --- ## Pop-up quizes! -- <img src="fig/w4_fig1.png" width="2383" style="display: block; margin: auto;" /> --- ## Pop-up quizes! 각 변수의 유형을 구분해보자. <table class=" lightable-material lightable-striped lightable-hover" style='font-family: "Source Sans Pro", helvetica, sans-serif; margin-left: auto; margin-right: auto;'> <thead> <tr> <th style="text-align:left;"> gender </th> <th style="text-align:right;"> sleep </th> <th style="text-align:left;"> school </th> <th style="text-align:right;"> countries </th> <th style="text-align:right;"> bodytemp </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> male </td> <td style="text-align:right;"> 5.0 </td> <td style="text-align:left;"> Elem </td> <td style="text-align:right;"> 13 </td> <td style="text-align:right;"> 36.4 </td> </tr> <tr> <td style="text-align:left;"> female </td> <td style="text-align:right;"> 7.0 </td> <td style="text-align:left;"> Elem </td> <td style="text-align:right;"> 7 </td> <td style="text-align:right;"> 37.4 </td> </tr> <tr> <td style="text-align:left;"> female </td> <td style="text-align:right;"> 5.5 </td> <td style="text-align:left;"> High </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 37.1 </td> </tr> <tr> <td style="text-align:left;"> female </td> <td style="text-align:right;"> 7.0 </td> <td style="text-align:left;"> High </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 36.5 </td> </tr> <tr> <td style="text-align:left;"> female </td> <td style="text-align:right;"> 3.0 </td> <td style="text-align:left;"> Col </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 37.4 </td> </tr> <tr> <td style="text-align:left;"> female </td> <td style="text-align:right;"> 3.0 </td> <td style="text-align:left;"> Col </td> <td style="text-align:right;"> 9 </td> <td style="text-align:right;"> 36.4 </td> </tr> </tbody> </table> --- ## Pop-up quizes! 각 변수의 유형을 구분해보자. + `gender`: 명목형-이항형 + `sleep`: 연속형-등간형 + `school`: 명목형-분류형(혹은 순위형) + `countries`: 명목형-분류형 + `bodytemp`: 연속형-비율형 --- ## Probabilities, Distribution, and Hypotheses + 간단한 확률을 **R**을 이용해 증명 -- + 다양한 분포들의 차이를 이해 -- + 정규분포(normal distribution) + `\(t\)` 분포(t-distribution) + 이항분포(binomial distribution) + 포아송분포(Poisson distribution) -- + 가설(Hypotheses)에 대한 소개 --- ## Probability into R 확률모델: 우리가 어떠한 이론적 기대-모델을 가지고 있을 때, 어떠한 데이터를 관측할 확률에 대해 알려줌. -- + 동전 던지기 -- + 앞면을 관측할 확률을 대략 0.5일 것이라고 기대 + 얻을 수 있는 가능성이 앞면/뒷면만 존재할 때, 이 동전에 문제가 없다면 앞면과 뒷면이 나올 확률이 같을 것이라는 일종의 이론적 기대-모델을 가지고 있기 때문. -- + 정확히는 동전을 반복해서 던졌을 때, 데이터가 어떻게 나타날 것(동전 앞/뒷면이 반반)이라는 이론을 가지고 있다는 것 --- ## Probability into R 확률모델: 우리가 어떠한 이론적 기대-모델을 가지고 있을 때, 어떠한 데이터를 관측할 확률에 대해 알려줌. $$ \Pr(Y|M) = \Pr(데이터|모델) $$ -- 즉, 확률이란 무한정 반복되는 무작위한 과정(random process)에서 우리가 어떠한 결과를 관측할 횟수의 비율(proportion of times) --- ## Probability into R 무작위한 과정(random process) -- + 무슨 일이 일어날 것이라는 건 알지만, 그 결과과 어떤 것인지는 알지 못하는 상태 -- + 예를 들어, 동전 던지기, 주사위 굴리기 등은 우리가 앞면/뒷면 혹은 주사위의 어느 눈이라는 결과를 얻을 것이라는 건 알지만, 결과가 앞면일지 뒷면일지 혹은 1부터 6 사이의 어떤 값일지는 확신하지 못한다. --- ## Probability into R ### Types of probabilities 사건 `\(A\)`와 사건 `\(B\)` .pull-left[ #### Joint probability: 결합확률 + 두 사건이 동시에 일어날 확률 + `\(\Pr(A\cap B)\)` 또는 `\(\Pr(A \text{ and } B)\)` ] .pull-right[ #### Marginal probability: 한계확률 + 전체 중에서 특정 사건이 발생할 확률 + `\(\Pr(A)\)` 또는 `\(\Pr(B)\)` ] --- ## Probability into R ### Types of probabilities 사건 `\(A\)`와 사건 `\(B\)` #### Conditional probability: 조건부확률 + 한계확률 대비 결합확률의 비율 + `\(\Pr(A|B) = \Pr(A\cap B)/\Pr(B)\)` --- ## Marginal probability and joint probability .pull-left[ .center[Table: 한계확률과 결합확률 (1)] | 구분 | `\(A_{\text{Fight}}\)` | `\(A_{\text{Comply}}\)` | 총합 | |--------------------|:------------------:|:-------------------:|:------:| | `\(B_{\text{Fight}}\)` | 0.3 | 0.2 | 0.5 | | `\(B_{\text{Comply}}\)`| 0.1 | 0.4 | 0.5 | | 총합 | 0.4 | 0.6 | 1 | + `A`와 `B`라는 국가는 서로 갈등 중 ] .pull-right[ `A`가 싸우기로 결정할 확률은? `A`가 상대방의 요구에 순응할 확률은? `B`가 싸우기로 결정할 확률은? `B`가 상대방의 요구에 순응할 확률은? `A`와 `B`가 모두 싸우기로 결정할 확률은? `A`와 `B`가 모두 상대방에게 순응할 확률은? ] --- ## Marginal probability and joint probability .pull-left[ .center[Table: 한계확률과 결합확률 (1)] | 구분 | `\(A_{\text{Fight}}\)` | `\(A_{\text{Comply}}\)` | 총합 | |--------------------|:------------------:|:-------------------:|:------:| | `\(B_{\text{Fight}}\)` | 0.3 | 0.2 | 0.5 | | `\(B_{\text{Comply}}\)`| 0.1 | 0.4 | 0.5 | | 총합 | 0.4 | 0.6 | 1 | + `A`와 `B`라는 국가는 서로 갈등 중 ] .pull-right[ `\(\Pr(A_\text{Fight}) = 0.4\)` `\(\Pr(A_\text{Comply}) = 0.6\)` `\(\Pr(B_\text{Fight}) = 0.5\)` `\(\Pr(B_\text{Comply}) = 0.5\)` `\(\Pr(A_\text{Fight}\cap B_\text{Fight}) = 0.3\)` `\(\Pr(A_\text{Comply}\cap B_\text{Comply}) = 0.4\)` ] --- ## Marginal probability and joint probability .pull-left[ .center[Table: 한계확률과 결합확률 (2)] | 구분 | A | B | 총합 | |-------------------|:------------------:|:-------------------:|:------:| | 남성 | 40 | 60 | 100 | | 여성 | 65 | 35 | 100 | | 총합 | 105 | 95 | 200 | 유권자들에게게 두 가지 질문을 던졌다. + `A`라는 후보에게 투표했는지 혹은 `B`라는 후보에게 투표했는지 + 응답자가 남성인지 혹은 여성인지 ] .pull-right[ 응답자가 여성일 확률은? 응답자가 남성일 확률은? 여성 중에서 `A` 후보에게 투표했을 조건부 확률은? 응답자가 여성이면서 `A` 후보에게 투표했을 확률은? ] --- ## Marginal probability and joint probability .pull-left[ .center[Table: 한계확률과 결합확률 (2)] | 구분 | A | B | 총합 | |-------------------|:------------------:|:-------------------:|:------:| | 남성 | 40 | 60 | 100 | | 여성 | 65 | 35 | 100 | | 총합 | 105 | 95 | 200 | 유권자들에게게 두 가지 질문을 던졌다. + `A`라는 후보에게 투표했는지 혹은 `B`라는 후보에게 투표했는지 + 응답자가 남성인지 혹은 여성인지 ] .pull-right[ `\(\Pr(여성) = 100/200 = 0.5\)` `\(\Pr(남성) = 100/200 = 0.5\)` `\(\Pr(A후보|여성) = 65/100 = 0.65\)` `\(\Pr(A후보, 여성) =\\ \Pr(A후보) \text{ AND } \Pr(여성)\\ = 65/200 = 0.325\)` ] --- ## Marginal probability and joint probability .pull-left[ .center[Table: 한계확률과 결합확률 (2)] | 구분 | A | B | 총합 | |-------------------|:------------------:|:-------------------:|:------:| | 남성 | 40 | 60 | 100 | | 여성 | 65 | 35 | 100 | | 총합 | 105 | 95 | 200 | 유권자들에게게 두 가지 질문을 던졌다. + `A`라는 후보에게 투표했는지 혹은 `B`라는 후보에게 투표했는지 + 응답자가 남성인지 혹은 여성인지 ] .pull-right[ 조건부 확률은 한계확률에 대한 결합확률의 비율 + `\(\Pr(A|B) = \Pr(A, \;B)/\Pr(B)\)` + `\(\Pr(\text{A}|\text{female}) =\\ \Pr(\text{A}, \;\;\text{female})/\Pr(\text{female})\)` + `\(\Pr(\text{A}|\text{female})/\Pr(\text{female}) =\\ 0.325/0.5 = 0.65\)` ] --- ## Independence 만약 어떤 한 사건의 결과를 알고 있는 것이 다른 사건의 결과에 대해 어떠한 정보도 제공하지 못한다면, 우리는 두 사건의 관계를 **독립적(Independent)**이라고 한다. -- + 동전 던지기에서, 첫 번째로 던진 동전이 앞면이었다는 것은 두 번째 동전을 던졌을 경우에 어느 면이 위로 오게 될지에 대해 유용한 정보를 제공하지 않는다. -- + 첫 번째 동전 던지기와 두 번째 동전 던지기는 독립적인 사건 -- 반대로 한 사건의 결과가 다른 사건의 결과에 대해 유용한 정보를 제공할 때, 우리는 두 사건의 관계를 **종속적(Dependent)**이라고 한다. -- + 카드 게임에서 덱(deck)으로부터 꺼낸 첫 번째 카드가 에이스(Ace) 카드일 경우, 우리는 두 번째로 카드를 뽑았을 때 그것이 에이스 카드일지 아닐지에 대한 유용한 정보를 얻게 된다. -- + 첫 번째 카드 뽑기와 두 번째 카드 뽑기는 서로 종속적인 사건 --- ## Random variables 확률변수란 무작위로 발생하는 사건의 결과에 따라 갖는 값을 수량화한 것 -- + 대개 `\(X\)`와 같은 영어 대문자를 이용해 확률변수를 표기한다. + 확률변수가 갖는 값들은 대개 `\(x\)`와 같이 영어 소문자를 이용해 표기한다. -- + 예를 들어, `\(\Pr(X = x)\)`는 확률변수 `\(X\)`가 `\(x\)`라는 값을 가질 확률을 의미한다. -- 확률변수에는 두 가지 유형이 있다. -- + 이산형 확률변수(Discrete random variables) + 오직 정수형 값(integer values)만을 가지는 확률변수. -- + 연속형 확률변수(Continuous random variables) + 소수점을 포함한 실수값(real values)을 취하는 확률변수. --- ## Expectation 우리는 확률변수가 평균적으로 가지는 결과에 관심을 가진다. -- 확률변수의 평균적인 결과를 우리는 기대값(expected value)라고 한다. -- + 하지만 현실에서 우리는 모집단을 관측하거나 가질 수는 없다. -- + 따라서 모집단에 대해 우리가 기대하는 값(기대값)에 상응하는 것을 표본에서 찾고자 한다. -- 그 표본을 대표하는 값(평균적으로 가지는 결과)는? -- 평균(mean) -- + 그리고 이때 이 평균은 우리가 가질 수 있는 결과들에 대한 가중평균으로 나타난다. -- $$ \mu = E(X) = \sum^{k}_{i=1}x_i \Pr(X = x_i) $$ --- ## Expectation + 예를 들어, 주사위의 기대값을 생각해보자. + 주사위를 한 번 던질 때 각 눈이 나올 확률은 `\(\frac{1}{6}\)`이다. + 주사위가 가질 수 있는 값은 1~6이다. -- $$ `\begin{aligned} E(X=\text{die})&= 1\times\frac{1}{6} + 2\times\frac{1}{6} + 3\times\frac{1}{6} +4 \times\frac{1}{6} + 5\times\frac{1}{6} + 6\times\frac{1}{6}\\ &= 3.5 \end{aligned}` $$ --- ## Expected value of a discrete random variable 이산형 확률변수의 기대값은 어떻게 구할 수 있을까? -- 아래는 축구 경기에서 이길 확률의 분포를 시각적으로 나타낸 것이다. .panelset[ .panel[.panel-name[R-code] ```r # Probability distribution of winnings from the game library(tidyverse) discrete <- tibble(x = c(rep("0", 60), rep("1", 20), "2", "3", "4", rep("5", 10), "6", "7", "8", "9", rep("10", 3))) discrete %>% ggplot(aes(x = x)) + geom_bar(aes(y = (..count..)/sum(..count..))) + scale_y_continuous( breaks = c(seq(0, 0.6, 0.1)), labels = scales::percent) + scale_x_discrete(limits = c(unique(discrete$x))) + theme_bw() ``` ] .panel[.panel-name[Plot] <img src="D3S3_files/figure-html/unnamed-chunk-4-1.png" style="display: block; margin: auto;" /> ] .panel[.panel-name[Expected value] 게임에서 승리한 실제 관측 횟수와 각 승리 횟수의 확률을 고려한 가중평균 $$ `\begin{aligned} E(X)=&\:0\times0.6 + 1\times0.2 + 2\times0.01 + 3\times0.01 + 4\times0.01\\ &+ 5\times0.1 + 6\times0.01 + 7\times0.01 + 8\times0.01 + 9\times0.01\\ &+ 10\times 0.03\\ =&\:0 + 0.2 + 0.02 + 0.03 + 0.04 + 0.5 + 0.06\\ &+ 0.07 + 0.08 + 0.09 + 0.3\\ =&1.39 \end{aligned}` $$ ] ] --- ## Distribution into R 확률분포(Probability distribution) -- + 한 번의 시행에서 변수 `\(X\)`가 취할 수 있는 값에 대하여 `\(X\)`가 취할 수 있는 값, `\(x_1, x_2, x_3, \dots, x_n\)`에 대응하는 확률을 `\(p_1, p_2, p_3, \dots, p_n\)`이라고 할 때의 관계 -- + 쉽게 무작위로 어떠한 값을 가질 수 있는 변수 --- ## Distribution into R <img src="fig/stat101w2_Distribution.png" width="80%" style="display: block; margin: auto;" /> --- ## Distribution into R ### What do we want to know using distribution? -- + 특정한 값이 확률밀도함수(probability density function)에서 어디에 위치하는지 -- + 특정한 값이 누적분포함수(cumulative distribution function)에서 어디에 위치하는지 -- + 특정한 확률에 대응하는 분위의 값(quantile value)이 어떻게 되는지 -- + 특정한 분포로부터 값을 무작위로 추출(ramdom draw)했을 때의 결과 --- ## Probability density function; PDF 연속확률변수인 `\(X\)`의 확률을 결정하는 함수 -- + 연속형 변수, 0.01, 0.05, 1.23 과 같은 연속적인 값을 가지는 변수가 존재한다고 할 때, 우리가 어떤 값을 뽑을 확률은 그 확률함수에 대한 확률밀도함수로 결정된다. -- + 만약 `\(X\)`가 이산형 변수일 경우에는 `\(X\)`가 가질 수 있는 값, `\(x_1, x_2, x_3, \dots\)`에 대한 확률 `\(\Pr(X = x_1)\)`에 대응하는 관계를 보여주는 함수인 확률질량함수(probability mass function)이 동일한 역할을 수행 -- 즉, 변수 `\(X\)`가 연속형 변수이면 확률밀도함수, 이산형 변수이면 확률질량함수 --- ## Cumulative distribution fucntion; CDF 누적분포함수는 주어진 확률변수에서 어떤 특정한 값과 같거나 작은 값을 뽑을 확률을 보여주는 함수 -- + PDF와 같은 것을 다른 방식으로 보여준다고 이해할 수 있다. .panelset[ .panel[.panel-name[R-code] ```r x <- seq(-5, 5, length = 100) plot(x, dnorm(x), type = "l", col = "#DB3A2F", ylab = "Density", xlim = c(-5, 5), ylim = c(0, 1)) text(-3, 0.2, "PDF of Normal Distribution", col = "#DB3A2F") par(new=TRUE) plot(x, pnorm(x), type = "l", col = "#275D8E", ylab = "Density", xlim = c(-5, 5), ylim = c(0, 1)) text(2, 0.5, "CDF of Normal Distribution", col = "#275D8E") ``` ] .panel[.panel-name[Plot] <img src="D3S3_files/figure-html/unnamed-chunk-7-1.png" style="display: block; margin: auto;" /> ] ] --- ## How can R help us? R은 기본적으로 이러한 밀도(density), 분포(distribution), 분위(quantile), 그리고 확률값(random values)을 구할 수 있는 함수를 제공 -- + `dname`: 투입된 값 `x`가 확률밀도함수의 어디에 위치하는지(density) 계산 + `pname`: 투입된 값 `x`가 누적밀도함수의 어디에 위치하는지(distribution) 계산 + `qname`: 투입된 확률의 분위를 계산 + `rname`: 특정한 분포로부터 무작위로 뽑은 하나의 값 생성 --- ## How can R help us? R은 기본적으로 이러한 밀도(density), 분포(distribution), 분위(quantile), 그리고 확률값(random values)을 구할 수 있는 함수를 제공 -- .pull-left[ .panelset[ .panel[.panel-name[dnorm] ```r dnorm(x = 3, mean = 2, sd = 5) ``` ``` ## [1] 0.07820854 ``` ] .panel[.panel-name[pnorm] ```r pnorm(q = 3, mean = 2, sd = 5) ``` ``` ## [1] 0.5792597 ``` ] .panel[.panel-name[qnorm] ```r qnorm(p = 0.975, mean = 2, sd = 5) ``` ``` ## [1] 11.79982 ``` ] .panel[.panel-name[rnorm] ```r rnorm(n = 4, mean = 2, sd = 5) ``` ``` ## [1] 0.6837798 -5.1933065 -1.3652015 -2.6399251 ``` ] .panel[.panel-name[dbinom] ```r dbinom(x= 6, size = 10, prob = 0.75) ``` ``` ## [1] 0.145998 ``` ] .panel[.panel-name[pbinom] ```r pbinom(2, size=5, prob=.5, lower.tail=FALSE) ``` ``` ## [1] 0.5 ``` ] .panel[.panel-name[qbinom] ```r qbinom(.40, size=30, prob=.25) ``` ``` ## [1] 7 ``` ] .panel[.panel-name[dbinom] ```r rbinom(6, size=100, prob=.3) ``` ``` ## [1] 27 33 20 21 34 37 ``` ] ] ] .pull-right[ 위 함수들은 다른 분포들에도 동일하게 적용 <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Command </th> <th style="text-align:left;"> Distribution </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> *binom </td> <td style="text-align:left;"> Binomial </td> </tr> <tr> <td style="text-align:left;"> *t </td> <td style="text-align:left;"> t </td> </tr> <tr> <td style="text-align:left;"> *pois </td> <td style="text-align:left;"> Poisson </td> </tr> <tr> <td style="text-align:left;"> *f </td> <td style="text-align:left;"> F </td> </tr> <tr> <td style="text-align:left;"> *chisq </td> <td style="text-align:left;"> Chi-Squared </td> </tr> </tbody> </table> ] --- ## Normal distribution .left-column[ 표준정규분포 + 평균으로부터 1표준편차만큼 떨어진 거리에 전체 관측치의 약 68%에 해당하는 관측치들이 속해 있다. + 평균으로부터 2표준편차만큼 떨어진 거리는 95%, 3 표준편차 떨어진 거리에는 약 99%의 관측치들 위치 ] .right-column[ <div class="figure" style="text-align: center"> <img src="D3S3_files/figure-html/unnamed-chunk-17-1.png" alt="Normal distribution (Mean = 0, SD = 1)" /> <p class="caption">Normal distribution (Mean = 0, SD = 1)</p> </div> ] --- ## Normal distribution .left-column[ 표준정규분포 + 평균으로부터 1표준편차만큼 떨어진 거리에 전체 관측치의 약 68%에 해당하는 관측치들이 속해 있다. + 평균으로부터 2표준편차만큼 떨어진 거리는 95%, 3 표준편차 떨어진 거리에는 약 99%의 관측치들 위치 ] .right-column[ 평균이 50이고 표준편차가 10인 정규분포가 있다고 하자. + 만약 70이라는 값을 얻었을 때, 과연 이 분포로부터 70이라는 값을 얻을 확률은 어떻게 될까? ```r pnorm(70, mean = 50, sd = 10, lower.tail = TRUE) ``` ``` ## [1] 0.9772499 ``` ```r pnorm(70, mean = 50, sd = 10, lower.tail = FALSE) ``` ``` ## [1] 0.02275013 ``` ```r 1 - pnorm(70, mean = 50, sd = 10, lower.tail = TRUE) ``` ``` ## [1] 0.02275013 ``` + 70은 이 분포에서 약 하위 97.7% (=상위 2.3%) 값. ] --- ## Student's `\(t\)`: the `\(t\)`-distribution `\(t\)` 분포는 정규분포와 거의 비슷 + 소수의 사례로 구성된, 꼬리가 정규표준분포에 비해 약간 더 두꺼운 `\(t\)` 분포 + 특징 + 0을 중심으로 종 형태(bell-shaped)를 취하는 분포 + 표준편차는 1보다 조금 큰 분포; 따라서 표준정규분포보다 양 꼬리가 조금은 더 두꺼운 모습을 보임. + 표본규모가 커질수록 우리는 `\(t\)` 분포가 정규분포에 수렴할 것이라고 기대할 수 있음. + 평균에 대한 신뢰구간은 오차한계를 `\(t(se)\)`로 갖게 됨. --- ## Student's `\(t\)`: the `\(t\)`-distribution <img src="D3S3_files/figure-html/unnamed-chunk-19-1.png" style="display: block; margin: auto;" /> --- ## Binomial distribution n번의 시행에서 k번 성공할 확률을 보여주는 분포 -- + 한 번의 시도에서 성공할 경우 1, 실패할 경우 0으로 코딩된 변수가 있다고 하자. + 1을 뽑을 성공 사례의 총합을 100으로 나눔으로써, 전체 대비 성공의 확률을 구하는 것 + 정규분포에서와는 다르게 이항분포에서는 평균(mean)이 아니라 비율(proportion)에 초점 -- 승리확률이 25%인 경기가 있다고 할 때, 총 백번 경기에서 27번 승리할 확률은? -- ```r pbinom(27, size=100, prob=0.25, lower.tail = TRUE) ``` ``` ## [1] 0.7223805 ``` + 27번 성공한 것은 이 이항분포에서 하위 72.2%, 상위 27.8%에 해당 --- ## Poisson distribution .pull-left[ 고정된 대규모 모집단(fixed large population)에서 짧은 시간에 걸쳐서 희소한 사건(rare events)의 발생 횟수를 추정하는 데 용이한 분포 + 포와송 분포에서 그 희소한 사건의 발생 확률은 시간 단위 별 발생의 평균 횟수로 나타나며 그리스어 람다(`Lambda`, `\(\lambda\)`)로 표기 + 람다는 평균과 분산을 결정 + 포아송 분포를 이용하여 단일 시간 단위에서 `k`라는 희소한 사건을 정확하게 관측할 확률을 추정 ] .pull-right[ <img src="D3S3_files/figure-html/unnamed-chunk-21-1.png" style="display: block; margin: auto;" /> ] --- ## Negative binomial distribution .pull-left[ n번째 시도에서 k번째에 성공할 확률을 보여주는 분포 다음과 같은 네 조건이 충족될 때 유용 1. 모든 시도는 독립적이다. 2. 각 시도의 결과는 성공 혹은 실패로 구분될 수 있다. 3. 성공 확률 (p)은 각 시도마다 동일하다. 4. 마지막 시도는 항상 성공이어야만 한다. ] .pull-right[ <img src="D3S3_files/figure-html/unnamed-chunk-22-1.png" style="display: block; margin: auto;" /> ] --- ## Pop-up quizes! .pull-left[ 우측의 산포도를 바탕으로 두상의 길이와 두개골의 너비 간의 관계에 대해 올바른 진술을 고르시오. ] .pull-right[ <img src="D3S3_files/figure-html/unnamed-chunk-23-1.png" style="display: block; margin: auto;" /> ] (a) 두상의 길이와 두개골의 너비 간에는 관계가 없다. 두 변수는 독립적이다. (b) 두상의 길이와 두개골 너비 간에는 정(positive)의 관계가 있다. (c) 두상이 더 길수록 두개골은 더 넓어진다. (d) 더 넓은 두개골일수록 두상이 더 길어진다. --- ## Pop-up quizes! .pull-left[ 우측의 산포도를 바탕으로 두상의 길이와 두개골의 너비 간의 관계에 대해 올바른 진술을 고르시오. ] .pull-right[ <img src="D3S3_files/figure-html/unnamed-chunk-24-1.png" style="display: block; margin: auto;" /> ] (a) 두상의 길이와 두개골의 너비 간에는 관계가 없다. 두 변수는 독립적이다. **(b) 두상의 길이와 두개골 너비 간에는 정(positive)의 관계가 있다.** (c) 두상이 더 길수록 두개골은 더 넓어진다. (d) 더 넓은 두개골일수록 두상이 더 길어진다. --- ## Hypothesis Tests in R ### Sample and Population .pull-left[ <img src="fig/sample-pop.png" width="80%" style="display: block; margin: auto;" /> ] .pull-right[ 우리는 모집단에 대한 이론적 기대를 가진다. + "모집단은 ~할거야!" 모집단을 직접 관측/획득할 수 없으므로, 표본을 바탕으로 모집단에 대한 추론을 수행 + "표본이 ~하니, 모집단도 ~할거야!" 그러나 이러한 추론은 단정적(deterministic)이지 않음! ] --- ## Hypothesis Tests in R 가설검정의 구조 + 전체적인 모델과 그 모델에 관계된 일련의 가정들을 수립한다. + 예를 들면, 관측치들이 정규분포를 따른다는 가정 등. + 영가설(null hypothesis; `\(H_0\)`)과 대안가설(혹은 연구가설; alternative hypothesis, research hypothesis;<br> `\(H_1\)`, `\(H_A\)`)을 수립한다. 대개 영가설은 모수가 어떤 값을 것이라고 특정한 값을 고정적으로 설정한다. + 주어진 데이터를 가지고 *검정통계치(test statistics)*의 값을 계산한다. + 일반적인 가정 하에서, 영가설이 참이라는 가정 하에 검정통계량의 **분포(distribution)**는 알려져 있다. + 주어진 분포와 추정한 검정통계치로 계산한 `\(p\)`-값과 사전에 특정한 신뢰수준의 값에 따라서 다음과 같은 결정을 내릴 수 있다. + 영가설을 기각하는 데 실패하거나 or 영가설을 기각하거나 --- ## Sample `\(t\)`-test ### What the hack is going on? <img src="fig/ttestpic.jpg" width="80%" style="display: block; margin: auto;" /> --- class: center, middle background-image: url(https://raw.githubusercontent.com/pherephobia/usc_logo/main/UofSC_Primary_RGB_G.png) background-size: 300px background-position: 11% 15% # Thanks! ## Please do not hesitate to ask questions. Contacts for Instructor. | Contact | Sanghoon Park | | :-------------: | :----------------------------: | | <svg viewBox="0 0 512 512" style="height:1em;position:relative;display:inline-block;top:.1em;" xmlns="http://www.w3.org/2000/svg"> <path d="M440 6.5L24 246.4c-34.4 19.9-31.1 70.8 5.7 85.9L144 379.6V464c0 46.4 59.2 65.5 86.6 28.6l43.8-59.1 111.9 46.2c5.9 2.4 12.1 3.6 18.3 3.6 8.2 0 16.3-2.1 23.6-6.2 12.8-7.2 21.6-20 23.9-34.5l59.4-387.2c6.1-40.1-36.9-68.8-71.5-48.9zM192 464v-64.6l36.6 15.1L192 464zm212.6-28.7l-153.8-63.5L391 169.5c10.7-15.5-9.5-33.5-23.7-21.2L155.8 332.6 48 288 464 48l-59.4 387.3z"></path></svg> | [sp23@email.sc.edu](sp23@email.sc.edu) | | <svg viewBox="0 0 576 512" style="height:1em;position:relative;display:inline-block;top:.1em;" xmlns="http://www.w3.org/2000/svg"> <path d="M528 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h480c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm0 400H303.2c.9-4.5.8 3.6.8-22.4 0-31.8-30.1-57.6-67.2-57.6-10.8 0-18.7 8-44.8 8-26.9 0-33.4-8-44.8-8-37.1 0-67.2 25.8-67.2 57.6 0 26-.2 17.9.8 22.4H48V144h480v288zm-168-80h112c4.4 0 8-3.6 8-8v-16c0-4.4-3.6-8-8-8H360c-4.4 0-8 3.6-8 8v16c0 4.4 3.6 8 8 8zm0-64h112c4.4 0 8-3.6 8-8v-16c0-4.4-3.6-8-8-8H360c-4.4 0-8 3.6-8 8v16c0 4.4 3.6 8 8 8zm0-64h112c4.4 0 8-3.6 8-8v-16c0-4.4-3.6-8-8-8H360c-4.4 0-8 3.6-8 8v16c0 4.4 3.6 8 8 8zm-168 96c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64z"></path></svg> | [sanghoon-park.com/](https://www.sanghoon-park.com/) | | <svg viewBox="0 0 448 512" style="height:1em;position:relative;display:inline-block;top:.1em;" xmlns="http://www.w3.org/2000/svg"> <path d="M128 148v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12zm140 12h40c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12zm-128 96h40c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12zm128 0h40c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12zm-76 84v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm76 12h40c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12zm180 124v36H0v-36c0-6.6 5.4-12 12-12h19.5V24c0-13.3 10.7-24 24-24h337c13.3 0 24 10.7 24 24v440H436c6.6 0 12 5.4 12 12zM79.5 463H192v-67c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v67h112.5V49L80 48l-.5 415z"></path></svg> | #305 Gambrell |