data(GSS)
str(GSS)
# use xtabs to show the table in a compact form
(GSStab <- xtabs(count ~ sex + party, data=GSS))
# fit the independence model
(mod.glm <- glm(count ~ sex + party, family = poisson, data = GSS))
# display all the residuals in a mosaic plot
mosaic(mod.glm,
formula = ~ sex + party,
labeling = labeling_residuals,
suppress=0)
Run the code above in your browser using DataLab