比例的假设检验

R 中的分类数据推断

Andrew Bray

Assistant Professor of Statistics at Reed College

2-1-1.png

R 中的分类数据推断

2-1-2.png

R 中的分类数据推断

2-1-3.png

R 中的分类数据推断

2-1-4.png

R 中的分类数据推断

2-1-5.png

R 中的分类数据推断

2-1-6.png

R 中的分类数据推断

是否有一半美国人支持死刑?

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

ch2v1-density-plot.png

R 中的分类数据推断

是否有一半美国人支持死刑?

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
R 中的分类数据推断

是否有一半美国人支持死刑?

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

ch2v1-density-plot.png

R 中的分类数据推断

假设检验

  • 原假设:关于真实世界状态的理论。
  • 原假设分布:在原假设为真时检验统计量的分布。
  • p 值:原假设与观测一致性的度量。
    • p 值高:一致(p 值 > α)
    • p 值低:不一致(p 值 < α)
R 中的分类数据推断

Passons à la pratique !

R 中的分类数据推断

Preparing Video For Download...