#### Illustration Mosaik Plots mit Titanic Daten ### ### Vorlesung Helmut Küchenhoff 8.12.2015 data(Titanic) Titanic; ### Lade Paket vcd #### library(vcd); library(stats); mosaicplot(~ Sex, data = Titanic, color = TRUE) mosaicplot(~ Sex+Age, data = Titanic, color = TRUE) mosaicplot(~ Sex+Age+Class, data = Titanic, color = TRUE) mosaicplot(~ Sex+Class+Survived , data = Titanic, color = TRUE) mosaicplot(~ Sex+Age+Class+Survived,data = Titanic, color = TRUE) mosaicplot(~ Sex+Class+Survived , data = Titanic, shade = TRUE) pairs(Titanic) ### Darstellungen mit pearson Resuen mosaicplot(~ Sex + Survived, data = Titanic, color = TRUE,shade=TRUE) mosaicplot(~ Sex+Class + Survived , data = Titanic, shade=TRUE,color = TRUE) mosaicplot(~ Sex+Class+Age + Survived , data = Titanic, shade=TRUE,color = TRUE) wahl <- matrix(c(144, 153, 17, 26, 95,200, 145, 30, 50, 71),5,2) dimnames(wahl) = list(Partei= c("CDU","SPD", "FDP", "Gr","R"), Geschlecht = c("M","F")) ###wahl ist eine Matrix wahl ### Transponieren t(wahl) ## plotten geht nicht vern?nftig plot(wahl) ### wahl2 ist ein Obejkt des typus table wahl2 <- as.table(wahl) ### Standardplot ist Mosaik plot wahl2 plot(wahl2) ### besser transponiert plot(t(wahl2)) ### Mosaikplot mit Farben mosaicplot(~ Geschlecht+Partei, data = wahl2, color = c("black","red","yellow","green","white"), dir= c("v","h")) mosaicplot(wahl2, color=TRUE,shade = TRUE) ### Berechne Kontingenzkoeffizienten assocstats(wahl2) margin.table(wahl2,2) oddsratio(wahl2) ### geht nicht oddsratio(wahl2[1:2,]) ### lokaler odds ratio wahl2[1:2,] ### spd gruen ### lokaler odds ratio wahl2[c(2,4),] oddsratio(wahl2[c(2,4),])