Presentation is loading. Please wait.

Presentation is loading. Please wait.

빅데이터 기술 개요 2016/8/20 ~ 9/3 윤형기

Similar presentations


Presentation on theme: "빅데이터 기술 개요 2016/8/20 ~ 9/3 윤형기"— Presentation transcript:

1 빅데이터 기술 개요 2016/8/20 ~ 9/3 윤형기 (hky@openwith.net)hky@openwith.net

2 D6 2http://www.openwith.net

3 R 과 기초통계 2014.2.3 윤형기 (v.0.9)

4 목차 Unit I: 개요 –1. 기본개념 –2. Chart 와 그래프 –3. 기술통계 –4. 확률 Unit II: 변량별 데이터 분석 –5. 단변량 –6. 이변량 –7. 다변량 Unit III: 분포와 표본추출 –8. 이산 분포 –9. 연속 분포 –10. 표본추출과 표본분포 Unit IV: 모수 추정 –11. 신뢰구간추정 ( 단일 모집단 ) –12. 가설검정 ( 단일 모집단 ) –13. 추정 (2 개 모집단 ) –14. 분산분석과 실험계획 Unit V: 비모수 추정 –15. 범주형 데이터 –16. 비모수 통계 * Unit VI: 회귀분석과 예측 –17. 단순회귀분석 –18. 다중회귀분석 4 R 과 기초통계 (www.openwith.net)

5 UNIT I: 개요 1. 기본개념 2. Chart 와 그래프 3. 기술통계 4. 확률 5 R 과 기초통계 (www.openwith.net)

6 1. 기본개념 1.1 통계 개념 6 R 과 기초통계 (www.openwith.net)

7 1.2 데이터의 측도 (Levels of data measurement) R 과 기초통계 (www.openwith.net) 7

8 2. Chart 와 그래프 2.1 Frequency Distributions –Class Midpoint –Relative Frequency –Cumulative Frequency 2.2 계량데이터의 그래프 표현 –Histograms –Frequency Polygons, Ogives –Pie Charts –Stem-and-Leaf Plots –Pareto Charts 2.3 이변량 데이터의 그래프 표현 : Numerical Data –Scatter Plots  Unit II: 변량별 데이터 분석 참조 R 과 기초통계 (www.openwith.net) 8

9 3. 기술통계 3.1 Central Tendency: Ungrouped Data –Mode, Median, Mean Mode  Bimodal, Multimodal Median Mean –Percentiles, Quartiles Percentiles Quartiles R 과 기초통계 (www.openwith.net) 9

10 3.2 Variability: Ungrouped Data –Range & IQR (Interquartile Range) –MAD (Mean Absolute Deviation) –Variance –Standard Deviation Empirical Rule 와 Chebychev’s Theorem Population vs. Sample Variance and Standard Deviation –Unbiased estimator Z-score Coefficient of Variation (CV) R 과 기초통계 (www.openwith.net) 10

11 Z score R 과 기초통계 (www.openwith.net) 11

12 3.3 Central Tendency 와 변동성 : Grouped Data –Central Tendency 의 측정 지표 Mean Mode – 변동성 측정지표 R 과 기초통계 (www.openwith.net) 12

13 3.4 Measures of Shape –Skewness Coefficient of Skewness –Kurtosis –Box-and-Whisker Plots R 과 기초통계 (www.openwith.net) 13

14 3.5 연관성 (Association) 측도 –Correlation Pearson product-moment correlation coefficient Spearman Correlation Coefficient Kendall Tau-b Correlation Coefficient R 과 기초통계 (www.openwith.net) 14

15 R 과 기초통계 (www.openwith.net) 15

16 4. 확률 4.1 기본개념 –Experiment, (Elementary) Events, Sample Space, Independent Events, Unions, Intersections, –MECE (Mutually Exclusive Collectively Exhaustive) –Marginal, Union, Joint –Counting Possibilities mn Counting Rule: m x n Sampling from a Population with Replacement: (N) n possibilities Combinations: Sampling from Population Without Replacement: N C n =  !/  !(  −  )! R 과 기초통계 (www.openwith.net) 16 P(X ⋂ Y) = 0

