7. 쌍체 t 검정하기

    >>> x1 <- c(51.4, 52.0, 45.5, 54.5, 52.3, 50.9, 52.7, 50.3, 53.8, 53.1)
    >>> x2 <- c(50.1, 51.5, 45.9, 53.1, 51.8, 50.3, 52.0, 49.9, 52.5, 53.0)
    >>> t.test(x1, x2, paired=TRUE, conf.level=0.95) # x1과 x2 평균 비교, 귀무 가설은 두 집단 모평균은 같음
            Paired t-test
    
    data: x1 and x2
    t = 3.5507, df = 9, p-value = 0.006209
    alternative hypothesis: true difference in means is not equal to 0
    95 percent confidence interval:
     0.2322535 1.0477465
    sample estimates:
    mean of the differences

    8. 카이제곱 검정하기

    >>> freq = c(22, 21, 22, 27 ,22, 36)   # 주사위를 150번 던졌을 때 눈별로 나온 빈도
    >>> probs = c(1, 1, 1, 1, 1, 1)/6      # 이론적으로 각 눈은 동일한 확률로 나오는 것을 표현
    >>> chisq.test(freq, p=probs)
            Chi-squared test for given probabilities
    
    data: freq
    X-squared = 6.72, df = 5, p-value = 0.2423
    # 각 눈이 다른 확률로 나온 이번 실험 결과에도 불구하고 검정 결과는 각 눈은 동일한 확률로 나온다는 귀무 가설을 기각시키지 못함
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.