1

library(vcdExtra)
## Loading required package: vcd
## Loading required package: grid
## Loading required package: gnm
library(vcd)
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 fourfold dislay with with sex, stratified by status

fourfold(aperm(Abortion, c(3, 1, 2)))

b fourfold display for support for abortion with status, stratified by sex.

fourfold(aperm(Abortion, c(3, 2, 1)))

c oddsratio () to calculate the numerical values of the odds ratio, as stratified in the question

summary(oddsratio(aperm(Abortion, c(3, 1, 2))))
## 
## z test of coefficients:
## 
##    Estimate Std. Error z value Pr(>|z|)    
## Lo  0.74555    0.17844  4.1781 2.94e-05 ***
## Hi -0.01889    0.17228 -0.1096   0.9127    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(oddsratio(aperm(Abortion, c(3, 2, 1))))
## 
## z test of coefficients:
## 
##        Estimate Std. Error z value Pr(>|z|)   
## Female  0.56346    0.18623  3.0256 0.002481 **
## Male   -0.20098    0.16384 -1.2267 0.219941   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

d why abortion depends on sex and status

aperm(Abortion, c(3, 1, 2))
## , , 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
aperm(Abortion, c(3, 2, 1))
## , , 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

Overall if status is high both male and female support abortion at a higher rate, but if status is low more females still support abortion rates which is interesting to see that they are practical and aware of how this impacts childbirth and children

2

d.mat <- matrix(c(24, 8, 13, 8, 13, 11, 10, 9, 64),
                nrow = 3, ncol = 3, byrow = TRUE)
d.t <- as.table(d.mat)
rownames(d.t) <- c('Con', 'Mixed', 'Pro')
colnames(d.t) <- c('Con', 'Mixed', 'Pro')
addmargins(d.t)
##       Con Mixed Pro Sum
## Con    24     8  13  45
## Mixed   8    13  11  32
## Pro    10     9  64  83
## Sum    42    30  88 160

a Kohen’s

Kappa(d.t)
##             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 agreement plot

agreementplot(d.t, main="Unweighted", weights=1)

agreementplot(d.t, main="Weighted")