Hypothesetoets voor een proportie

Inferentie voor categorische gegevens in R

Andrew Bray

Assistant Professor of Statistics at Reed College

2-1-1.png

Inferentie voor categorische gegevens in R

2-1-2.png

Inferentie voor categorische gegevens in R

2-1-3.png

Inferentie voor categorische gegevens in R

2-1-4.png

Inferentie voor categorische gegevens in R

2-1-5.png

Inferentie voor categorische gegevens in R

2-1-6.png

Inferentie voor categorische gegevens in R

Is de helft van de Amerikanen voor de doodstraf?

gss2016 %>%
  ggplot(aes(x = cappun)) +
  geom_bar()
p_hat <- gss2016 %>%
  summarize(mean(cappun == "FAVOR")) %>%
  pull()
p_hat
0.5666667

dichtheidsplot ch2v1

Inferentie voor categorische gegevens in R

Is de helft van de Amerikanen voor de doodstraf?

null <- gss2016 %>%
  specify(
    response = cappun, 
    success = "FAVOR"
  ) %>%
  hypothesize(
    null = "point", 
    p = 0.5
  ) %>%
  generate(
    reps = 500, 
    type = "simulate"
  ) %>%
  calculate(stat = "prop")
A tibble: 500 x 2
   replicate  stat
   <fct>     <dbl>
 1 1         0.48 
 2 2         0.447
 3 3         0.48 
 4 4         0.44 
 5 5         0.407
 6 6         0.52 
 7 7         0.413
 8 8         0.553
 9 9         0.52 
10 10        0.467
# … with 490 more rows
Inferentie voor categorische gegevens in R

Is de helft van de Amerikanen voor de doodstraf?

ggplot(null, aes(x = stat)) +
  geom_density() +
  geom_vline(
    xintercept = p_hat, 
    color = "red"
  )
null %>%
  summarize(mean(stat > p_hat)) %>%
  pull() * 2

dichtheidsplot ch2v1

Inferentie voor categorische gegevens in R

Hypothesetoets

  • Nulhypothese: theorie over de echte situatie.
  • Nulverdeling: verdeling van toetsstatistieken als de nul waar is.
  • p-waarde: maat voor consistentie tussen nulhypothese en je data.
    • hoge p-waarde: consistent (p-val > alpha)
    • lage p-waarde: inconsistent (p-val < alpha)
Inferentie voor categorische gegevens in R

Laten we oefenen!

Inferentie voor categorische gegevens in R

Preparing Video For Download...