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:

  1. Taking support for abortion as the outcome variable, produce fourfold displays showing the association with sex, stratified by status.
library(vcdExtra)
#fourfold(Abortion,c(3,1,2))
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"
fourfold(Abortion)

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 = F))
## log odds ratios for Support_Abortion and Status by Sex 
## 
##     Female       Male 
##  0.5634609 -0.2009764
  1. Write a brief summary of how support for abortion depends on sex and status

The graphs above tell us that more female will be in favor of abortion when the status is low, whereas more men will be in favor of abortion when status is high

Exercise 4.4 The Hospital data in vcd gives a 3 × 3 table relating the length of stay (in years) of 132 long-term schizophrenic patients in two London mental hospitals with the frequency of visits by family and friends.

(a)Carry out a χ2 test for association between the two variables.

chisq.test(Hospital)
## 
##  Pearson's Chi-squared test
## 
## data:  Hospital
## X-squared = 35.171, df = 4, p-value = 4.284e-07

(b)Use assocstats () to compute association statistics. How would you describe the strength of association here?

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

(c)Produce an association plot for these data, with visit frequency as the vertical variable. Describe the pattern of the relation you see here.

x <- t(Hospital)
assocplot(x)

(d)Both variables can be considered ordinal, so CMHtest () may be useful here. Carry out that analysis. Do any of the tests lead to different conclusions?

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

Exercise 4.6 The two-way table Mammograms in vcdExtra gives ratings on the severity of diagnosis of 110 mammograms by two raters.

(a)Assess the strength of agreement between the raters using Cohen’s κ, both unweighted and weighted.

data(Mammograms)
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

(b)Use agreementplot () for a graphical display of agreement here.

agreementplot(Mammograms)

(c)Compare the Kappa measures with the results from assocstats (). What is a reasonable interpretation of each of these measures

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

Exercise 4.7 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”).

  1. Assess the strength of agreement between the raters using Cohen’s κ, both unweighted and weighted.
dt <- matrix(c(24, 8, 13, 8, 13, 11, 10, 9, 64),
                nrow = 3, ncol = 3, byrow = TRUE)
dt <- as.table(dt)
rownames(dt) <- c('Con', 'Mixed', 'Pro')
colnames(dt) <- c('Con', 'Mixed', 'Pro')
addmargins(dt)
##       Con Mixed Pro Sum
## Con    24     8  13  45
## Mixed   8    13  11  32
## Pro    10     9  64  83
## Sum    42    30  88 160
Kappa(dt)
##             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
  1. Use agreementplot () for a graphical display of agreement here.
agreementplot(dt, main="Weighted")

agreementplot(dt, main="Unweighted")