#### Stochastik IV, Übungsblatt 7 ### Aufgabe 3 library(ellipse) # Einlesen und Auswahl der Daten und Einbinden in Suchpfad data.crabs <- read.table("D:/Univ Augsburg/Lehre/SS07/VO_MultiVar/Datensaetze/crabs.txt", head = TRUE, sep = "\t", quote = "") crabs.bl <- subset(data.crabs, sp == 1) attach(crabs.bl) # Scatterplot plot(FL, RW, main = "Scatterplot mit 95%-Konfidenzellipsen", xlim = c(6, 23), ylim = c(6, 19), pch = sex, col = sex, cex = 1.5) ## Teilaufgabe (a) lines(ellipse(cov(cbind(FL[sex == 1], RW[sex == 1])), centre = c(mean(FL[sex == 1]), mean(RW[sex == 1])), level = 0.95), col = 1, lwd = 2) lines(ellipse(cov(cbind(FL[sex == 2], RW[sex == 2])), centre = c(mean(FL[sex == 2]), mean(RW[sex == 2])), level = 0.95), col = 2, lwd = 2) ## Teilaufgabe (b) cov.pooled <- (( cov(cbind(FL[sex == 1], RW[sex == 1])) + cov(cbind(FL[sex == 2], RW[sex == 2])) ) / 2) lines(ellipse(cov.pooled, centre = c(mean(FL[sex == 1]), mean(RW[sex == 1])), level = 0.95), col = 1, lty = 2, lwd = 2) lines(ellipse(cov.pooled, centre = c(mean(FL[sex == 2]), mean(RW[sex == 2])), level = 0.95), col = 2, lty = 2, lwd = 2) ## Teilaufgabe (c) lines(ellipse(cov(cbind(FL, RW)), centre = c(mean(FL), mean(RW)), level = 0.95), col = 3, lwd = 2) # Legende legend( 14, 9, lty = c(1, 1, 2, 2, 1), col = c(1, 2, 1, 2, 3), c("Teilaufgabe (a): Blue Male", "Teilaufgabe (a): Blue Female", "Teilaufgabe (b): Blue Male", "Teilaufgabe (b): Blue Female", "Teilaufgabe (c): Blue Male AND Female") )