Exercise 9.1 Consider the data set DaytonSurvey (described in Example 2.6), giving results of a survey of use of alcohol (A), cigarettes (C), and marijuana (M) among high school seniors. For this exercise, ignore the variables sex and race, by working with the marginal table Dayton.ACM, a 2 × 2 × 2 table in frequency data frame form.

library(vcdExtra)
## Loading required package: vcd
## Loading required package: grid
## Loading required package: gnm
data(DaytonSurvey, package = "vcdExtra")
Dayton.ACM <- aggregate(Freq ~ cigarette + alcohol + marijuana, data = DaytonSurvey, FUN = sum)
Dayton.ACM
##   cigarette alcohol marijuana Freq
## 1       Yes     Yes       Yes  911
## 2        No     Yes       Yes   44
## 3       Yes      No       Yes    3
## 4        No      No       Yes    2
## 5       Yes     Yes        No  538
## 6        No     Yes        No  456
## 7       Yes      No        No   43
## 8        No      No        No  279
(a) Use loglm () to fit the model of mutual independence, (A)(C)(M).
library(MASS)
Dayton.ll <- loglm(Freq ~ cigarette + alcohol + marijuana, data= Dayton.ACM, fitted= TRUE)
(b) Prepare mosaic display(s) for associations among these variables. Give a verbal description of the association between cigarette and alcohol use.
mosaic(Dayton.ll,labeling = labeling_residuals)

When alcohol is Yes the possibility of cigarette being Yes is very high. So alcohol and cigarette uses are highly correlated.

(c) Use fourfold () to produce fourfold plots for each pair of variables, AC, AM, and CM, stratified by the remaining one. Describe these associations verbally.
Dayton.xtabs <- xtabs(Freq ~ cigarette + alcohol + marijuana, data = DaytonSurvey)
Dayton1 <- aperm(Dayton.xtabs, c(1,2,3))
fourfold(Dayton1)

Dayton2 <- aperm(Dayton.xtabs, c(1,3,2))
fourfold(Dayton2)

Dayton3 <- aperm(Dayton.xtabs, c(2,3,1))
fourfold(Dayton3)

More alcohol is related to more cigarette use regardless the use of marijuana; more cigarette is related to more marijuana use when alcohol is also used; more marijuana is related to more alcohol use regardless the use of cigarette.