remove(list=ls()) #setwd("/Users/michael/Dropbox/Angewandte Statistik SoSe11/Uebungen/Blatt07/R") setwd("/Volumes/MichaelsHD/Dropbox/Angewandte Statistik SoSe11/Uebungen/Blatt07/R") set.seed(23514) #Daten einlesen mango1 <- matrix(scan("./mango1.dat"),ncol=2,byrow=T) mango2 <- matrix(scan("./mango2.dat"),ncol=2,byrow=T) x <- mango1[,1] t <- mango1[,2] z <- mango2[,1] tau <- mango2[,2] #QR1 und QR2 aus den einzelnen Modellen fit1 <- lm(x ~ 1+t) fit2 <- lm(z ~ 1+tau) QR1 <- (summary(fit1)$sigma)^2 * fit1$df QR1 QR2 <- (summary(fit2)$sigma)^2 * fit2$df QR2 #QR berechnen QR <- QR1 + QR2 QR #Modell um QRH0 zu bekommen x0 <- c(x,z) t0 <- c(t,tau) fit0 <- lm(x0 ~ 1+t0) QRH0 <- (summary(fit0)$sigma)^2 * fit0$df QRH0 #Testgroesse V52 berechnen V52 <- (QRH0 - QR)/ QR * (104-4)/2 #95%-Quantil der F(2,48)-Verteilung quant <- qf(0.95,2,104) V52 quant #H0 wird verworfen da V52>quant ##Bonusmaterial:## #p-Wert 1-pf(V52,2,104) #Plot der beiden Datensaetze op <- par(mfrow=c(2,2)) plot(t,x,ylim=c(0,275),xlim=c(0,366)) plot(tau,z,ylim=c(0,275),xlim=c(0,366)) plot(t,x,ylim=c(0,275),xlim=c(0,366)) lines(t,fit1$fit,col=1) lines(tau,fit2$fit,col=2) plot(tau,z,ylim=c(0,275),xlim=c(0,366)) lines(t,fit1$fit,col=2) lines(tau,fit2$fit,col=1) par(op)