17 4.2 Addition 및 Multiplication Laws –Addition General Law of Addition: –P(X ∪ Y) = P(X) + P(Y) - P(X ⋂ Y) Special Law of Addition –If X, Y are mutually exclusive, P(X ∪ Y) = P(X) + P(Y) –Multiplication General Law of Multiplication –P(X ⋂ Y) = P(X) P(Y|X) = P(Y) P(X|Y) Special Law of Multiplication –If X, Y are independent, P(X ⋂ Y) = P(X) P(Y) R 과 기초통계 (www.openwith.net) 17

18 R 과 기초통계 (www.openwith.net) 18

19 UNIT II: 변량별 데이터 분석 5. 단변량 6. 이변량 7. 다변량 19 R 과 기초통계 (www.openwith.net)

20 5. 단변량 데이터 5.1 Categorical Data –Table –Barplots –Pie Chart –Dot Chart –Factor 5.2 Numeric Data –Stem-and-leaf plots –Strip chart –The Center: mean, median & mode Range, variance, … 5.3 분포의 모양 –Histogram –Mode, Symmetry and Skew –Boxplot 20 R 과 기초통계 (www.openwith.net)

21 6. 이변량 (Bivariate) 데이터 6.1 Pairs of categorical variables –2-way Table (Summarized/ Unsummarized Data) –2-way table 의 주변분포 (Marginal Distribution) –2-way table 의 조건부 분포 –2-way contingency table 의 그래프 요약 6.2 독립표본의 비교 –Side-by-side Boxplots –Density plot –Strip Chart –Quantile-Quantile plots 6.3 Numeric Data 에서의 관계 (Relationship) –Scatter plot 을 이용한 관계성 분석 – 두 변수간의 상관관계 6.4 단순회귀분석 21 R 과 기초통계 (www.openwith.net)

22 7. 다변량 (Multivariate) 데이터 7.1 다변량데이터의 요약 – 범주형 다변량데이터 요약 – 독립표본의 비교 – 관계성 비교 7.2 R 의 다변량데이터타입 : Data Frame 과 List 7.3 다변량 데이터 모델링 –Boxplot 과 다변량 모델 –Contingency Table – xtabs() –split() 과 stack() 7.4 Lattice 그래픽 활용 22 R 과 기초통계 (www.openwith.net)

23 UNIT II: 분포와 표본추출 8. 이산 분포 9. 연속 분포 10. 표본추출과 표본분포 23 R 과 기초통계 (www.openwith.net)

24 8. 이산 분포 8.1 개요 –Random variable = a variable that contains the outcomes of a chance experiment 8.2 이산분포의 모양 –Mean or Expected Value = long-run average of occurrences –Variance and Standard Deviation of a Discrete Distribution 8.2 이항분포 –Binomial formula –Mean and Standard deviation of a Binomial Distribution 24 R 과 기초통계 (www.openwith.net)

25 8.3 Poisson 분포 – 개념 : Law of improbable events focuses only on the number of discrete occurrences over some interval or continuum –Poisson formula λ = long-run average –Poisson Tables lambda determines … –Mean & Standard Deviation of a Poisson Distribution The mean and expected value of a Poisson distribution is λ. R 과 기초통계 (www.openwith.net) 25

26 8.4 초기하 (Hypergeometric) 분포 – 개요 = 유한 모집단으로부터 비복원추출 시 나타나는 확률분포 – 다음 경우에 이항분포 대신 사용 : (i) Sampling is done without replacement. (ii) n ≥ 5% N R 과 기초통계 (www.openwith.net) 26

27 9. 연속 분포 9.1 Uniform Distribution – 개요 – 일양분포의 확률 R 과 기초통계 (www.openwith.net) 27

28 9.2 정규분포 – 개요 Gaussian distribution Probability Density Function of Normal Distribution –Standardized Normal Distribution z score = # of s.d. that a value x is above or below the mean z distribution 9.3 이항분포 대신 정규분포의 적용 (Approximate) – 경험법칙 ; 대략 normal curve value 의 99.7% 가 3 s.d. 이내 n p > 5 and n q > 5 –Correcting for Continuity ; Converting discrete distribution into a continuous distribution. R 과 기초통계 (www.openwith.net) 28

29 9.4 지수분포 –= probability distribution of times between random occurrences – 지수분포의 확률 Interarrival times of random arrivals are exponentially distributed –cf. Poisson distribution = random occurrences over some interval R 과 기초통계 (www.openwith.net) 29

