Main page: https://www.rdocumentation.org/packages/datasets/versions/3.6.2/topics/warpbreaks
warpbreaks
## breaks wool tension
## 1 26 A L
## 2 30 A L
## 3 54 A L
## 4 25 A L
## 5 70 A L
## 6 52 A L
## 7 51 A L
## 8 26 A L
## 9 67 A L
## 10 18 A M
## 11 21 A M
## 12 29 A M
## 13 17 A M
## 14 12 A M
## 15 18 A M
## 16 35 A M
## 17 30 A M
## 18 36 A M
## 19 36 A H
## 20 21 A H
## 21 24 A H
## 22 18 A H
## 23 10 A H
## 24 43 A H
## 25 28 A H
## 26 15 A H
## 27 26 A H
## 28 27 B L
## 29 14 B L
## 30 29 B L
## 31 19 B L
## 32 29 B L
## 33 31 B L
## 34 41 B L
## 35 20 B L
## 36 44 B L
## 37 42 B M
## 38 26 B M
## 39 19 B M
## 40 16 B M
## 41 39 B M
## 42 28 B M
## 43 21 B M
## 44 39 B M
## 45 29 B M
## 46 20 B H
## 47 21 B H
## 48 24 B H
## 49 17 B H
## 50 13 B H
## 51 15 B H
## 52 15 B H
## 53 16 B H
## 54 28 B H
require(stats); require(graphics)
summary(warpbreaks)
## breaks wool tension
## Min. :10.00 A:27 L:18
## 1st Qu.:18.25 B:27 M:18
## Median :26.00 H:18
## Mean :28.15
## 3rd Qu.:34.00
## Max. :70.00
opar <- par(mfrow = c(1, 2), oma = c(0, 0, 1.1, 0))
plot(breaks ~ tension, data = warpbreaks, col = "lightgray",
varwidth = TRUE, subset = wool == "A", main = "Wool A")
plot(breaks ~ tension, data = warpbreaks, col = "lightgray",
varwidth = TRUE, subset = wool == "B", main = "Wool B")
mtext("warpbreaks data", side = 3, outer = TRUE)
par(opar)
summary(fm1 <- lm(breaks ~ wool*tension, data = warpbreaks))
##
## Call:
## lm(formula = breaks ~ wool * tension, data = warpbreaks)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.5556 -6.8889 -0.6667 7.1944 25.4444
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 44.556 3.647 12.218 2.43e-16 ***
## woolB -16.333 5.157 -3.167 0.002677 **
## tensionM -20.556 5.157 -3.986 0.000228 ***
## tensionH -20.000 5.157 -3.878 0.000320 ***
## woolB:tensionM 21.111 7.294 2.895 0.005698 **
## woolB:tensionH 10.556 7.294 1.447 0.154327
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.94 on 48 degrees of freedom
## Multiple R-squared: 0.3778, Adjusted R-squared: 0.3129
## F-statistic: 5.828 on 5 and 48 DF, p-value: 0.0002772
anova(fm1)
## Analysis of Variance Table
##
## Response: breaks
## Df Sum Sq Mean Sq F value Pr(>F)
## wool 1 450.7 450.67 3.7653 0.0582130 .
## tension 2 2034.3 1017.13 8.4980 0.0006926 ***
## wool:tension 2 1002.8 501.39 4.1891 0.0210442 *
## Residuals 48 5745.1 119.69
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1