Learn R Programming

vcdExtra (version 0.9.7)

Mental: Mental Impairment and Parents SES

Description

A 6 x 4 contingency table representing the cross-classification of mental health status (mental) of 1660 young New York residents by their parents' socioeconomic status (ses).

Arguments

Format

A data frame frequency table with 24 observations on the following 3 variables.

ses

an ordered factor with levels 1 < 2 < 3 < 4 < 5 < 6

mental

an ordered factor with levels Well < Mild < Moderate < Impaired

Freq

cell frequency: a numeric vector

Details

Both ses and mental can be treated as ordered factors or integer scores. For ses, 1="High" and 6="Low".

References

Friendly, M. Visualizing Categorical Data, Cary, NC: SAS Institute, 2000, Appendix B.7.

Examples

Run this code

data(Mental)
str(Mental)
(Mental.tab <- xtabs(Freq ~ ses + mental, data=Mental))

# mosaic and sieve plots
mosaic(Mental.tab, gp=shading_Friendly)
sieve(Mental.tab, gp=shading_Friendly)

if(require(ca)){
  plot(ca(Mental.tab), main="Mental impairment & SES", lines=TRUE)
}

# fit linear x linear (uniform) association model, using integer scores
# for rows/cols
indep <- glm(Freq ~ mental + ses, family = poisson, data = Mental)
Cscore <- as.numeric(Mental$ses)
Rscore <- as.numeric(Mental$mental)

linlin <- glm(Freq ~ mental + ses + Rscore:Cscore,
              family = poisson, data = Mental)
anova(linlin, test = "Chisq")

# use update.glm method to fit other models
linlin <- update(indep, . ~ . + Rscore:Cscore)
roweff <- update(indep, . ~ . + mental:Cscore)
coleff <- update(indep, . ~ . + Rscore:ses)
rowcol <- update(indep, . ~ . + Rscore:ses + mental:Cscore)

# compare models
LRstats(indep, linlin, roweff, coleff, rowcol)

# tests of nested models
anova(indep, linlin, roweff, test = "Chisq")

Run the code above in your browser using DataLab