library(tidyverse)
library(magrittr)
library(vcd)
library(vcdExtra)
library(HistData)
The data set Abortion in vcdExtra gives a 2 × 2 × 2 table of opinions regarding abortion in relation to sex and status of the respondent. This table has the following structure:
Abortion <- vcdExtra::Abortion
str(Abortion)
## table [1:2, 1:2, 1:2] 171 152 138 167 79 148 112 133
## - attr(*, "dimnames")=List of 3
## ..$ Sex : chr [1:2] "Female" "Male"
## ..$ Status : chr [1:2] "Lo" "Hi"
## ..$ Support_Abortion: chr [1:2] "Yes" "No"
abort1 = aperm(Abortion, c(3,1,2))
abort1
## , , Status = Lo
##
## Sex
## Support_Abortion Female Male
## Yes 171 152
## No 79 148
##
## , , Status = Hi
##
## Sex
## Support_Abortion Female Male
## Yes 138 167
## No 112 133
fourfoldplot(abort1,color = c("blue", "green"), conf.level = 0.95, std = c("ind.max"), space = 0.3, main = NULL, mfrow = NULL, mfcol = NULL)
abort2 = aperm(Abortion, c(3,2,1))
abort2
## , , Sex = Female
##
## Status
## Support_Abortion Lo Hi
## Yes 171 138
## No 79 112
##
## , , Sex = Male
##
## Status
## Support_Abortion Lo Hi
## Yes 152 167
## No 148 133
fourfoldplot(abort2 ,color = c("blue", "green"), conf.level = 0.95, std = c("ind.max"), space = 0.3, main = NULL, mfrow = NULL, mfcol = NULL)
# stratified by status
oddsratio(abort1)
## log odds ratios for Support_Abortion and Sex by Status
##
## Lo Hi
## 0.74554746 -0.01888987
# stratified by sex
oddsratio(abort2)
## log odds ratios for Support_Abortion and Status by Sex
##
## Female Male
## 0.5634609 -0.2009764
From the fourfold plot stratified by status we can see when status is Hi, the odds seems to be similar for Females and Males to support or not support abortion; but when status is low, the odds for females not support abortion is clearly less than males.
From the fourfold plot stratified by sex we can see when sex is male the odds seems to be similar for the two status to support or not support abortion; but when sex is female, the odds for status lo not support abortion is clearly less then status Hi.
Agresti and Winner (1997) gave the data in below on the ratings of 160 movies by the reviewers Gene Siskel and Roger Ebert for the period from April 1995 through September 1996. The rating categories were Con (“thumbs down”), Mixed, and Pro (“thumbs up”).
datav <- matrix(c(24, 8, 13, 8, 13, 11, 10, 9, 64),
nrow = 3, ncol = 3, byrow = TRUE)
datav <- as.table(datav)
rownames(datav) <- c('Con', 'Mixed', 'Pro')
colnames(datav) <- c('Con', 'Mixed', 'Pro')
datav
## Con Mixed Pro
## Con 24 8 13
## Mixed 8 13 11
## Pro 10 9 64
Kappa(datav)
## value ASE z Pr(>|z|)
## Unweighted 0.3888 0.05979 6.503 0.00000000007870
## Weighted 0.4269 0.06350 6.723 0.00000000001781
From the cohen’s kappa we saw both p values for unweighted and weighted are smaller than alpha, but the k value is not very close to 1. Thus, we can conclude there is marginal agreement between the two reviewers.
(b). Use agreementplot () for a graphical display of agreement here.
agreementplot(datav, main="Unweighted", weights=1)
agreementplot(datav, main="Weighted")