Skip to content

Instantly share code, notes, and snippets.

@nozma
Created July 25, 2016 13:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nozma/029387af2e7694da37b4c49775f1ccf3 to your computer and use it in GitHub Desktop.
Save nozma/029387af2e7694da37b4c49775f1ccf3 to your computer and use it in GitHub Desktop.
カテゴリカルデータ解析第4章練習問題解答
# 練習問題
# 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