30 10. 표본추출과 표본분포 R 과 기초통계 (www.openwith.net) 30

31 –Central Limit Theorem R 과 기초통계 (www.openwith.net) 31

32 R 과 기초통계 (www.openwith.net) 32

33 UNIT IV: 모수 추정 11. 신뢰구간 추정 ( 단일 모집단 ) 12. 가설검정 ( 단일 모집단 ) 13. 추정 (2 개 모집단 ) 14. 분산분석과 실험계획 33 R 과 기초통계 (www.openwith.net)

34 11. 신뢰구간 추정 ( 단일 모집단 ) 11.1 z 통계량 이용한 신뢰구간 추정 ( 단일 모집단 ) (σ Known) – 점추정 (point estimation) –100(1-α)% Confidence Interval to Estimate μ: σ known] – 유한조정계수 –Sample Size 가 작은 경우 여태까지 주로 n ≥ 30 n < 30 이어도 중심극한정리에 의해 z formula 적용 : sample size 가 클 때 또는 작아도 모집단이 정규분포 (σ known) 34 R 과 기초통계 (www.openwith.net)

35 11.2 t 통계량 이용한 신뢰구간추정 ( 단일모집단 ) (σ Unknown) – 모집단이 정규분포인데 모집단 s.d 를 모르는 경우 t 분포 적용. 표본크기에 따라 분포가 다르다. t statistic 의 assumption: 모집단이 정규분포 –If population is not normal dist. or is unknown, nonparametric techniques t Distribution 의 특징 : Robust –t 통계량을 이용한 모집단 평균 추정에서의 신뢰구간 R 과 기초통계 (www.openwith.net) 35

36 11.3 모비율 추정 11.4 모분산 추정 –(…) Sample Variance 모분산과 표본분산의 관계 : χ2 분포 R 과 기초통계 (www.openwith.net) 36

37 R 과 기초통계 (www.openwith.net) 37

38 12. 가설검정 ( 단일 모집단 ) 12.1 개요 –Hypotheses 의 종류 –Statistical Hypotheses H 0 H a – 가설검정의 절차 –Rejection and Nonrejection Regions –Type I 및 Type II Errors R 과 기초통계 (www.openwith.net) 38

39 R 과 기초통계 (www.openwith.net) 39

40 –Critical Value Method 를 이용한 가설검정 Rejecting H 0 using p-values R 과 기초통계 (www.openwith.net) 40

41 12.3 t 통계량 이용한 모평균 가설검정 (σ Unknown) –(…) z Test of a Population Proportion R 과 기초통계 (www.openwith.net) 41

42 12.4 비율에 관한 가설검정 –[…] Using p-value Using the critical value method R 과 기초통계 (www.openwith.net) 42

43 12.5 분산에 관한 가설검정 Table χ 2 vs. Observed χ 2 H 0 can also be tested by the critical value method. Observed χ2 value 대신 critical χ 2 value for alpha 를 적용하여 s 2 계 산  yields critical sample variance (s c 2 ) R 과 기초통계 (www.openwith.net) 43

44 12.6 Type II Errors –Some Observations About Type II Errors R 과 기초통계 (www.openwith.net) 44

45 – 운영특성곡선 (OC Curve) 와 Power Curves – 표본크기의 증가가 Rejection Limit 에 미치는 영향 R 과 기초통계 (www.openwith.net) 45

46 13. 추정 (2 개 모집단 ) R 과 기초통계 (www.openwith.net) 46

47 13.2 두 평균 차에 대한 추정 / 가설검정 : 독립표본이고 σ Known – 가설검정 –t Test 를 이용한 두 모평균 차에 대한 CI 수립 및 가설검정 –Confidence Intervals R 과 기초통계 (www.openwith.net) 47

48 13.3 서로 관련된 모집단에 대한 추정 – 종류 Before-and-after study Matched-pair with built-in relatedness, as an experimental control mechanism (ex) twins, siblings – 가설검정 – 신뢰구간 R 과 기초통계 (www.openwith.net) 48

49 13.4 두 개 모비율에 대한 추정 (p 1 - p 2 ) –(…) – 가설검정 – 신뢰구간 13.5 두 개 모분산에 대한 추정 R 과 기초통계 (www.openwith.net) 49

