1.II.13J

Statistical Modelling
Part II, 2008

Consider performing a two-way analysis of variance (ANOVA) on the following data: >Y[,,1]>\mathrm{Y}[,, 1] Y[,,2]\mathrm{Y}[,, 2] Y[,,3]\mathrm{Y}[,, 3] [,1][,2][, 1] \quad[, 2] [,1][,2][, 1] \quad[, 2] [,1][,2][, 1] \quad[, 2]

Explain and interpret the R commands and (slightly abbreviated) output below. In particular, you should describe the model being fitted, and comment on the hypothesis tests which are performed under the summary and anova commands. >K<dim(Y)[1]>\mathrm{K}<-\operatorname{dim}(\mathrm{Y})[1] >I<dim(Y)[2]>I<-\operatorname{dim}(Y)[2] >J<dim(Y)[3]>\mathrm{J}<-\operatorname{dim}(\mathrm{Y})[3] >C(I,J,K)>\mathrm{C}(\mathrm{I}, \mathrm{J}, \mathrm{K})

[1] 23102 \quad 3 \quad 10

>y<>y<- as.vector (Y)(Y)

>a<gl(I,K>\mathrm{a}<-\mathrm{gl}(\mathrm{I}, \mathrm{K}, length (y))(\mathrm{y}))

>b<gl(J,KI>\mathrm{b}<-\operatorname{gl}(\mathrm{J}, \mathrm{K} * \mathrm{I}, length (y))(\mathrm{y}))

>fit1<lm(ya+b)>f i t 1<-\operatorname{lm}(\mathrm{y} \sim \mathrm{a}+\mathrm{b})

>summary(fit1)>\operatorname{summary}(f i t 1)

Coefficients:

Estimate Std. Error t value Pr(>t)\operatorname{Pr}(>|t|)

(Intercept) 3.76730.303212.43<2e163.7673 \quad 0.3032 \quad 12.43<2 \mathrm{e}-16 * * *

a23.45420.303211.393.27e16\mathrm{a} 2 \quad 3.4542 \quad 0.3032 \quad 11.393 .27 \mathrm{e}-16 * * *

b2 6.3215<0.371317.03<2e16-6.3215<0.3713-17.03<2 \mathrm{e}-16 * * *

b3 5.8268<0.371315.69<2e16-5.8268<0.3713-15.69<2 \mathrm{e}-16 * * *

>anova(fit1)>\operatorname{anova}(\mathrm{fit1})

The following R\mathrm{R} code fits a similar model. Briefly explain the difference between this model and the one above. Based on the output of the anova call below, say whether you prefer this model over the one above, and explain your preference.

Finally, explain what is being calculated in the code below and give the value that would be obtained by the final line of code.