De snelkoppeling via benadering

Inferentie voor categorische gegevens in R

Andrew Bray

Assistant Professor of Statistics at Reed College

Betrouwbaarheidsintervallen

SE
0.009998905
SE_small_n
0.03809731
SE_low_p
0.00547912

Standaardfouten nemen toe als

  • n klein is
  • p dicht bij 0,5 ligt
Inferentie voor categorische gegevens in R

bootstrap_one.png

Inferentie voor categorische gegevens in R

bootstrap_two.png

Inferentie voor categorische gegevens in R

De normale verdeling

Ook wel de "klokcurve".

Als

  • waarnemingen onafhankelijk zijn
  • n groot is

Dan

  • $\hat{p}$ is (ongeveer) normaal verdeeld

ch1v3-normal-curve.png

Inferentie voor categorische gegevens in R

Standaarddeviatie

$$\sqrt{\frac{ \hat{p} \times (1 - \hat{p})}{n}}$$

Inferentie voor categorische gegevens in R

Aannames valideren

Hoe check ik of "waarnemingen onafhankelijk zijn"?

  • Dit hangt af van de dataverzameling.

Wat betekent "n is groot"?

  • $n \times \hat{p} \gt 10$
  • $n \times(1 - \hat{p}) \gt 10$
Inferentie voor categorische gegevens in R

Standaardfout berekenen: benadering

p_hat <- gss2016 %>%
  summarize(mean(happy == "HAPPY")) %>%
  pull()
n <- nrow(gss2016)
c(n * p_hat, n * (1 - p_hat))
116  35
SE_approx <- sqrt(p_hat * (1 - p_hat) / n)
SE_approx
0.03418468
Inferentie voor categorische gegevens in R

Standaardfout berekenen: bootstrap

boot <- gss2016 %>%
  specify(response = happy, success = "HAPPY") %>%
  generate(reps = 500, type = "bootstrap") %>%
  calculate(stat = "prop")
SE_boot <- boot %>%
  summarize(sd(stat)) %>%
  pull()
SE_boot
0.03176741
Inferentie voor categorische gegevens in R

Steekproevenverdelinge n

ggplot(boot, aes(x = stat)) +
  geom_density()

ch1v3-density-curve-1.png

Inferentie voor categorische gegevens in R

Steekproevenverdelingen

ggplot(boot, aes(x = stat)) +
  geom_density() +
  stat_function(fun = dnorm, 
                color = "purple",
                args = 
                  list(mean = p_hat,
                       sd = SE_approx))

ch1v3-density-curve-1.png

Inferentie voor categorische gegevens in R

Steekproevenverdelingen

ggplot(boot, aes(x = stat)) +
  geom_density() +
  stat_function(fun = dnorm, 
                color = "purple",
                args = 
                  list(mean = p_hat,
                       sd = SE_approx))

ch1v3-density-curve-2.png

Inferentie voor categorische gegevens in R

Laten we oefenen!

Inferentie voor categorische gegevens in R

Preparing Video For Download...