Exercise 4.2 (a) Taking support for abortion as the outcome variable, produce fourfold displays showing the association with sex, stratified by status.

library(vcd)
## Loading required package: grid
library(vcdExtra)
## 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"
#stratified by status
fourfoldplot(aperm(Abortion, c(3,1,2)))

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

  1. For each of the problems above, use oddsratio () to calculate the numerical values of the odds ratio, as stratified in the question.
#calculating odds ratio when stratified by status
odds_ratio_by_status<-oddsratio(Abortion, stratum="Status", log=FALSE)
odds_ratio_by_status
##  odds ratios for Sex and Status by Support_Abortion 
## 
##        Lo        Hi 
## 1.3614130 0.6338682
#calculating odds ratio when stratified by sex
odds_ratio_by_sex<-oddsratio(Abortion, stratum="Sex", log=FALSE)
odds_ratio_by_sex
##  odds ratios for Sex and Status by Support_Abortion 
## 
##    Female      Male 
## 1.3614130 0.6338682
  1. Write a brief summary of how support for abortion depends on sex and status.

Summary From both the stratified graphs (by status and by sex) we can see when the status is “Low” higher proportion of women are supporting abortion. On the contrary, when status is “high” higher proportion of Men are supporting abortion.

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

#creating a matrix with the movie ratings

rating_dataset<- cbind(c(24, 8, 10),c(8,9,13),c(13,10,64))

#lebel the rows and columns
rownames(rating_dataset) = c("Con","Mixed","Pro")
colnames(rating_dataset) = c("Con","Mixed","Pro")
Kappa(rating_dataset)
##             value     ASE     z  Pr(>|z|)
## Unweighted 0.3433 0.06042 5.682 1.330e-08
## Weighted   0.4015 0.06428 6.245 4.225e-10

Comment the unweighted value is 0.3433 which shows the stregnth as “fair agreement”. Weighted value is slightly higher 0.4014 which falls into “moderate agreement” range.

Also, p-value is statisitcally significant, this shows that there is considerable agreement between two reviewrs

  1. Use agreementplot for a graphical display of agreement here.
#lets plot both weighted and unweighted plots and analyze the observations

agreementplot(rating_dataset, main = "Weighted")

agreementplot(rating_dataset, main = "Unweighted")

Comment

By observing the plots we can see the association is higher in “pro” and “con scenarios”, there seems to be relatively less agreement in “con”. This explains the overall kappa values which accounts for all the three scnearios and shows “fair agreement” overall.