50 14. 분산분석과 실험계획 14.1 실험계획 –experimental design = a plan and a structure to test hypotheses in which the researcher either controls or manipulates one or more variables. – 독립변수 (I.V.) 처치변인 (treatment variable) = a variable the experimenter controls or modifies 분류변인 (classification variable (=factors)) = some characteristic of the subject that was present prior to the experiment and is not a result of manipulations or control. Each I.V. has 2 or more levels (= classifications =subcategories) – 종속변수 (D.V.) R 과 기초통계 (www.openwith.net) 50

51 14.2 Completely Randomized Design (One-Way ANOVA) –One-Way Analysis of Variance H 0 : μ 1 = μ 2 = μ 3 = … = μ k H a : At least one of the means is different from the others. R 과 기초통계 (www.openwith.net) 51

52 –F 분포표 상의 수치 –ANOVA tests are always one-tailed tests w/ rejection region in the upper tail –“Observed F value” vs. “Critical value of F test” (=Table F value) (d.f. 에 의해 참조되는 값 ) –Reject H 0 if (observed F > critical F) –F 값 및 t 값의 비교 F = t 2 for df C = 1 R 과 기초통계 (www.openwith.net) 52

53 14.3 다중비교 검정 –(…) ANOVA 는 multiple group 의 평균 차에 대한 가설검정에 유용 –( 장점 ) Type I error, α, is controlled –Tukey’s Honestly Significant Difference (HSD) Test: The Case of Equal Sample Sizes = pairwise multiple comparisons –Tukey-Kramer Procedure: The Case of Unequal Sample Sizes R 과 기초통계 (www.openwith.net) 53

54 14.4 Randomized Block Design –(…) CRD (I.V. = treatment var. ) + Blocking variable –Block’g var ; to control confounding/concomitant variable »researcher want to control but is not the treatment of interest CRD 와 비슷하지만 also includes a blocking variable, that can be used to control for confounding or concomitant variables. R 과 기초통계 (www.openwith.net) 54

55 RBDCRD R 과 기초통계 (www.openwith.net)

56 14.5 Factorial Design (Two-Way ANOVA) –Factorial Design 의 장점 CRDRBDFactorial Design 각 변수의 Effect 를 별도로 분석 (one per design). 즉, Var’s are studied in isolation 하나의 실험설계에서 두 변수를 동시에 분석. Confounding or concomitant variable 을 하나의 study 에서 control 가능  Additional effects of the second variable are removed from the SSE. 즉, there is potential for increased power over the completely randomized design because the additional effects of the second variable are removed from the error sum of squares. 단, focus on one treatment variable & control for the blocking effect  Interaction 분석 가능 FD with 2 treatments are similar to RBD. Focus on the effects of both variables. (2 treatment 변수 간의 interaction 분석 가능, if multiple measurements are taken under every combination of levels of 2 treatment) R 과 기초통계 (www.openwith.net)

57 –2 개 처치변인을 가지는 Factorial Designs –Factorial Design 에 대한 통계검정 Row effects: H 0 : Row means all are equal. H a : At least one row is different. Column effects: H 0 : Col. means are all equal. H a : At least one col is different. Interaction effects: H 0 : Interaction effects =0. H a : Interaction effect is present. Each of these observed F values is compared to a table F value. The table F value is determined by a, df num, and df denom. R 과 기초통계 (www.openwith.net)

58 –Interaction R 과 기초통계 (www.openwith.net)

59 UNIT V: 비모수 추정 15. 범주형 데이터 16. 비모수 통계 * 59 R 과 기초통계 (www.openwith.net)

60 15. 범주형 데이터 15.1 χ 2 Goodness-of-Fit Test – 모비율 검정 using χ 2 Goodness-of-Fit Test as an Alternative Technique to the z Test 60 R 과 기초통계 (www.openwith.net) 자유도 적용 값 일양분포 가정 or expected 분포가 있을 때 k-1 관측된 것이 Poisson 분포인지 알아보는 경우 k-2 λ 추정 관측된 것이 normal 분포인지 알아보는 경우 k-3μ, σ 추정

