library(MASS)
dta <- read.table("all.txt",h=T)
性別與厭世程度
tb1 <- table(dta$gender, dta$level)
tb1
##
## 1 2 3 4 5
## 0 16 43 80 121 81
## 1 14 46 149 182 64
chisq.test(tb1)$expected
##
## 1 2 3 4 5
## 0 12.85176 38.12688 98.10176 129.8028 62.11683
## 1 17.14824 50.87312 130.89824 173.1972 82.88317
chisq.test(tb1)$residuals
##
## 1 2 3 4 5
## 0 0.8781864 0.7892072 -1.8276052 -0.7726398 2.3959081
## 1 -0.7602531 -0.6832231 1.5821726 0.6688806 -2.0741571
chisq.test(tb1)$stdres
##
## 1 2 3 4 5
## 0 1.184076 1.107615 -2.864166 -1.298557 3.504185
## 1 -1.184076 -1.107615 2.864166 1.298557 -3.504185
chisq.test(tb1)
##
## Pearson's Chi-squared test
##
## data: tb1
## X-squared = 19.369, df = 4, p-value = 0.000665
barplot(tb1, beside=T, legend=c("男","女"), xlab="厭世程度", ylab="人數")

性別與社會性厭世程度
tb2 <- table(dta$gender, dta$rating)
tb2
##
## 0 0.5 1
## 0 256 32 53
## 1 346 37 72
chisq.test(tb2)$expected
##
## 0 0.5 1
## 0 257.892 29.55905 53.54899
## 1 344.108 39.44095 71.45101
chisq.test(tb2)$residuals
##
## 0 0.5 1
## 0 -0.11781294 0.44896711 -0.07502270
## 1 0.10199162 -0.38867448 0.06494776
chisq.test(tb2)$stdres
##
## 0 0.5 1
## 0 -0.3156454 0.6213763 -0.1080784
## 1 0.3156454 -0.6213763 0.1080784
chisq.test(tb2)
##
## Pearson's Chi-squared test
##
## data: tb2
## X-squared = 0.38677, df = 2, p-value = 0.8242
barplot(tb2, beside=T, legend=c("男","女"), xlab="社會性厭世程度", ylab="人數")

性別與關心社會議題程度
tb3 <- table(dta$gender, dta$concern)
tb3
##
## 1 2 3 4 5
## 0 8 41 100 133 59
## 1 9 49 165 197 35
chisq.test(tb3)$expected
##
## 1 2 3 4 5
## 0 7.282663 38.55528 113.5239 141.3693 40.26884
## 1 9.717337 51.44472 151.4761 188.6307 53.73116
chisq.test(tb3)$residuals
##
## 1 2 3 4 5
## 0 0.2658140 0.3937203 -1.2692798 -0.7039048 2.9517529
## 1 -0.2301174 -0.3408469 1.0988258 0.6093761 -2.5553564
chisq.test(tb3)$stdres
##
## 1 2 3 4 5
## 0 0.3553993 0.5529589 -2.0555000 -1.2168256 4.1573712
## 1 -0.3553993 -0.5529589 2.0555000 1.2168256 -4.1573712
chisq.test(tb3)
##
## Pearson's Chi-squared test
##
## data: tb3
## X-squared = 19.323, df = 4, p-value = 0.0006791
barplot(tb3, beside=T,legend=c("男","女"), xlab="關心社會議題程度", ylab="人數")

厭世程度與社會性厭世程度
tb4 <- table(dta$level, dta$rating)
tb4
##
## 0 0.5 1
## 1 22 5 3
## 2 71 6 12
## 3 181 16 32
## 4 222 28 53
## 5 106 14 25
chisq.test(tb4)$expected
## Warning in chisq.test(tb4): Chi-squared approximation may be incorrect
##
## 0 0.5 1
## 1 22.68844 2.600503 4.711055
## 2 67.30905 7.714824 13.976131
## 3 173.18844 19.850503 35.961055
## 4 229.15327 26.265075 47.581658
## 5 109.66080 12.569095 22.770101
chisq.test(tb4)$residuals
## Warning in chisq.test(tb4): Chi-squared approximation may be incorrect
##
## 0 0.5 1
## 1 -0.1445324 1.4879614 -0.7883243
## 2 0.4498855 -0.6173857 -0.5285939
## 3 0.5935785 -0.8642346 -0.6605333
## 4 -0.4725430 0.3385254 0.7855007
## 5 -0.3495834 0.4036070 0.4673076
chisq.test(tb4)$stdres
## Warning in chisq.test(tb4): Chi-squared approximation may be incorrect
##
## 0 0.5 1
## 1 -0.2984441 1.5871689 -0.8752706
## 2 0.9669511 -0.6854767 -0.6108918
## 3 1.4246195 -1.0714847 -0.8524226
## 4 -1.2162703 0.4501048 1.0871137
## 5 -0.7830193 0.4669969 0.5628130
chisq.test(tb4)
## Warning in chisq.test(tb4): Chi-squared approximation may be incorrect
##
## Pearson's Chi-squared test
##
## data: tb4
## X-squared = 6.7133, df = 8, p-value = 0.5679
barplot(tb4, beside=T, legend=T, xlab="社會性厭世程度", ylab="人數")

