如何解决带有数字变量的 chisq.test
我有下表:
词 | 猫 | 数量 |
---|---|---|
师屋 | DE | 214 |
师屋 | N | 190 |
东溪 | DE | 1308 |
东溪 | N | 925 |
如何运行 chisq.test 来测试 shiwu (214/190) 的 DE/N 比与东溪 (1308/925) 的 DE/N 比是否有显着差异?
解决方法
我认为这段代码很有用。
tibble(Word = c("shiwu","shiwu","dongxi","dongxi"),Cat = c("DE","N","DE","N"),Num = c(214,190,1308,925)) %>% # build tibble (like data frame)
pivot_wider(names_from = Cat,values_from = Num) %>% # structuring it as a table
column_to_rownames("Word") %>% # defining first column (Word) as rownames
as.matrix() %>% # converting data for a contigency table
chisq.test() # executing chi-squared test
答案将是带有 Yates 校正的 Pearson 卡方检验的结果(此校正,因为此数据不会影响结果)。
Pearson's Chi-squared test with Yates' continuity correction
data: .
X-squared = 4.1782,df = 1,p-value = 0.04095
干得好
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。