Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017....

19
Chap 2. 데이터 정리 (organizing data)

Transcript of Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017....

Page 1: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

Chap 2. 데이터 정리 (organizing data)

Page 2: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

• 기술통계학 (descriptive statistics)

• 추측통계학 (inferential statistics)

• 순서에 따른 배열 (sorting)

[표 1.4.1]의 births의 산모연령을 크기 순서로 배열한 결과

>sort(births$matage)

Page 3: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

2.3 그룹화된 데이터: 도수 분포 grouped data, frequency table

• Sturge’s rule : k=1+3.222(log 10 n)

k=# of classes, n=# sample

width of the classes : w=R/k

R=range (max-min)

Page 4: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

Example 2.3.1

• k=1+3.322(log500) =about 10

• R/k=(43-23)/10=2 -> 5 for practical purpose

[23 ~ 27]

[28 ~ 32]

[33 ~ 37]

[38 ~ 42]

[43 ~ 47]

Page 5: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

Example 2.3.1

• 히스토그램 (histogram)

• 도수다각형 (polygon)

• 히스토그램 및 도수다각형

Page 6: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

Example 2.3.1

• 줄기-잎 그림 (stem-and-leaf displays) > help(stem)

Page 7: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

2.4 기술통계학: 중심성향 descriptive stat: central tendency

population mean

sample mean

statistics : desc. stat derived from sample parameter: desc. stat derived from pop

Page 8: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

2.4 기술통계학: 중심성향

descriptive stat: central tendency

• 산술평균의 성질: (properties of the mean)

① 모든 데이터는 오직 하나의 산술평균치만 갖는다(유일성, uniqueness).

② 산술평균은 그 의미를 이해하기 쉬우며 계산이 간단하다(간결성, simplicity).

③ 산술평균은 모든 데이터를 이용하여 계산하기 때문에 개별 값에 영향을 받는다. (sensitive to outliers)

Page 9: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

2.4 기술통계학: 중심성향

descriptive stat: central tendency

좌우 대칭

Symmetric

오른쪽으로 치우침

Skewed to the right

왼쪽으로 치우침

Skewed to the left

평균 mean 8.0000 6.6667 8.3333

중앙값 median 8.0000 6.0000 9.0000

최빈값 mode 8.00 5.00 10.00

왜도skewness 0.000 0.627 -0.627

skewness

Page 10: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)
Page 11: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

2.5 기술통계학: 산포

descriptive stat: dispersion

Page 12: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

2.5 기술통계학: 산포

descriptive stat: dispersion Range=Max-Min

sample variance, sample standard deviation

population variance, population standard deviation

coefficient of variation

Page 13: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

2.5 기술통계학: 산포

descriptive stat: dispersion

• 백분위수와 사분위수 (percentiles and quartile)

• 100𝑝 % 백분위수(percentile)는 P100𝑝로 표기

예) P10:10% 백분위수(percentile), P70:70% 백분위수

P25 = Q1, P50 = Q2, P75 = Q3

• 정의 (definition)

n개의 관측값이 있고 이들을 (𝑥1, 𝑥2, ⋯ , 𝑥n) 라고 하자. (n+1)p를 계산한 값의 음이 아닌 정수값을 r과 0과 1 사이의 소수를 0≤b<1라고 하자. 이때 r번째 순서통계량과 (r+1)번째 순서통계량을 각각 𝑥(𝑟), 𝑥(𝑟+1)이라고 하면

100p% 백분위수는 다음과 같다.

1 − 𝑏 𝑥 𝑟 + 𝑏 𝑥 𝑟+1 (2.5.6)

Page 14: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

2.5 기술통계학: 산포

descriptive stat: dispersion

• (하나의) 정의 (a definition)

n observations of data= (𝑥1, 𝑥2, ⋯ , 𝑥n) Let (n+1)p=r+b, where r is an integer and 0≤b<1. And let 𝑥(𝑟), 𝑥(𝑟+1) are rth and (r+1)th the order statistics,

then 100p% percentile is defined by

1 − 𝑏 𝑥 𝑟 + 𝑏 𝑥 𝑟+1 (2.5.6)

Page 15: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

2.5 기술통계학: 산포

descriptive stat: dispersion • 예제 2.4.2, P40=?

n=10, (n+1)p=11*.40=4.4=4+0.4=r+b, r=4, b=0.4

𝑃40 = 1 − 0.4 𝑥 4 + 0.4 𝑥 5 = 0.6 ∗ 33 + 0.4 ∗ 33=33

#Exercise 2.4.2, file name=e242.R

age <- c(34,30,35,31,33,33,29,37,36,39)

sort(age)

table(age)

hist(age)

0.6*33+0.4*33

summary(age)

apropos("quan")

?quantile

quantile(age,.40)

n<-length(age)

n

p<-0.40

r=floor((n+1)*p) ; b=(n+1)*p-r

r;b

(1-b)*sort(age)[r]+b*sort(age)[r+1]

Page 16: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)
Page 17: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

2.5 기술통계학: 산포 descriptive stat: dispersion

kurtosis

Page 18: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)

2.5 기술통계학: 산포 descriptive stat: dispersion

첨도 0.000 0.608 -1.158

kurtosis

Boxplot(상자그림)

Q3

Q2

Q1

Outlier : 중앙값을 중심으로 1.5*IQR 범위를 벋어나는 자료값 data not in (median ±1.5*IQR)

Extreme outlier: 중앙값을 중심으로 3.0*IQR 범위를 벋어나는 자료값 data not in (median ±3.0*IQR

±

Page 19: Chap 2. 데이터 정리 (organizing data)hosting03.snu.ac.kr/~hokim/int/2017/chap_2.pdf · 2017. 3. 11. · 데이터 정리 (organizing data) •기술통계학 (descriptive statistics)