61 15.2 Contingency Analysis: χ 2 Test of Independence –(…) χ 2 적합성 검정 ; … χ 2 독립성검정 : 두 변수가 독립인지 여부를 알아보기 위해 여러 범주 를 가지는 두 개 변수의 빈도를 조사 categorical data 분석에 유용  contingency analysis R 과 기초통계 (www.openwith.net) 61

62 16. 비모수 통계 * R 과 기초통계 (www.openwith.net) 62

63 UNIT IV: 회귀분석과 예측 17. 단순회귀분석 18. 다중회귀분석 63 R 과 기초통계 (www.openwith.net)

64 17. 단순회귀분석 17.1 개요 –Correlation – 단순회귀분석 dependent variable = the variable to be predicted (y). independent variable = explanatory variable = The predictor (x). SLR 의 대상 : only a straight-line relationship between 2 variables 17.2 Regression Line Equation 의 결정 deterministic regression model is y = β0 + β1x probabilistic regression model is y = β0 + β1x + ε R 과 기초통계 (www.openwith.net) 64

65 17.3 잔차분석 –It is the sum of squares of these residuals that is minimized to find the least squares line. R 과 기초통계 (www.openwith.net) 65

66 R 과 기초통계 (www.openwith.net) 66

67 17.4 추정값의 표준오차 –error 분석을 위해 잔차 (= 개별 point 에 대한 estimation errors) 계산 대신 standard error of the estimate 이용. SSE is in part a function of the number of pairs of data being used to compute the sum, which lessens the value of SSE as a measurement of error. 더 좋은 지표 = standard error of the estimate (s e ) is a standard deviation of the error of the regression model. ( 정규분포 empirical rule: “68% 가 μ+ 1σ 범위, 95% 가 μ+ 2σ 범위. regression 의 assumption 도 for a given x, error terms ~ ND() ) 이제 error terms ~ ND(), s e 는 error 의 s.d., AVG error =0 이므로 –68% of the error values (residuals) should be within 0 ±1s e –95% of the error values (residuals) should be within 0 ±2s e. s e provides a single measure of magnitude of errors in model. 또한 outlier 식별에 이용. ( 예 : outside ±2s e or ±3s e ) R 과 기초통계 (www.openwith.net) 67

68 17.5 Coefficient of Determination –R 2 = I.V. (x) 가 variability of D.V. (y) 를 얼마나 설명하는가 –r 2 =0 –… –r 2 = 1 D.V. (y) has a variation, measured by SS of y (SS yy ): –SS yy =SSR +SSE –If each term is divided by SSyy, the resulting equation is r 2 is proportion of y variability explained by regression model: –Relationship Between r and r 2 r 2 = (r) 2 –coeff’t of correlation & determination R 과 기초통계 (www.openwith.net) 68

69 17.6 회귀모델 기울기의 가설검정 & 모델 전반의 Testing – 기울기 r = (r) 2 (Q) If all pairs of data points for the population were available, would the slope of that regression line be different from zero? –H 0 : β 1 = 0, H a : β 1 ≠ 0 (two tailed test) –H 0 : β 1 = 0, H a : β 1 > 0 AND H 0 : β 1 = 0, H a : β 1 < 0 –In each case, testing the null hypothesis involves a t test of the slope. R 과 기초통계 (www.openwith.net) 69

70 ◊ – 모델 전반의 검정 F test to determine the overall significance of the model. –SLR provides only 1 predictor and 1 regression coefficient to test. F test for overall significance is testing the same thing as the t test in simple regression. –H 0 : β1 = 0 H a : β1 ≠ 0 –In SLR, F = t 2. Thus, for the airline cost example, the F value is The F value is computed directly by Note from ANOVA table that d.f. due to regression = 1. SLR 에서의 자유도 n -k -1 = n -1 -1 = n -2. 분자의 자유도 (1) / 분모의 자유도 due to error (n -2) In simple regression, the relationship between the critical t value to test the slope and the critical F value of overall significance is R 과 기초통계 (www.openwith.net) 70

71 ◊ 17.7 Estimation –C.I. to Estimate the Conditional Mean of y: μ y|x Because for any value of I.V., x, there can be many values of y (D.V.), one type of C.I. is an estimate of the average value of y for a given x. This average value of y is denoted E (y x ). –Prediction Intervals to Estimate a Single Value of y 2 nd type of interval in regression estimation is a prediction interval to estimate a single value of y for a given value of x. R 과 기초통계 (www.openwith.net) 71

