a
JobSat <- matrix(c(1,2,1,0,3,3,6,1,10,10,14,9,6,7,12,11),4,4)
dimnames(JobSat) = list(income=c("<15K","15-25K","25-40K",">40K"),satisfaction=c("VeryD","LittleD","ModerateS","VeryS"))
JobSat <- as.table(JobSat)
JobSat
## satisfaction
## income VeryD LittleD ModerateS VeryS
## <15K 1 3 10 6
## 15-25K 2 3 10 7
## 25-40K 1 6 14 12
## >40K 0 1 9 11
b
ChiSquare Test
chisq.test(JobSat)
## Warning in chisq.test(JobSat): Chi-squared approximation may be incorrect
##
## Pearson's Chi-squared test
##
## data: JobSat
## X-squared = 5.9655, df = 9, p-value = 0.7434
MonteCarlo Test
chisq.test(JobSat, simulate = TRUE)
##
## Pearson's Chi-squared test with simulated p-value (based on 2000
## replicates)
##
## data: JobSat
## X-squared = 5.9655, df = NA, p-value = 0.7751
c
library(vcdExtra)
## Warning: package 'vcdExtra' was built under R version 3.5.1
## Loading required package: vcd
## Warning: package 'vcd' was built under R version 3.5.1
## Loading required package: grid
## Loading required package: gnm
## Warning: package 'gnm' was built under R version 3.5.1
##
## Attaching package: 'vcdExtra'
## The following object is masked _by_ '.GlobalEnv':
##
## JobSat
CMHtest(JobSat)
## Cochran-Mantel-Haenszel Statistics for income by satisfaction
##
## AltHypothesis Chisq Df Prob
## cor Nonzero correlation 2.9830 1 0.084144
## rmeans Row mean scores differ 4.4774 3 0.214318
## cmeans Col mean scores differ 3.1036 3 0.375931
## general General association 5.9034 9 0.749549
data("Mammograms",package = "vcdExtra")
Kappa(Mammograms)
## value ASE z Pr(>|z|)
## Unweighted 0.3713 0.06033 6.154 7.560e-10
## Weighted 0.5964 0.04923 12.114 8.901e-34
agreementplot(Mammograms,main = "unweighted", weights = 1)
agreementplot(Mammograms, main="Weighted")
c
assocstats(Mammograms)
## X^2 df P(> X^2)
## Likelihood Ratio 92.619 9 4.4409e-16
## Pearson 83.516 9 3.2307e-14
##
## Phi-Coefficient : NA
## Contingency Coeff.: 0.657
## Cramer's V : 0.503