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.
knitr::opts_chunk$set(warning = FALSE)
library(MASS)
## Warning: package 'MASS' was built under R version 3.4.4
library(vcd)
## Loading required package: grid
library(vcdExtra)
## Warning: package 'vcdExtra' was built under R version 3.4.2
## Loading required package: gnm
data(DaytonSurvey)
attach(DaytonSurvey)
str(DaytonSurvey)
## 'data.frame': 32 obs. of 6 variables:
## $ cigarette: Factor w/ 2 levels "Yes","No": 1 2 1 2 1 2 1 2 1 2 ...
## $ alcohol : Factor w/ 2 levels "Yes","No": 1 1 2 2 1 1 2 2 1 1 ...
## $ marijuana: Factor w/ 2 levels "Yes","No": 1 1 1 1 2 2 2 2 1 1 ...
## $ sex : Factor w/ 2 levels "female","male": 1 1 1 1 1 1 1 1 2 2 ...
## $ race : Factor w/ 2 levels "white","other": 1 1 1 1 1 1 1 1 1 1 ...
## $ Freq : num 405 13 1 1 268 218 17 117 453 28 ...
(a)Use loglm () to fit the model of mutual independence, [A][C][M].
Dayton1.ACM =aggregate(Freq~cigarette +alcohol +marijuana,data= DaytonSurvey, FUN=sum)
ACM.ind =loglm(Freq ~., data=Dayton1.ACM)
ACM.ind
## Call:
## loglm(formula = Freq ~ ., data = Dayton1.ACM)
##
## Statistics:
## X^2 df P(> X^2)
## Likelihood Ratio 1286.020 4 0
## Pearson 1411.386 4 0
(b)Prepare mosaic display(s) for associations among these variables. Give a verbal description of the association between cigarette and alcohol use.
Dayton1.tab = xtabs(Freq ~ ., data=Dayton1.ACM)
pairs(Dayton1.tab, type="pairwise", shade = TRUE)
As the plot shows, Marijuana abuse is very high but within a reasonable level.
(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.
fourfold(aperm(Dayton1.tab,c(1,2,3)))
Marijuana abuse is highly correlated with alcohol use.
fourfold(aperm(Dayton1.tab, c(2, 3, 1)))
If people don’t abuse cigarettes, the probability for their abusing alcohol and marijuana are much higher than before.
fourfold(aperm(Dayton1.tab, c(3, 1, 2)))
Through the plot, we can see higher alcohol consumption would have more correlaton with higher cigarette use, but not with marjuana.