Statistics Assignment Solution
Question 1(a)
Factors and the number of levels for each factor indicating any nesting present
Response Variable = Student Test Scores Factor A = School
Factor A Levels = {Lowton, Westleigh, Bedford}, a = 3
Factor B = Teacher (nested within School), b=2 levels per school
Factor B Levels = Lowton -> {T1, T2}, Westleigh -> {T3,T4}, Bedford -> {T5, T6}
Question 1(b)
𝑌𝑖𝑗𝑘 = 𝜇 + 𝛼𝑖 + 𝐵𝑗(𝑖) + 𝜖𝑘(𝑖𝑗)
where 𝐵𝑗(𝑖) ~ 𝑁(0, 𝜎𝐵2), 𝜖𝑘(𝑖𝑗) ~ 𝑁(0, 𝜎2)
And constraint Σ𝛼𝑖=03𝑖=1 for i = 1 to 3, j = 1,2 and k = 1 to 8
Question 1(c)
𝐸[ 𝑌𝑖𝑘𝑗 ] = 𝐸 [ 𝜇 + 𝛼𝑖 + 𝐵𝑗(𝑖) + 𝜖𝑘(𝑖𝑗) ]
= 𝐸 [ 𝜇 ] + 𝐸 [ 𝛼𝑖 ] + 𝐸 [ 𝐵𝑗(𝑖)] + 𝐸 [ 𝜖𝑘(𝑖𝑗) ]
= 𝜇 + 𝛼𝑖 + 0 + 0
= 𝜇 + 𝛼𝑖
= 𝜇𝑖
And
𝑉𝑎𝑟[ 𝑌𝑖𝑘𝑗 ] = 𝑉𝑎𝑟 [ 𝜇 + 𝛼𝑖 + 𝐵𝑗(𝑖) + 𝜖𝑘(𝑖𝑗) ]
= 𝑉𝑎𝑟 [ 𝜇 ] + 𝑉𝑎𝑟 [ 𝛼𝑖 ] + 𝑉𝑎𝑟 [ 𝐵𝑗(𝑖)] + 𝑉𝑎𝑟 [ 𝜖𝑘(𝑖𝑗) ]
= 0 + 0 + 𝜎𝐵2 + 𝜎2
= 𝜎𝐵2 + 𝜎2
, 2
Question 1(d)
> # 1.1a - Read in the 'School.csv' data set
> Sch1a <- read.csv("F:\\Lecture Courses\\STAT 293\\Additional Material\\Assignments &
Tests\\Assignments & Tests Data\\School.csv")
> str(Sch1a)
'data.frame': 48 obs. of 3 variables:
$ School : chr "Lowton" "Lowton" "Lowton" "Lowton" ...
$ Teacher: chr "Teacher1" "Teacher1" "Teacher1" "Teacher1" ...
$ Score : int 89 96 113 100 88 85 91 113 79 90 ...
> # 1.1b - Fitting the model.
> library(nlme)
> Sch1b <- lme(Score ~ School, random=~1|Teacher, data=Sch1a)
> # 1.1c - Obtaining the ANOVA table
> anova(Sch1b)
numDF denDF F-value p-value
(Intercept) 1 42 419.0479 <.0001
School 2 3 9.2664 0.052
Testing the null hypothesis H0: αi = 0 for all i = 1 to 3
Vs H1: αi ≠ 0 for some i = 1 to3
Fobs = 9.2664 and a p-value of 0.052 therefore there is weak evidence against the null
hypothesis.
Question 1(e)
> summary(Sch1b)