Parametrik olmayan ANOVA ve eşleşmemiş t-testleri

R ile Hipotez Testi

Richie Cotton

Data Evangelist at DataCamp

Parametrik olmayan testler

Parametrik olmayan test, test istatistiği için bir olasılık dağılımı varsaymayan bir hipotez testidir.

Parametrik olmayan hipotez testlerinin iki türü vardır:

  1. Simülasyon tabanlı.
  2. Sıra tabanlı.
R ile Hipotez Testi

t_test()

$H_{0}$: $\mu_{child} - \mu_{adult} = 0$     $H_{A}$: $\mu_{child} - \mu_{adult} > 0$

library(infer)
stack_overflow %>% 
  t_test(
    converted_comp ~ age_first_code_cut,
    order = c("child", "adult"),
    alternative = "greater"
  )
# A tibble: 1 x 6
  statistic  t_df p_value alternative lower_ci upper_ci
      <dbl> <dbl>   <dbl> <chr>          <dbl>    <dbl>
1      2.40 2083. 0.00814 greater        8438.      Inf
R ile Hipotez Testi

Sıfır dağılımını hesaplama

Simülasyon tabanlı iş akışı
null_distn <- stack_overflow %>% 
  specify(converted_comp ~ age_first_code_cut) %>%

hypothesize(null = "independence") %>%
generate(reps = 5000, type = "permute") %>%
calculate( stat = "diff in means", order = c("child", "adult") )
Karşılaştırma için t-testi
library(infer)
stack_overflow %>% 
  t_test(
    converted_comp ~ age_first_code_cut,
    order = c("child", "adult"),
    alternative = "greater"
  )
R ile Hipotez Testi

Gözlenen istatistiği hesaplama

Simülasyon tabanlı iş akışı
obs_stat <- stack_overflow %>% 
  specify(converted_comp ~ age_first_code_cut) %>% 
  calculate(
    stat = "diff in means", 
    order = c("child", "adult")
  )
Karşılaştırma için t-testi
library(infer)
stack_overflow %>% 
  t_test(
    converted_comp ~ age_first_code_cut,
    order = c("child", "adult"),
    alternative = "greater"
  )
R ile Hipotez Testi

p-değerini alın

Simülasyon tabanlı iş akışı
get_p_value(
  null_distn, obs_stat, 
  direction = "greater"
)
# A tibble: 1 x 1
  p_value
    <dbl>
1  0.0066
Karşılaştırma için t-testi
library(infer)
stack_overflow %>% 
  t_test(
    converted_comp ~ age_first_code_cut,
    order = c("child", "adult"),
    alternative = "greater"
  )
# A tibble: 1 x 6
  statistic  t_df p_value alternative lower_ci upper_ci
      <dbl> <dbl>   <dbl> <chr>          <dbl>    <dbl>
1      2.40 2083. 0.00814 greater        8438.      Inf
R ile Hipotez Testi

Vektörlerin sıraları

x <- c(1, 15, 3, 10, 6)
rank(x)
1 5 2 4 3

Wilcoxon-Mann-Whitney testi (diğer adıyla Wilcoxon sıra toplamı testi), (kabaca) sayısal girdinin sıraları üzerinde bir t-testidir.

R ile Hipotez Testi

Wilcoxon-Mann-Whitney testi

wilcox.test(
  converted_comp ~ age_first_code_cut,
  data = stack_overflow,
  alternative = "greater",
  correct = FALSE
) 
    Wilcoxon rank sum test

data:  converted_comp by age_first_code_cut
W = 967298, p-value <2e-16
alternative hypothesis: true location shift is greater than 0
1 "Wilcoxon sıra-toplam testi" ve "Mann-Whitney U testi" olarak da bilinir.
R ile Hipotez Testi

Kruskal-Wallis testi

Kruskal-Wallis testi, Wilcoxon-Mann-Whitney testine; ANOVA, t-testine denktir.

kruskal.test(
  converted_comp ~ job_sat,
  data = stack_overflow
)
    Kruskal-Wallis rank sum test

data:  converted_comp by job_sat
Kruskal-Wallis chi-square = 81, df = 4, p-value <2e-16
R ile Hipotez Testi

Haydi pratik yapalım!

R ile Hipotez Testi

Preparing Video For Download...