开始使用免费开始使用

比例差的假设检验

在上一个练习中,您了解到大约 52% 的女性支持死刑,而大约 63% 的男性支持死刑,相差约 11 个百分点。这个差异看起来很大,但如果这只是偶然造成的,实际上性别与是否支持死刑毫无关系呢?请通过检验原假设——性别与是否支持死刑相互独立——来找出答案。

本练习中您将使用的 stat"diff in props",它需要您通过添加参数 order = c("FIRST", "SECOND") 来指定差值的顺序,其中 FIRST 和 SECOND 指的是组名。计算方式为:FIRST - SECOND。

本练习是课程的一部分

R 中的分类数据推断

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Create null distribution
___ <- gss2016 %>%
  # Specify the response and explanatory as well as the success
  ___(___ ~ ___, success = "___") %>%
  # Set up null hypothesis
  ___(null = "___") %>%
  # Generate 500 reps by permutation
  ___(___ = ___, ___ = "___") %>%
  # Calculate the statistics
  ___(stat = ___, order = c("___", "___"))
编辑并运行代码