72 R 과 기초통계 (www.openwith.net) 72

73 18. 다중회귀분석 R 과 기초통계 (www.openwith.net) 73

74 18.2 Significance Test of Regression Model & Coefficients – test the overall significance of the model, study the significance tests of the regression coefficients, compute the residuals, examine the standard error of the estimate, observe the coefficient of determination. – 모델 전반의 검정 simple regression; t test of slope of the regression line to see if ≠ 0. ( 즉, whether I.V. contribute significantly in predicting D.V. ) –H 0 : β 1 =0 –H a : β 1 ≠0 multiple regression; an analogous test makes use of F statistic. –H 0 : β 1 = β 2 = β 3 =…= β k =0 –H a : At least one of the regression coefficients is ≠ 0 R 과 기초통계 (www.openwith.net) 74

75 –Significance Tests of the Regression Coefficients In multiple regression, individual significance tests for each regression coefficient using t test. –H 0 : β 1 =0 H 0 : β 2 =0 … H 0 : β k =0 –H a : β 1 ≠ 0 H a : β 2 ≠ 0 H a : β k ≠ 0 –d.f. for each of individual tests of regression coefficients are n - k - 1. R 과 기초통계 (www.openwith.net) 75

76 R 과 기초통계 (www.openwith.net) 76

77 –Coefficient of Multiple Determination (R 2 ) = the proportion of variation of the dependent variable, y, accounted for by the independent variables –Adjusted R 2 I.V. 가 추가되면서 R 2 는 증가 But, 간혹 I.V. 추가 시 모델에 추가정보를 주지 못하면서 R 2 만 증가.  R 2 yield an inflated figure. 이를 감안하려는 것이 adjusted R 2 ( 추 가 정보와 변화된 degrees of freedom 를 함께 검토 ) R 과 기초통계 (www.openwith.net) 77

78 19. 다중 Regression 모델의 구축 R 과 기초통계 (www.openwith.net) 78

79 –Tukey’s Ladder of Transformations R 과 기초통계 (www.openwith.net) 79

80 R 과 기초통계 (www.openwith.net) 80

81 19.2 Indicator (Dummy) Variables –( 예 ) monthly salary – age – sex R 과 기초통계 (www.openwith.net) 81

82 19.3 모델 구축 : 탐색 절차 –regression 모델 개발 : (i) maximize explained proportion of the deviation of y values. (ii) Be as parsimonious as possible. –Search Procedures All Possible Regressions ( 모든 가능한 조합의 회귀분석 ) –If a data set contains k independent variables, all possible regressions will determine 2 k -1 different models. Stepwise Regression ( 단계적 회귀분석 ) –single predictor variable 에서 시작해서 adds and deletes predictors one step at a time, examining the fit of the model at each step until no more significant predictors remain outside the model. –STEP 1/2/3: … Forward Selection ( 전진선택법 ) –= stepwise regression 과 동일. 단, once a variable is entered into the process, it is never dropped out. Backward Elimination ( 후진제거법 ) –… R 과 기초통계 (www.openwith.net) 82

83 19.4 Multicollinearity ( 다중공선성 ) –= 2 이상 독립변수가 highly correlated. (2 개 : collinearity; 여러 개 : multicollinearity) - 실무에서 많이 발생. –1. It is difficult to interpret the estimates of the regression coeff’ts. –2. Inordinately small t values for regression coefficients may result. –3. S.D. of regression coefficients are overestimated. –4. The algebraic sign of estimated regression coefficients may be the opposite of what would be expected for a particular predictor value. –multicollinearity 문제는 regression 계수를 평가하는 t 값에도 영향. Multicollinearity can result in an overestimation of s.d. of the regression coefficients  t values tend to be underrepresentative when multicollinearity is present. – (Approaches to the problem) examine a correlation matrix to search for possible intercorrelations among potential predictor variables. Stepwise regression to prevent the problem of multicollinearity. R 과 기초통계 (www.openwith.net) 83


Download ppt "빅데이터 기술 개요 2016/8/20 ~ 9/3 윤형기"

Similar presentations


Ads by Google