Beispiel: Funktionsdauer von Batterien in Abhängigkeit des verwendeten aterials und der Umgebungstemperatur emp. = 15 emp. = 70 emp. = 125 130 155 34 40 20 70 aterial 1 74 180 80 75 82 58 150 188 136 122 25 70 aterial 2 159 126 106 115 58 45 138 110 174 120 96 104 aterial 3 168 160 150 139 82 60 > battery.df <- read.table(file="c:\\daten\\battery.txt", header =) > attach(battery.df) > battery.df hours 1 1 1 130 2 1 1 155 3 1 1 74 4 1 1 180 5 1 2 34 27 3 1 110 28 3 1 160 29 3 2 174 30 3 2 120 31 3 2 150 32 3 2 139 33 3 3 96 34 3 3 82 35 3 3 104 36 3 3 60 > [1] 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 3 [26] 3 3 3 3 3 3 3 3 3 3 3 Levels: 1 2 3 > [1] 1 1 1 1 2 2 2 2 3 3 3 3 1 1 1 1 2 2 2 2 3 3 3 3 1 [26] 1 1 1 2 2 2 2 3 3 3 3 Levels: 1 2 3 > is.vector() [1] FALSE > is.factor() [1] RUE arcus Hudec 1 01 2007
Deskriptive Analysen > mean.mat <- tapply(hours, list(, ), mean) > > mean.mat <- cbind(mean.mat, apply(mean.mat, 1, mean)) > mean.mat <- rbind(mean.mat, apply(mean.mat, 2, mean)) > mean.mat 1 2 3 1 134.7500 57.2500 57.50000 83.16667 2 155.7500 119.7500 49.50000 108.33333 3 144.0000 145.7500 85.50000 125.08333 144.8333 107.5833 64.16667 105.52778 par(mfrow=c(1,2)) plot(hours~ +) hours 50 100 150 hours 50 100 150 1 2 3 1 2 3 plot.design(hours ~ +, ylim=c(60,160)) plot.design(hours ~ +, ylim=c(60,160), fun=median) arcus Hudec 2 01 2007
mean of hours 60 80 100 120 140 160 3 2 1 1 2 3 Factors median of hours 60 80 100 120 140 160 3 2 1 1 2 3 Factors arcus Hudec 3 01 2007
interaction.plot(,, hours, ylim=c(20,160)) win.graph() interaction.plot(,, hours, median, ylim=c(20,160)) win.graph() interaction.plot(,, hours, ylim=c(20,160)) win.graph() interaction.plot(,, hours, median, ylim=c(20,160)) mean of hours 20 40 60 80 100 120 140 160 2 1 3 1 2 3 arcus Hudec 4 01 2007
median of hours 20 40 60 80 100 120 140 160 1 2 3 1 2 3 mean of hours 20 40 60 80 100 120 140 160 3 1 2 1 2 3 arcus Hudec 5 01 2007
median of hours 20 40 60 80 100 120 140 160 3 1 2 1 2 3 arcus Hudec 6 01 2007
Allgemeine Datenstruktur: Zwei Faktoren A und B mit a und b verschiedenen Kategorien A1 A2 Ai Aa B1 B2 Bj Bb y 111 y 11n11 y.1 y.2 y ij1 y ijnij y. j y.b y 1. y 2. y i. y a. y.. i = 1,, a j = 1,, b Wichtigster Spezialfall: n ij = const.=n y = µ + α + β + ( αβ) + ε = µ + ε ijk i j ij ijk ij ijk E( y ) = µ = µ + α + β + ( αβ) ijk ij i j ij ε α = 0 β = 0 ( αβ) = ( αβ) = 0 i j ij ij i j i j 2 ijk N(0, σ ) B1 B2 Bj Bb A1 A2 y 11 y 1. y 2. Ai y ij y i. Aa y.1 y.2 y ab y. j y.b y a. y.. arcus Hudec 7 01 2007
Varianzanalytische Zerlegung: Source of Sum of degrees of ean Squares Variation Squares freedom reatment A SSA a-1 SA=SSA/(a-1) reatment B SSB b-1 SB=SSB/(b-1) AB Interaction SSAB (a-1)(b-1) SAB=SSAB/((a-1)(b-1)) Error SSE ab(n-1). SE=SSE/k(n-1) otal SS abn-1 k SSA = bn ( y y ) i= 1 i... k 2 SSAB = n ( yij y.. ) SSA SSB i= 1 SS = ( y y ) i j k ijk 2.. 2 k SSB = an ( y y ) i= 1. j.. SSE = ( y y ) i j k ijk 2 ij 2 > contrasts() 2 3 1 0 0 2 1 0 3 0 1 > contrasts() 2 3 1 0 0 2 1 0 3 0 1 arcus Hudec 8 01 2007
> model.matrix(hours~*) (Intercept) 2 3 2 3 2:2 3:2 2:3 3:3 1 1 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 0 3 1 0 0 0 0 0 0 0 0 4 1 0 0 0 0 0 0 0 0 5 1 1 0 0 0 0 0 0 0 6 1 1 0 0 0 0 0 0 0 7 1 1 0 0 0 0 0 0 0 8 1 1 0 0 0 0 0 0 0 9 1 0 1 0 0 0 0 0 0 10 1 0 1 0 0 0 0 0 0 11 1 0 1 0 0 0 0 0 0 12 1 0 1 0 0 0 0 0 0 13 1 0 0 1 0 0 0 0 0 14 1 0 0 1 0 0 0 0 0 15 1 0 0 1 0 0 0 0 0 16 1 0 0 1 0 0 0 0 0 17 1 1 0 1 0 1 0 0 0 18 1 1 0 1 0 1 0 0 0 19 1 1 0 1 0 1 0 0 0 20 1 1 0 1 0 1 0 0 0 21 1 0 1 1 0 0 1 0 0 22 1 0 1 1 0 0 1 0 0 23 1 0 1 1 0 0 1 0 0 24 1 0 1 1 0 0 1 0 0 25 1 0 0 0 1 0 0 0 0 26 1 0 0 0 1 0 0 0 0 27 1 0 0 0 1 0 0 0 0 28 1 0 0 0 1 0 0 0 0 29 1 1 0 0 1 0 0 1 0 30 1 1 0 0 1 0 0 1 0 31 1 1 0 0 1 0 0 1 0 32 1 1 0 0 1 0 0 1 0 33 1 0 1 0 1 0 0 0 1 34 1 0 1 0 1 0 0 0 1 35 1 0 1 0 1 0 0 0 1 36 1 0 1 0 1 0 0 0 1 arcus Hudec 9 01 2007
> fit.treat.add<-aov(hours~+) > > summary(fit.treat.add) Df Sum Sq ean Sq F value Pr(>F) 2 39119 19559 21.7759 1.239e-06 *** 2 10684 5342 5.9472 0.006515 ** Residuals 31 27845 898 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > anova(fit.treat.add) Analysis of Variance able Response: hours Df Sum Sq ean Sq F value Pr(>F) 2 39119 19559 21.7759 1.239e-06 *** 2 10684 5342 5.9472 0.006515 ** Residuals 31 27845 898 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > coefficients(fit.treat.add) (Intercept) 2 3 2 3 122.47222-37.25000-80.66667 25.16667 41.91667 > tapply(fitted(fit.treat.add), list(,), mean) 1 2 3 1 122.47222 147.63889 164.38889 2 85.22222 110.38889 127.13889 3 41.80556 66.97222 83.72222 > interaction.plot(,, fitted(fit.treat.add)) arcus Hudec 10 01 2007
mean of fitted(fit.treat.add) 40 60 80 100 120 140 160 3 2 1 Effekt der Orthogonalität: 1 2 3 > aov(hours~+) Call: aov(formula = hours ~ + ) erms: Residuals Sum of Squares 10683.72 39118.72 27844.53 Deg. of Freedom 2 2 31 Residual standard error: 29.97016 Estimated effects may be unbalanced > aov(hours~+) Call: aov(formula = hours ~ + ) erms: Residuals Sum of Squares 39118.72 10683.72 27844.53 Deg. of Freedom 2 2 31 arcus Hudec 11 01 2007
> aov(hours~) Call: aov(formula = hours ~ ) erms: Residuals Sum of Squares 10683.72 66963.25 Deg. of Freedom 2 33 Residual standard error: 45.04652 Estimated effects may be unbalanced > aov(hours~) Call: aov(formula = hours ~ ) erms: Residuals Sum of Squares 39118.72 38528.25 Deg. of Freedom 2 33 Residual standard error: 34.16903 Estimated effects may be unbalanced > Schätzung mit Interaktionseffekten > fit.treat<-aov(hours~*) > summary(fit.treat) Df Sum Sq ean Sq F value Pr(>F) 2 39119 19559 28.9677 1.909e-07 *** 2 10684 5342 7.9114 0.001976 ** : 4 9614 2403 3.5595 0.018611 * Residuals 27 18231 675 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > anova(fit.treat) Analysis of Variance able Response: hours Df Sum Sq ean Sq F value Pr(>F) 2 39119 19559 28.9677 1.909e-07 *** 2 10684 5342 7.9114 0.001976 ** : 4 9614 2403 3.5595 0.018611 * Residuals 27 18231 675 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 arcus Hudec 12 01 2007
> coefficients(fit.treat) (Intercept) 2 3 2 3 2:2 134.75-77.50-77.25 21.00 9.25 41.50 3:2 2:3 3:3-29.00 79.25 18.75 > tapply(fitted(fit.treat), list(,), mean) 1 2 3 1 134.75 155.75 144.00 2 57.25 119.75 145.75 3 57.50 49.50 85.50 > interaction.plot(,, fitted(fit.treat)) > mean of fitted(fit.treat) 60 80 100 120 140 160 3 1 2 1 2 3 > options(contrasts=c("contr.sum", "contr.poly")) > > contrasts() [,1] [,2] > contrasts() [,1] [,2] 1 1 0 1 1 0 2 0 1 2 0 1 3-1 -1 3-1 -1 arcus Hudec 13 01 2007
> model.matrix(hours~*) (Intercept) 1 2 1 2 1:1 2:1 1:2 2:2 1 1 1 0 1 0 1 0 0 0 2 1 1 0 1 0 1 0 0 0 3 1 1 0 1 0 1 0 0 0 4 1 1 0 1 0 1 0 0 0 5 1 0 1 1 0 0 1 0 0 6 1 0 1 1 0 0 1 0 0 7 1 0 1 1 0 0 1 0 0 8 1 0 1 1 0 0 1 0 0 9 1-1 -1 1 0-1 -1 0 0 10 1-1 -1 1 0-1 -1 0 0 11 1-1 -1 1 0-1 -1 0 0 12 1-1 -1 1 0-1 -1 0 0 13 1 1 0 0 1 0 0 1 0 14 1 1 0 0 1 0 0 1 0 15 1 1 0 0 1 0 0 1 0 16 1 1 0 0 1 0 0 1 0 17 1 0 1 0 1 0 0 0 1 18 1 0 1 0 1 0 0 0 1 19 1 0 1 0 1 0 0 0 1 20 1 0 1 0 1 0 0 0 1 21 1-1 -1 0 1 0 0-1 -1 22 1-1 -1 0 1 0 0-1 -1 23 1-1 -1 0 1 0 0-1 -1 24 1-1 -1 0 1 0 0-1 -1 25 1 1 0-1 -1-1 0-1 0 26 1 1 0-1 -1-1 0-1 0 27 1 1 0-1 -1-1 0-1 0 28 1 1 0-1 -1-1 0-1 0 29 1 0 1-1 -1 0-1 0-1 30 1 0 1-1 -1 0-1 0-1 31 1 0 1-1 -1 0-1 0-1 32 1 0 1-1 -1 0-1 0-1 33 1-1 -1-1 -1 1 1 1 1 34 1-1 -1-1 -1 1 1 1 1 35 1-1 -1-1 -1 1 1 1 1 36 1-1 -1-1 -1 1 1 1 1 > fit.sum<-aov(hours~*) > summary(fit.sum) Df Sum Sq ean Sq F value Pr(>F) 2 39119 19559 28.9677 1.909e-07 *** 2 10684 5342 7.9114 0.001976 ** : 4 9614 2403 3.5595 0.018611 * Residuals 27 18231 675 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 arcus Hudec 14 01 2007
> anova(fit.sum) Analysis of Variance able Response: hours Df Sum Sq ean Sq F value Pr(>F) 2 39119 19559 28.9677 1.909e-07 *** 2 10684 5342 7.9114 0.001976 ** : 4 9614 2403 3.5595 0.018611 * Residuals 27 18231 675 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > coefficients(fit.sum) (Intercept) 1 2 1 2 1:1 105.527778 39.305556 2.055556-22.361111 2.805556 12.277778 2:1 1:2 2:2-27.972222 8.111111 9.361111 > options(contrasts=c("contr.helmert", "contr.poly")) > contrasts() [,1] [,2] 1-1 -1 2 1-1 3 0 2 > contrasts() [,1] [,2] 1-1 -1 2 1-1 3 0 2 arcus Hudec 15 01 2007
> tapply(fitted(fit.treat), list(,), mean) 1 2 3 1 134.75 155.75 144.00 2 57.25 119.75 145.75 3 57.50 49.50 85.50 > model.tables(fit.treat) ables of effects 1 2 3 39.31 2.056-41.36 rep 12.00 12.000 12.00 1 2 3-22.36 2.806 19.56 rep 12.00 12.000 12.00 : 1 2 3 1 12.278 8.111-20.389 rep 4.000 4.000 4.000 2-27.972 9.361 18.611 rep 4.000 4.000 4.000 3 15.694-17.472 1.778 rep 4.000 4.000 4.000 > model.tables(fit.sum) ables of effects 1 2 3 39.31 2.056-41.36 rep 12.00 12.000 12.00 1 2 3-22.36 2.806 19.56 rep 12.00 12.000 12.00 : 1 2 3 1 12.278 8.111-20.389 rep 4.000 4.000 4.000 2-27.972 9.361 18.611 rep 4.000 4.000 4.000 3 15.694-17.472 1.778 rep 4.000 4.000 4.000 > arcus Hudec 16 01 2007