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
library(MASS)
Dayton.ll <- loglm(Freq ~ cigarette + alcohol + marijuana, data= Dayton.ACM, fitted= TRUE)
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.
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.