如何根据图片中R的独立性卡方检验的结果进行残差分析?
## From Agresti(2007) p.39
M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(M) <- list(gender = c("F", "M"),
party = c("Democrat","Independent", "Republican"))
(Xsq <- chisq.test(M)) # Prints test summary\
答案 0 :(得分:0)
您可以在chsq$stdres
下访问标准化残差,其中chsq
是chisq.test
返回对象。
要使用?chisq.test
M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(M) <- list(
gender = c("F", "M"),
party = c("Democrat","Independent", "Republican"))
chsq <- chisq.test(M)
chsq$stdres
# party
#gender Democrat Independent Republican
# F 4.5020535 0.6994517 -5.3159455
# M -4.5020535 -0.6994517 5.3159455
答案 1 :(得分:-1)