통계에 대한 기초적인 이해
가설과 가설검증
R Cookbook
Chapter 1 Getting Started and Getting Help
Chapter 2 Some Basics
Chapter 3 Navigating the Software
Chapter 4 Input and Output
Chapter 5 Data Structures
Chapter 6 Data Transformations
Chapter 7 Strings and Dates
Chapter 8 Probability
Chapter 9 General Statistics
Chapter 10 Graphics
Chapter 11 Linear Regression and ANOVA
Chapter 12 Useful Tricks
Chapter 13 Beyond Basic Numerics and Statistics
Chapter 14 Time Series Analysis
Course Introduction –> syllabus
동영상 (R 관련)
Introduction to R and others
동영상 (통계관련 샘플링에 대한 설명)
기본용어
기술통계 (descriptive statistics)
추론통계 (inferential statistics)
아래의 개념은 샘플링 문서를 먼저 볼것
가설 (hypothesis)
변인 (variables)
What's normal distribution?
?rnorm ?pnorm ?qnorm . . . . rnorm(40,100,10) rnorm(20,0,1) rnorm(20)
rnorm2 <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) } set.seed(101) a <- rnorm(1000,100,10) mean(a) sd(a) b <- rnorm2(1000,100,10) mean(b) sd(b)
Sampling
가설
지난 동영상 리캡 및 가설에 대한 소개
가설에 대한 소개 및 설명
가설이 만들어지는 이유
가설의 예
변인의 종류와 변인측정의수준
Some basics
from the previous lecture (research question and hypothesis)
# normal distribution # see the above [[:normal_distribution]] doc # dnorm = density of normal distribution # pnorm = percentile of normal distribution # qnorm = quantile of normal distribution # rnorm = random sampling of normal distribution dnorm(0,0,1) x <- seq(-5, 5, length=11) span <- c(x) span dnorm(span, 0,1) plot(dnorm(span,0,1)) pnorm(0,0,1) pnorm(1,0,1) pnorm(2) pnorm(3) # volume of the intersection pnorm(1)-pnorm(-1) pnorm(2)-pnorm(-2) pnorm(3)-pnorm(-3) # qnorm qnorm(0.84134478,0,1) qnorm(0.97724988888) qnorm(0.9986501)
> dnorm(0,0,1) [1] 0.3989423 > x <- seq(-5, 5, length=11) > span <- c(x) > span [1] -5 -4 -3 -2 -1 0 1 2 3 4 5 > dnorm(span, 0,1) [1] 1.486720e-06 1.338302e-04 4.431848e-03 5.399097e-02 2.419707e-01 3.989423e-01 2.419707e-01 [8] 5.399097e-02 4.431848e-03 1.338302e-04 1.486720e-06 > plot(dnorm(span,0,1)) > > pnorm(0,0,1) [1] 0.5 > pnorm(1,0,1) [1] 0.8413447 > pnorm(2) [1] 0.9772499 > pnorm(3) [1] 0.9986501 > > # volume of the intersection > pnorm(1)-pnorm(-1) [1] 0.6826895 > pnorm(2)-pnorm(-2) [1] 0.9544997 > pnorm(3)-pnorm(-3) [1] 0.9973002 > > # qnorm > qnorm(0.84134478,0,1) [1] 1 > qnorm(0.97724988888) [1] 2 > qnorm(0.9986501) [1] 3 >
> 0.05/2 [1] 0.025 > qnorm(1-0.025) [1] 1.959964 > qnorm(0.025) [1] -1.959964 > 0.01/2 [1] 0.005 > 1-(0.01/2) [1] 0.995 > qnorm(1-0.005) [1] 2.575829 > qnorm(0.005) [1] -2.575829 > 0.32/2 [1] 0.16 > qnorm(1-0.16) # = 0.84 [1] 0.9944579 > qnorm(0.16) [1] -0.9944579 >
3주차 온라인 강의 동영상은 4주에 걸쳐서 보시기 바랍니다. 즉, 4주 중에 따로 동영상 올리지 않습니다.
—–
—–
Howell, Ch. 4 내용 중 Variance와 (분산) Standard deviation은 (표준편차는) 이후 통계 검증방법을 이해하는데 기초가 되는 중요한 내용이니 꼭 숙지하시기 바랍니다.
Navigating software
+-1 sd = 68% = +-1 sd
+-2 sd = 95% = +-1.96 sd
+-3 sd = 99% (99.7%) = +-3 sd
표준점수 (unit with a standard deviation) = z score
Sampling distribution via random sampling
# +-1SD = 68% # +-2SD = 95% # +-3SD = 99% 라고 했지만 # pnorm(2) = ? pnorm(2) pnorm(2) - pnorm(-2) pnorm(90,70,10) pnorm(90,70,10) - pnorm(50,70,10) pnorm(3) - pnorm(-3) # 95%를 마춰서 생각하려면 qnorm(0.975) # .05의 (1-0.95) 오른쪽 반 qnorm(0.025) # 왼쪽 반 s2.h <- qnorm(.975) # environment panel (r) 체크할 것 s2.l <- qnorm(.025) pnorm(s2.h) - pnorm(s2.l) # 정확히 95% # 1%의 반반씩 생각해보기 s3.h <- qnorm(0.995) s3.l <- qnorm(0.005) pnorm(s3.h) - pnorm(s3.l) # for variance of sample means # see the [[:sampling distribution in r]]
see the sampling distribution in r
동영상 시청
Lecture materials for this week
##### mu.pop <- 100 sd.pop <- 10 set.seed(101) treated.group <- rnorm(16, 112, 10) treated.group m.tg <- mean(treated.group) m.tg # H1: m.tg =\ mu.pop (100) ? # H0: if m.tg =\ mu.pop (100) # then # n=16 Xbar ~ N(mu.pop, 25/4) # 즉 Xbar집합의 분산은 6.25 # 표준편차는 (표준오차, se) 2.5 # 따라서 Xbar 집합의 평균을 중심으로한 # 95% 범위는 pop.mu +- 2*(se) # 즉, 100중 95는 95 ~ 105 사이에서 샘플의 평균이 나와야 함 # 즉, m.tg는 위의 범위에서 나와야 함. 그러나 # 나머지 5%는 95 밑이나 105 위에서 나올 수도 있음 # 그런데, m.tg = 113.0706 # 이를 근거로 영가설을 부정하고 # 검증하고자 하는 연구가설을 채택함 # 즉, treated group 과 모집단의 평균은 다르다. 혹은 # treated group은 모집단에서 추출될 수 있는 샘플이 아니라 # 다른 모집단에 속한 샘플이다 (95% 확신, 5% 에러마진) se <- sqrt((sd.pop^2)/16) qnorm(0.975,mean=100,sd=se) # [1] 104.8999 qnorm(0.025,mean=100,sd=se) # [1] 95.10009 # 그렇다면 mu.tg 값이 나올 확률은 몇일까? pnorm(mu.tg, mean=100, sd=se) # [1] 0.9999999 sscore <- (m.tg-mu.pop)/se sscore # [1] 5.22823 1-pnorm(sscore,0,1) # [1] 8.557037e-08 a <- 1-pnorm(sscore,0,1) b <- pnorm(-sscore,0,1) a # [1] 8.557037e-08 b # [1] 8.557037e-08 a+b # [1] 1.711407e-07 # install.packages("BSDA") # library(BSDA) z.test(treated.group, mu=mu.pop, sigma.x=sd.pop) mu.pop <- 100 sd.pop <- 10 set.seed(100) treated.group.2 <- rnorm(16, 102, 10) treated.group.2 m.treated.group.2 <- mean(treated.group.2) m.treated.group.2 # install.packages("BSDA") # library(BSDA) z.test(treated.group.2, mu=mu.pop, sigma.x=sd.pop) set.seed(100) treated.group.2 <- rnorm(1600, 102, 10) treated.group.2 m.treated.group.2 <- mean(treated.group.2) m.treated.group.2 # install.packages("BSDA") # library(BSDA) z.test(treated.group.2, mu=mu.pop, sigma.x=sd.pop)
> z.test(treated.group, mu=mu.pop, sigma.x=sd.pop) One-sample z-Test data: treated.group z = 5.2282, p-value = 1.711e-07 alternative hypothesis: true mean is not equal to 100 95 percent confidence interval: 108.1707 117.9705 sample estimates: mean of x 113.0706 > # 위에서 . . . . z 값이 +_2 밖이면 영가설을 부정하고 # 연구가설을 채택하게 된다
# 샘플 숫자가 작을 경우 위의 +-2 점수가 정확하지 # 않기 때문에 보정을 해주게 된다. 이 보정된 값은 # 샘플의 숫자에 따라서 (degrees of freedom) 달 # 라지게 된다
이번 주 동영상
또한 R에서 데이터를 (테이블 혹은 어레이) 이용하여 function을 적용하는 것에 대해서 잘 익혀두시기 바랍니다. 이는 R cookbook의 아래 내용에 해당이 됩니다 (특히 sapply, tapply, by 등)
Strings and Dates
# pnorm # qnorm # pt # qt percentage <- .975 df <- 99 t.critical <- qt(percentage, df) # sample size = df + 1 일 때, 95%에 해당하는 점수는? t.critical t.calculated <- 3.6 df <- 8 pt(t.calculated, df)
7주차 동영상
Probability calculation in R ← Probability in R cookbook (텍스트북)
8주차 정기시험기간 중에 2차 퀴즈
시험기간
영상 ANOVA
위키페이지 참조
vene . . . go or come
intervene
convene
contravene
prevent
advent
circumvent
10주차 동영상입니다.
see w10.lecture.note
동영상 (총 5 개)
—-
regression
multiple regression
using dummy variables
getting started
basics
navigating in r
input output in r
data structures
data transformations
과제명: ms23.w11.ga.covariance.exercise
제출파일명: ms23.w11.ga.covariance.exercise.group##.odc (docx)
과제내용:
아래 데이터를 다운로드 받아서 두 변인 간의 상관관계계수를 구하시오.
income.happiness.csv
income.happiness.cat.csv
데이터는 수입과 행복을 측정한 것입니다. 실제 데이터를 살펴보고 R로 읽어 온 후에 R을 이용하여 아래를 구하시오. R에서의 명령어와 아웃풋을 카피/패이스트 하여 제출하시오 (fixed-font를 사용하여).
==
연산자를 이용하여 확인하시오) May 22 (월), 24 (수)
regression lecture note for r
동영상 Regression
영상
multiple regression lecture note for r
multiple regression
June 5(월), 7(수)
13주차 참조
June 12, 14
13주차 참조
June 19, 21 (퀴즈일자에만 퀴즈를 보고 수업은 없음)
Final-term