Created
July 25, 2016 13:44
-
-
Save nozma/029387af2e7694da37b4c49775f1ccf3 to your computer and use it in GitHub Desktop.
カテゴリカルデータ解析第4章練習問題解答
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 練習問題 | |
# 1. | |
Ctable <- xtabs(Freq ~ management + own, data = JobSatisfaction) | |
# (a) | |
chisq.test(Ctable) | |
# (b) | |
fisher.test(Ctable) | |
# 2. | |
Ctable <- xtabs(Freq ~ Sex + Survived, data = Titanic[,,"Child",]) | |
chisq.test(Ctable) | |
# 3. | |
Ctable <- xtabs(Freq ~ Class + Survived, data = Titanic)[-4,] | |
result <- chisq.test(Ctable) | |
v <- result$expected * (1 - rowSums(Ctable)/sum(Ctable)) %o% | |
(1 - colSums(Ctable)/sum(Ctable)) | |
(Ctable - result$expected) / sqrt(v) | |
# 4. | |
lbl_test(Hospital) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment