Source(Discrete Data Analysis with R By: Michael Friendly)
Exercise 4.2 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
library(vcdExtra)
## Loading required package: vcd
## Loading required package: grid
## Loading required package: gnm
data("Abortion", package = "vcdExtra")
str(Abortion)
## 'table' num [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"
(a) Taking support for abortion as the outcome variable, produce fourfold displays showing the association with sex, stratified by status.
fourfold(aperm(Abortion, c(1,3,2 )))

(b) Do the same for the association of support for abortion with status, stratified by sex.
fourfold(aperm(Abortion, c(2,3,1 )))

(c) For each of the problems above, use oddsratio () to calculate the numerical values of the odds ratio, as stratified in the question.
oddsratio(aperm(Abortion, c(1,3,2 )))###log odds ratios for Sex and Support_Abortion by Status
## log odds ratios for Sex and Support_Abortion by Status
##
## Lo Hi
## 0.74554746 -0.01888987
oddsratio(aperm(Abortion, c(2,3,1 )))###log odds ratios for Status and Support_Abortion by Sex
## log odds ratios for Status and Support_Abortion by Sex
##
## Female Male
## 0.5634609 -0.2009764
(d) Write a brief summary of how support for abortion depends on sex and status.
fourfold(aperm(Abortion, c(2,1,3 )))

First of all I threw a plot of association of status and sex with stratified by support abortion.Women with low status support abortion rather than males with same situation and males with high status support abortion rather than females with same situation.
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).
(a) Assess the strength of agreement between the raters using Cohen s ??, both unweighted and weighted.
movie = matrix(c(24,8,13,8,13,11,10,9,64),ncol=3,byrow=TRUE)
movie
## [,1] [,2] [,3]
## [1,] 24 8 13
## [2,] 8 13 11
## [3,] 10 9 64
colnames(movie) = c("Con","Mixed","Pro")
rownames(movie) = c("Con","Mixed","Pro")
movie
## Con Mixed Pro
## Con 24 8 13
## Mixed 8 13 11
## Pro 10 9 64
class(movie)
## [1] "matrix"
movie = as.table(movie)
class(movie)
## [1] "table"
addmargins(movie)
## 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(movie)
## 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
(b) Use agreementplot() for a graphical display of agreement here.
agreementplot(movie)

agreementplot(movie, main="Weighted")

agreementplot(movie, main="UnWeighted")
