library(vcdExtra)
## Loading required package: vcd
## Loading required package: grid
## Loading required package: gnm
## Warning: package 'gnm' was built under R version 3.4.4
fourfold(Abortion,c(3,1,2))
fourfold(aperm(Abortion,c(3,1,2)))
oddsratio(Abortion, log = FALSE)
## odds ratios for Sex and Status by Support_Abortion
##
## Yes No
## 1.3614130 0.6338682
oddsratio(aperm(Abortion,log = FALSE))
## log odds ratios for Support_Abortion and Status by Sex
##
## Female Male
## 0.5634609 -0.2009764
Summary: Both female with Lo status and male with Hi status tend to support abortion
chisq.test(Hospital)
##
## Pearson's Chi-squared test
##
## data: Hospital
## X-squared = 35.171, df = 4, p-value = 4.284e-07
assocstats(Hospital)
## X^2 df P(> X^2)
## Likelihood Ratio 38.353 4 9.4755e-08
## Pearson 35.171 4 4.2842e-07
##
## Phi-Coefficient : NA
## Contingency Coeff.: 0.459
## Cramer's V : 0.365
assocplot(Hospital)
CMHtest(Hospital)
## Cochran-Mantel-Haenszel Statistics for Visit frequency by Length of stay
##
## AltHypothesis Chisq Df Prob
## cor Nonzero correlation 29.138 1 6.7393e-08
## rmeans Row mean scores differ 34.391 2 3.4044e-08
## cmeans Col mean scores differ 29.607 2 3.7233e-07
## general General association 34.905 4 4.8596e-07
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= "Agreement")
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
The unweighted Kappa value suggested a minimal agreement between rater1 and rater2, and the weighted Kappa value suggested a little stronger, but still weak agreement.The Likelihood ratio and Pearson Chi Square test also suggested the two raters has different opinions on rating.
data <- matrix(c(24,8,13,8,13,11,10,9,64), nrow=3, ncol = 3, byrow = TRUE)
rownames(data) <- c("Con", "Mixed", "Pro")
colnames(data) <- c("Con", "Mixed", "Pro")
data
## Con Mixed Pro
## Con 24 8 13
## Mixed 8 13 11
## Pro 10 9 64
Kappa(data)
## value ASE z Pr(>|z|)
## Unweighted 0.3888 0.05979 6.503 7.870e-11
## Weighted 0.4269 0.06350 6.723 1.781e-11
agreementplot(data, main = "Unweighted", weights = 1)
agreementplot(data, main = "Weighted")