分类变量类别子集的等比例检验
Equality proportions test for a subset of categories of a categorical variable
infer
包的小插图给出了测试所有类别的相等性但不是类别的子集的示例。
例如,在infer::gss
数据集中,如果000 or more
的比例等于20000-24999
,有没有办法测试income
变量?
谢谢
我们可以 filter
'income' 的级别,删除未使用的级别 (droplevels
) 并在测试中使用它
library(dplyr)
library(infer)
gss %>%
filter(income %in% c("000 - 24999", "000 or more" ) ) %>%
droplevels %>%
specify(response = income, success = "000 - 24999") %>%
hypothesize(null = "point", p = .5) %>%
generate(reps = 1000) %>%
calculate(stat = "prop")
infer
包的小插图给出了测试所有类别的相等性但不是类别的子集的示例。
例如,在infer::gss
数据集中,如果000 or more
的比例等于20000-24999
,有没有办法测试income
变量?
谢谢
我们可以 filter
'income' 的级别,删除未使用的级别 (droplevels
) 并在测试中使用它
library(dplyr)
library(infer)
gss %>%
filter(income %in% c("000 - 24999", "000 or more" ) ) %>%
droplevels %>%
specify(response = income, success = "000 - 24999") %>%
hypothesize(null = "point", p = .5) %>%
generate(reps = 1000) %>%
calculate(stat = "prop")