厭世程度與關心社會程度
tb5 <- table(dta$level, dta$concern)
tb5
##
## 1 2 3 4 5
## 1 1 5 10 8 6
## 2 1 15 33 34 6
## 3 3 17 96 100 13
## 4 5 36 103 117 42
## 5 7 17 23 71 27
chisq.test(tb5)$expected
## Warning in chisq.test(tb5): Chi-squared approximation may be incorrect
##
## 1 2 3 4 5
## 1 0.6407035 3.39196 9.987437 12.43719 3.542714
## 2 1.9007538 10.06281 29.629397 36.89698 10.510050
## 3 4.8907035 25.89196 76.237437 94.93719 27.042714
## 4 6.4711055 34.25879 100.873116 125.61558 35.781407
## 5 3.0967337 16.39447 48.272613 60.11307 17.123116
chisq.test(tb5)$residuals
## Warning in chisq.test(tb5): Chi-squared approximation may be incorrect
##
## 1 2 3 4 5
## 1 0.448873959 0.873115210 0.003975208 -1.258190969 1.305532725
## 2 -0.653345882 1.556394755 0.619221744 -0.476925777 -1.391166095
## 3 -0.854944188 -1.747491325 2.263388573 0.519605574 -2.700386346
## 4 -0.578301856 0.297484353 0.211765971 -0.768710234 1.039593185
## 5 2.218075157 0.149549598 -3.637472712 1.404174816 2.386868965
chisq.test(tb5)$stdres
## Warning in chisq.test(tb5): Chi-squared approximation may be incorrect
##
## 1 2 3 4 5
## 1 0.462545399 0.945078506 0.004961481 -1.676302097 1.417156749
## 2 -0.700773693 1.753560559 0.804456007 -0.661395443 -1.571859736
## 3 -1.023977877 -2.198539214 3.283472602 0.804641413 -3.407052970
## 4 -0.742806107 0.401375986 0.329456834 -1.276613147 1.406644900
## 5 2.479305833 0.175592302 -4.924646447 2.029321212 2.810493564
chisq.test(tb5)
## Warning in chisq.test(tb5): Chi-squared approximation may be incorrect
##
## Pearson's Chi-squared test
##
## data: tb5
## X-squared = 54.098, df = 16, p-value = 4.998e-06
barplot(tb5, beside=T, legend=T, xlab="關心社會議題程度", ylab="人數")

社會性厭世程度與關心社會程度
tb6 <- table(dta$rating, dta$concern)
tb6
##
## 1 2 3 4 5
## 0 14 71 218 243 56
## 0.5 1 7 15 32 14
## 1 2 12 32 55 24
chisq.test(tb6)$expected
## Warning in chisq.test(tb6): Chi-squared approximation may be incorrect
##
## 1 2 3 4 5
## 0 12.856784 68.065327 200.41457 249.57286 71.090452
## 0.5 1.473618 7.801508 22.97111 28.60553 8.148241
## 1 2.669598 14.133166 41.61432 51.82161 14.761307
chisq.test(tb6)$residuals
## Warning in chisq.test(tb6): Chi-squared approximation may be incorrect
##
## 1 2 3 4 5
## 0 0.3188322 0.3557106 1.2421907 -0.4160600 -1.7897675
## 0.5 -0.3901538 -0.2869580 -1.6631354 0.6346690 2.0500029
## 1 -0.4098182 -0.5674203 -1.4903808 0.4415217 2.4046294
chisq.test(tb6)$stdres
## Warning in chisq.test(tb6): Chi-squared approximation may be incorrect
##
## 1 2 3 4 5
## 0 0.6528383 0.7650797 3.0807270 -1.1014765 -3.8604707
## 0.5 -0.4126795 -0.3188320 -2.1307192 0.8679610 2.2841877
## 1 -0.4512054 -0.6562274 -1.9874755 0.6285081 2.7888902
chisq.test(tb6)
## Warning in chisq.test(tb6): Chi-squared approximation may be incorrect
##
## Pearson's Chi-squared test
##
## data: tb6
## X-squared = 21.442, df = 8, p-value = 0.006062
barplot(tb6, beside=T, legend=T, xlab="關心社會議題程度", ylab="人數")
