The anaesthetic data provides the time to restart breathing unassisted in recovering from general anaesthetic for four treatment groups. Produce a boxplot depicting the data. Comment on any features of interest.

library(faraway) 
data(anaesthetic) 
anaesthetic
##    breath tgrp
## 1       3    A
## 2       6    B
## 3       3    C
## 4       4    D
## 5       2    A
## 6       4    B
## 7       5    C
## 8       8    D
## 9       1    A
## 10      1    B
## 11      2    C
## 12      2    D
## 13      4    A
## 14      1    B
## 15      4    C
## 16      3    D
## 17      3    A
## 18      6    B
## 19      2    C
## 20      2    D
## 21      2    A
## 22      2    B
## 23      1    C
## 24      3    D
## 25     10    A
## 26      1    B
## 27      6    C
## 28      6    D
## 29     12    A
## 30     10    B
## 31     13    C
## 32      2    D
## 33     12    A
## 34      1    B
## 35      1    C
## 36      3    D
## 37      3    A
## 38      1    B
## 39      1    C
## 40      4    D
## 41     19    A
## 42      1    B
## 43      1    C
## 44      8    D
## 45      1    A
## 46      2    B
## 47      4    C
## 48      5    D
## 49      4    A
## 50     10    B
## 51      1    C
## 52     10    D
## 53      5    A
## 54      2    B
## 55      1    C
## 56      2    D
## 57      1    A
## 58      2    B
## 59      1    C
## 60      0    D
## 61      1    A
## 62      2    B
## 63      8    C
## 64     10    D
## 65      7    A
## 66      2    B
## 67      1    C
## 68      2    D
## 69      5    A
## 70      1    B
## 71      2    C
## 72      3    D
## 73      1    A
## 74      3    B
## 75      4    C
## 76      9    D
## 77     12    A
## 78      7    B
## 79      0    C
## 80      1    D
plot(breath ~ tgrp, data=anaesthetic,ylab="Time (min)")

stripchart(breath ~ tgrp, data=anaesthetic, vertical=TRUE, method="stack",
xlab="Group Subject to Treatment",ylab="Time (min)")

For group B, the median and lower tertile.

Fit a one-factor model for the recovery times. Which pairs of treatments are different?

lmod<-lm(breath ~ tgrp,anaesthetic)
sumary(lmod)
##             Estimate Std. Error t value  Pr(>|t|)
## (Intercept)  5.40000    0.81598  6.6178 4.567e-09
## tgrpB       -2.15000    1.15397 -1.8631   0.06631
## tgrpC       -2.35000    1.15397 -2.0364   0.04519
## tgrpD       -1.05000    1.15397 -0.9099   0.36575
## 
## n = 80, p = 4, Residual SE = 3.64917, R-Squared = 0.07
round(coef(lmod),1)
## (Intercept)       tgrpB       tgrpC       tgrpD 
##         5.4        -2.2        -2.4        -1.1
model.matrix(lmod)
##    (Intercept) tgrpB tgrpC tgrpD
## 1            1     0     0     0
## 2            1     1     0     0
## 3            1     0     1     0
## 4            1     0     0     1
## 5            1     0     0     0
## 6            1     1     0     0
## 7            1     0     1     0
## 8            1     0     0     1
## 9            1     0     0     0
## 10           1     1     0     0
## 11           1     0     1     0
## 12           1     0     0     1
## 13           1     0     0     0
## 14           1     1     0     0
## 15           1     0     1     0
## 16           1     0     0     1
## 17           1     0     0     0
## 18           1     1     0     0
## 19           1     0     1     0
## 20           1     0     0     1
## 21           1     0     0     0
## 22           1     1     0     0
## 23           1     0     1     0
## 24           1     0     0     1
## 25           1     0     0     0
## 26           1     1     0     0
## 27           1     0     1     0
## 28           1     0     0     1
## 29           1     0     0     0
## 30           1     1     0     0
## 31           1     0     1     0
## 32           1     0     0     1
## 33           1     0     0     0
## 34           1     1     0     0
## 35           1     0     1     0
## 36           1     0     0     1
## 37           1     0     0     0
## 38           1     1     0     0
## 39           1     0     1     0
## 40           1     0     0     1
## 41           1     0     0     0
## 42           1     1     0     0
## 43           1     0     1     0
## 44           1     0     0     1
## 45           1     0     0     0
## 46           1     1     0     0
## 47           1     0     1     0
## 48           1     0     0     1
## 49           1     0     0     0
## 50           1     1     0     0
## 51           1     0     1     0
## 52           1     0     0     1
## 53           1     0     0     0
## 54           1     1     0     0
## 55           1     0     1     0
## 56           1     0     0     1
## 57           1     0     0     0
## 58           1     1     0     0
## 59           1     0     1     0
## 60           1     0     0     1
## 61           1     0     0     0
## 62           1     1     0     0
## 63           1     0     1     0
## 64           1     0     0     1
## 65           1     0     0     0
## 66           1     1     0     0
## 67           1     0     1     0
## 68           1     0     0     1
## 69           1     0     0     0
## 70           1     1     0     0
## 71           1     0     1     0
## 72           1     0     0     1
## 73           1     0     0     0
## 74           1     1     0     0
## 75           1     0     1     0
## 76           1     0     0     1
## 77           1     0     0     0
## 78           1     1     0     0
## 79           1     0     1     0
## 80           1     0     0     1
## attr(,"assign")
## [1] 0 1 1 1
## attr(,"contrasts")
## attr(,"contrasts")$tgrp
## [1] "contr.treatment"
anova(lmod)
## Analysis of Variance Table
## 
## Response: breath
##           Df  Sum Sq Mean Sq F value Pr(>F)
## tgrp       3   70.94  23.646  1.7757 0.1589
## Residuals 76 1012.05  13.316

no treatments are really different.

Try the Box-Cox transformation method. Explain what went wrong.

require(MASS)
## Loading required package: MASS
library(faraway) 
data(anaesthetic) 
#lmod<-lm(breath ~ tgrp,anaesthetic)
#boxcox(lmod,plotit=T)

It did not run successfully as the response variable is not positive.

Try a square root transformation on the response. Are the diagnostics satisfactory? Is there a significant difference among treatment groups?

plot(fitted(lmod),residuals(lmod),xlab="Fitted",ylab="Residuals")
abline(h=0)

plot(fitted(lmod),sqrt(abs(residuals(lmod))), xlab="Fitted",ylab=
expression(sqrt(hat(epsilon))))

sumary(lm(sqrt(abs(residuals(lmod))) ~ fitted(lmod)))
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept)   0.82561    0.28636  2.8831 0.005087
## fitted(lmod)  0.18188    0.06948  2.6177 0.010628
## 
## n = 80, p = 2, Residual SE = 0.58519, R-Squared = 0.08

There is no significant difference between the treatments.