Question 1
Part 1 The design of the experiment is a within-subjects , randmized block, design where s crosses a fixed variable P. s,P.
Part 2
L5Q1a=read.table('Lab5Q1data',header=TRUE)
L5Q1aov=aov(Perf ~ P+Error(Sub/P), data=L5Q1a)
print(L5Q1aov)
##
## Call:
## aov(formula = Perf ~ P + Error(Sub/P), data = L5Q1a)
##
## Grand Mean: 9.6875
##
## Stratum 1: Sub
##
## Terms:
## Residuals
## Sum of Squares 417.375
## Deg. of Freedom 7
##
## Residual standard error: 7.721723
##
## Stratum 2: Sub:P
##
## Terms:
## P Residuals
## Sum of Squares 231.125 78.375
## Deg. of Freedom 3 21
##
## Residual standard error: 1.931875
## Estimated effects may be unbalanced
L5Q1.sum=summary(L5Q1aov)
boxplot(Perf ~ P, data=L5Q1a)
L5Q1sum=unlist(L5Q1.sum)
structure(L5Q1sum)
## Error: Sub.Df Error: Sub.Sum Sq Error: Sub.Mean Sq
## 7.000000e+00 4.173750e+02 5.962500e+01
## Error: Sub.F value Error: Sub.Pr(>F) Error: Sub:P.Df1
## NA NA 3.000000e+00
## Error: Sub:P.Df2 Error: Sub:P.Sum Sq1 Error: Sub:P.Sum Sq2
## 2.100000e+01 2.311250e+02 7.837500e+01
## Error: Sub:P.Mean Sq1 Error: Sub:P.Mean Sq2 Error: Sub:P.F value1
## 7.704167e+01 3.732143e+00 2.064274e+01
## Error: Sub:P.F value2 Error: Sub:P.Pr(>F)1 Error: Sub:P.Pr(>F)2
## NA 1.810836e-06 NA
L5Q1.aovtbl=model.tables(L5Q1aov, type='means')
L5Q1aovtbl=unlist(L5Q1.aovtbl)
df1=as.numeric(L5Q1sum['Error: Sub:P.Df1'])
df2=as.numeric(L5Q1sum['Error: Sub:P.Df2'])
SS1=as.numeric(L5Q1sum['Error: Sub:P.Sum Sq1'])
SS2=as.numeric(L5Q1sum['Error: Sub:P.Sum Sq2'])
MS1=as.numeric(L5Q1sum['Error: Sub:P.Mean Sq1'])
MS2=as.numeric(L5Q1sum['Error: Sub:P.Mean Sq2'])
F1=as.numeric(L5Q1sum['Error: Sub:P.F value1'])
P1=as.numeric(L5Q1sum['Error: Sub:P.Pr(>F)1'])
GM1=as.numeric(L5Q1aovtbl['tables.Grand mean'])
Mp1=as.numeric(L5Q1aovtbl['tables.P.p1'])
Mp2=as.numeric(L5Q1aovtbl['tables.P.p2'])
Mp3=as.numeric(L5Q1aovtbl['tables.P.p3'])
Mp4=as.numeric(L5Q1aovtbl['tables.P.p4'])
options(digits=2)
Part 3 There was a significant interaction of the 4 different memory test conditions,P, using an alpha p level of 0.05, F(3,21)=20.64, MSe=3.73, p=1.8110^{-6}, Sum Sq=231.13. There was a Grand Mean of 9.69, with the first memory test having a mean on 13.13, the second 11.5, the third 7.13, and finally the fouth memory test having a mean of 7
Part 4 According to beckers 0-1-k rule suggest that the error should be the type II residual error because the P value crosses one random variable s. The aov did use the Type II error. It broke it into two different types and the one that had the residual error that used P was the type II error. MsE P
Part 5 Variables->s, P Interactions->s, P, s.P
df s->(8-1)=7 P->(4-1)=3 s.P->(8-1)(4-1)=21
EMS s->(P)s + s.P P->(s)P + s.P s.P->s.P
MS(P)=77.04 MSE(s.P)=3.73
MS(p)/MSE(s.P)=F(df(p), df(s.P))
CF1=77.04/3.73
F(3, 21)=20.65 Which is the same as the given F value 20.64 from the aov output.
Question 2
Part 1 This is a completely randomized design with the random variable o completely nested within A. o(A).
Part 2
L5Q2=read.table('Lab5Q2data',header=TRUE)
L5Q2aov=aov(Perf ~ A+Error(o), data=L5Q2)
print(L5Q2aov)
##
## Call:
## aov(formula = Perf ~ A + Error(o), data = L5Q2)
##
## Grand Mean: 9.7
##
## Stratum 1: o
##
## Terms:
## A Residuals
## Sum of Squares 231 496
## Deg. of Freedom 3 28
##
## Residual standard error: 4.2
## Estimated effects may be unbalanced
L5Q2.sum=summary(L5Q2aov)
boxplot(Perf ~ A, data=L5Q2)
L5Q2sum=unlist(L5Q2.sum)
structure(L5Q2sum)
## Error: o.Df1 Error: o.Df2 Error: o.Sum Sq1 Error: o.Sum Sq2
## 3.000 28.000 231.125 495.750
## Error: o.Mean Sq1 Error: o.Mean Sq2 Error: o.F value1 Error: o.F value2
## 77.042 17.705 4.351 NA
## Error: o.Pr(>F)1 Error: o.Pr(>F)2
## 0.012 NA
L5Q2.aovtbl=model.tables(L5Q2aov, type='means')
L5Q2aovtbl=unlist(L5Q2.aovtbl)
df21=as.numeric(L5Q2sum['Error: o.Df1'])
df22=as.numeric(L5Q2sum['Error: o.Df2'])
SS21=as.numeric(L5Q2sum['Error: o.Sum Sq1'])
SS22=as.numeric(L5Q2sum['Error: o.Sum Sq2'])
MS21=as.numeric(L5Q2sum['Error: o.Mean Sq1'])
MS22=as.numeric(L5Q2sum['Error: o.Mean Sq2'])
F21=as.numeric(L5Q2sum['Error: o.F value1'])
P21=as.numeric(L5Q2sum['Error: o.Pr(>F)1'])
GM21=as.numeric(L5Q2aovtbl['tables.Grand mean'])
Ma21=as.numeric(L5Q2aovtbl['tables.A.a1'])
Ma22=as.numeric(L5Q2aovtbl['tables.A.a2'])
Ma23=as.numeric(L5Q2aovtbl['tables.A.a3'])
Ma24=as.numeric(L5Q2aovtbl['tables.A.a4'])
options(digits=2)
Part 3 There is a significant intereation of A, F(3,28)=4.35, p=0.01, MSe=17.71, Sum Sq=231.13. The grand mean is 9.69.
Part 4 According to Becker’s 0-1-k the vaible A crossed 1 ranom variable o, so you would se the type II residual error. I think it looks like the aov used the Type I residual error in this case.
Part 5 Variables->o, A Interaction ->o, A, o.A Nesting->o/A, A, A.o/A
df A->(4-1)=3 o/A->(8-1)4=2401
EMS A->(o)A, +o/A o/A->o/A
MS(A)=77.04 MSE(s.P)=17.71
MS(A)/MSE(o/A)=F(df(A), df(o/A))
CF2=77.04/17.71
F(3, 28)=4.35 Which is the same as the given F value 4.35 from the aov output.
Question 3
Part 1 The fixed subjects are crossed S,P,o(P)
L5Q3=read.table('Lab5Q3data',header=TRUE)
L5Q3aov=aov(Perf ~ P*Sub+Error(O), data=L5Q3)
print(L5Q3aov)
##
## Call:
## aov(formula = Perf ~ P * Sub + Error(O), data = L5Q3)
##
## Grand Mean: 9.7
##
## Stratum 1: O
##
## Terms:
## P Sub P:Sub
## Sum of Squares 231 417 78
## Deg. of Freedom 3 7 21
##
## Estimated effects may be unbalanced
L5Q3.sum=summary(L5Q3aov)
boxplot(Perf ~ P*Sub, data=L5Q3)
L5Q3sum=unlist(L5Q3.sum)
structure(L5Q3sum)
## Error: O.Df1 Error: O.Df2 Error: O.Df3 Error: O.Sum Sq1
## 3.0 7.0 21.0 231.1
## Error: O.Sum Sq2 Error: O.Sum Sq3 Error: O.Mean Sq1 Error: O.Mean Sq2
## 417.4 78.4 77.0 59.6
## Error: O.Mean Sq3
## 3.7
L5Q3.aovtbl=model.tables(L5Q3aov, type='means')
L5Q3aovtbl=unlist(L5Q3.aovtbl)
df31=as.numeric(L5Q3sum['Error: O.Df1'])
df32=as.numeric(L5Q3sum['Error: O.Df2'])
SS31=as.numeric(L5Q3sum['Error: O.Sum Sq1'])
SS32=as.numeric(L5Q3sum['Error: O.Sum Sq2'])
MS31=as.numeric(L5Q3sum['Error: O.Mean Sq1'])
MS32=as.numeric(L5Q3sum['Error: O.Mean Sq2'])
F31=as.numeric(L5Q3sum['Error: O.F value1'])
P31=as.numeric(L5Q3sum['Error: O.Pr(>F)1'])
GM31=as.numeric(L5Q3aovtbl['tables.Grand mean'])
options(digits=2)
Part 3 I don’t know what happened with this question…. F(3,7)=NA, MSe=59.62, p=NA. Sum Sq=231.13. Grand Mean of 9.69.
Part 4 Beckers 0-1-k rule suggest that, for the interaction of S.P, seeing as there are no random variables, the error should be a Type I error. For the interection of S.o/P, S crosses one random variable, o, so it should use the Type II error.
Part 5 Variables->S, P, o Interactions -> S, P, o, S.P, S.o, P.o, S.P.o Nesting-> S, P, o/P, S.P, S.o/P, P.o/P, S.P.o/P
df S->(8-1)=7 P->(4-1)=3 o/P->(8-1)4=2401 s.P->(8-1)(4-1)=21 S.o/P->(8-1)(8-1)4=16807
EMS s->(p)(o)S + (o)S.P + S.o/P P->(s)(o)P + (s)o/P + (o)s.P + s.o/P o/P->(s)o/P + s.o/P s.P->(o)s.P + s.o/P s.o/P->s.o/P
Question 3 is different from question 2 is that in question 2 we ignored subjects altogether. In Question 3 we included subjects as a fixed variable in the analysis.
Question 4
Part 1 This is a two way, within-subject, randomized block design. s,Q, P(Q)
Part 2
L5Q4=read.table('Lab5Q4data',header=TRUE)
L5Q4aov=aov(Perf ~ P%in%Q+Error(Sub/Q), data=L5Q4)
print(L5Q4aov)
##
## Call:
## aov(formula = Perf ~ P %in% Q + Error(Sub/Q), data = L5Q4)
##
## Grand Mean: 9.7
##
## Stratum 1: Sub
##
## Terms:
## Residuals
## Sum of Squares 417
## Deg. of Freedom 7
##
## Residual standard error: 7.7
##
## Stratum 2: Sub:Q
##
## Terms:
## P:Q Residuals
## Sum of Squares 221 46
## Deg. of Freedom 1 7
##
## Residual standard error: 2.6
## 3 out of 4 effects not estimable
## Estimated effects are balanced
##
## Stratum 3: Within
##
## Terms:
## P:Q Residuals
## Sum of Squares 11 32
## Deg. of Freedom 2 14
##
## Residual standard error: 1.5
## 2 out of 4 effects not estimable
## Estimated effects are balanced
L5Q4.sum=summary(L5Q4aov)
boxplot(Perf ~ P%in%Q, data=L5Q4)
L5Q4sum=unlist(L5Q4.sum)
structure(L5Q4sum)
## Error: Sub.Df Error: Sub.Sum Sq Error: Sub.Mean Sq
## 7.0e+00 4.2e+02 6.0e+01
## Error: Sub.F value Error: Sub.Pr(>F) Error: Sub:Q.Df1
## NA NA 1.0e+00
## Error: Sub:Q.Df2 Error: Sub:Q.Sum Sq1 Error: Sub:Q.Sum Sq2
## 7.0e+00 2.2e+02 4.6e+01
## Error: Sub:Q.Mean Sq1 Error: Sub:Q.Mean Sq2 Error: Sub:Q.F value1
## 2.2e+02 6.6e+00 3.4e+01
## Error: Sub:Q.F value2 Error: Sub:Q.Pr(>F)1 Error: Sub:Q.Pr(>F)2
## NA 6.7e-04 NA
## Error: Within.Df1 Error: Within.Df2 Error: Within.Sum Sq1
## 2.0e+00 1.4e+01 1.1e+01
## Error: Within.Sum Sq2 Error: Within.Mean Sq1 Error: Within.Mean Sq2
## 3.2e+01 5.3e+00 2.3e+00
## Error: Within.F value1 Error: Within.F value2 Error: Within.Pr(>F)1
## 2.3e+00 NA 1.4e-01
## Error: Within.Pr(>F)2
## NA
L5Q4.aovtbl=model.tables(L5Q4aov, type='means')
## Warning in seq_len(x): first element used of 'length.out' argument
## Warning in any(efficiency): coercing argument of type 'double' to logical
L5Q4aovtbl=unlist(L5Q4.aovtbl)
df41=as.numeric(L5Q4sum['Error: Sub:Q.Df1'])
df42=as.numeric(L5Q4sum['Error: Sub:Q.Df2'])
SS41=as.numeric(L5Q4sum['Error: Sub:Q.Sum Sq1'])
SS42=as.numeric(L5Q4sum['Error: Sub:Q.Sum Sq2'])
MS41=as.numeric(L5Q4sum['Error: Sub:Q.Mean Sq1'])
MS42=as.numeric(L5Q4sum['Error: Sub:Q.Mean Sq2'])
F41=as.numeric(L5Q4sum['Error: Sub:Q.F value1'])
P41=as.numeric(L5Q4sum['Error: Sub:Q.Pr(>F)1'])
GM41=as.numeric(L5Q4aovtbl['tables.Grand mean'])
options(digits=2)
Part 3 There is a significant intereraction of Q, the two different types of memory tests, with the first test type, Q1 showing higher results than the second test type, Q2. F(1,7)=33.55, MSe=6.57, p=6.6910^{-4}. Sum Sq=220.5. Grand Mean of 9.69.
Part 4 According to beckers 0-1-k rule, for the intereaction of s.Q, Q crosses one random variablem so you should use the Type II error. For the intereaction of s.P/Q, P crosses one random ariable, s, so it should also use the Type II error. Which I do believe that the aov used.
Part 5 Variables->s, P, Q Interactions->s, P, Q, s.P, s.Q, P.Q, s.P.Q Nesting->s, p/Q, Q, s.P/Q, s.Q, Q.P/Q, S.Q.P/Q*
df s->(8-1)=7 P/Q->(4-1)2=9 Q->(2-1)=1 s.P/Q->(8-1)(4-1)2=63 s.Q->(8-1)(2-1)=7
EMS s->(p)(q)s + (p)s.Q+ s.P/Q P/Q->(s)P/Q + s.P/Q Q->(s)(p)Q + (s)P/Q + (p)s.Q + s.P/Q s.P/Q->s.P/Q s.Q->(p)S.Q + s.P/Q
MS(P/Q)=220.5 MSE(s.P/Q)=6.57
MS(P/Q)/MSE(s.P/Q)=F(df(P/Q), df(s.P/Q))
CF4=220.5/6.571
F(1, 7)=33.56 Which is the same as the given F value 33.55 from the aov output.
Question 5
Part 1 This is a within subject design, completey randomized, where P crosses s which is nested in A. P,s(A)
Part 2
L5Q5=read.table('Lab5Q5data',header=TRUE)
L5Q5aov=aov(Perc ~ P+Error(A/P), data=L5Q5)
print(L5Q5aov)
##
## Call:
## aov(formula = Perc ~ P + Error(A/P), data = L5Q5)
##
## Grand Mean: 74
##
## Stratum 1: A
##
## Terms:
## Residuals
## Sum of Squares 64
## Deg. of Freedom 1
##
## Residual standard error: 8
##
## Stratum 2: A:P
##
## Terms:
## P Residuals
## Sum of Squares 472 15
## Deg. of Freedom 2 2
##
## Residual standard error: 2.7
## Estimated effects may be unbalanced
##
## Stratum 3: Within
##
## Terms:
## Residuals
## Sum of Squares 836
## Deg. of Freedom 12
##
## Residual standard error: 8.3
L5Q5.sum=summary(L5Q5aov)
boxplot(Perc ~ P, data=L5Q5)
L5Q5sum=unlist(L5Q5.sum)
structure(L5Q5sum)
## Error: A.Df Error: A.Sum Sq Error: A.Mean Sq
## 1.00 64.22 64.22
## Error: A.F value Error: A.Pr(>F) Error: A:P.Df1
## NA NA 2.00
## Error: A:P.Df2 Error: A:P.Sum Sq1 Error: A:P.Sum Sq2
## 2.00 472.11 14.78
## Error: A:P.Mean Sq1 Error: A:P.Mean Sq2 Error: A:P.F value1
## 236.06 7.39 31.95
## Error: A:P.F value2 Error: A:P.Pr(>F)1 Error: A:P.Pr(>F)2
## NA 0.03 NA
## Error: Within.Df Error: Within.Sum Sq Error: Within.Mean Sq
## 12.00 836.00 69.67
## Error: Within.F value Error: Within.Pr(>F)
## NA NA
L5Q5.aovtbl=model.tables(L5Q5aov, type='means')
L5Q5aovtbl=unlist(L5Q5.aovtbl)
df51=as.numeric(L5Q5sum['Error: A:P.Df1'])
df52=as.numeric(L5Q5sum['Error: A:P.Df2'])
SS51=as.numeric(L5Q5sum['Error: A:P.Sum Sq1'])
SS52=as.numeric(L5Q5sum['Error: A:P.Sum Sq2'])
MS51=as.numeric(L5Q5sum['Error: A:P.Mean Sq1'])
MS52=as.numeric(L5Q5sum['Error: A:P.Mean Sq2'])
F51=as.numeric(L5Q5sum['Error: A:P.F value1'])
P51=as.numeric(L5Q5sum['Error: A:P.Pr(>F)1'])
GM51=as.numeric(L5Q5aovtbl['tables.Grand mean'])
Mp51=as.numeric(L5Q5aovtbl['tables.P.p1'])
Mp52=as.numeric(L5Q5aovtbl['tables.P.p2'])
Mp53=as.numeric(L5Q5aovtbl['tables.P.p3'])
options(digits=2)
Part 3 There is a significant interaction of the marks on the midterm tests (P), with the mean of the first midterm being 67.67, the second test mean 74.83, and the third test mean 80.17, F(2,2)=31.95, MSe=7.39, p=0.03. Sum Sq=472.11. Grand Mean of 74.22.
Part 4 According to beckers 0-1-k rule, for the interaction of P.A, there are no randm variabes, so you shuld use the Type I error. For the interaction of P.s/A, P crosses 1 random variable, s, so you should use the Type II error.
Part 5 Variables->P, A, s Interactions->P, A, s, P.A, P.s, P.A.s Nesting->P, A, s/A, P.A, P.s/A, P.A.s/A
df P->(3-1)=2 A->(2-1)=1 s/A->(6-1)2=25 P.A->(3-1)(2-1)=2 P.s/A->(3-1)(6-1)2=50
EMS P->(a)(s)P + (s)P.A + P.s/A A->(a)(p)A + (p)s/A +(s)P.A + p.s/A s/A->(p)s/A + P.s/A P.A->(s)P.A + P.s/A P.s/A->P.s/A
MS(P)=236.06 MSE(P.S/A)=7.39
MS(p)/MSE(P.s/A)=F(df(P), df(P.s/A))
CF5=236.056/7.38889
F(2, 2)=31.95 Which is the same as the given F value 31.95 from the aov output.
Question 6
Part 1 Split plop design. s,C(Year,Dept)
Part 2
L5Q6=read.table('Lab5Q6data',header=TRUE)
L5Q6aov=aov(R ~ Class*Year*Dept+Error(Sub), data=L5Q6)
print(L5Q6aov)
##
## Call:
## aov(formula = R ~ Class * Year * Dept + Error(Sub), data = L5Q6)
##
## Grand Mean: 4.4
##
## Stratum 1: Sub
##
## Terms:
## Class Residuals
## Sum of Squares 27 283
## Deg. of Freedom 7 48
##
## Residual standard error: 2.4
## 13 out of 20 effects not estimable
## Estimated effects may be unbalanced
L5Q6.sum=summary(L5Q6aov)
boxplot(R ~ Class*Year*Dept, data=L5Q6)
L5Q6sum=unlist(L5Q6.sum)
structure(L5Q6sum)
## Error: Sub.Df1 Error: Sub.Df2 Error: Sub.Sum Sq1
## 7.00 48.00 26.79
## Error: Sub.Sum Sq2 Error: Sub.Mean Sq1 Error: Sub.Mean Sq2
## 282.57 3.83 5.89
## Error: Sub.F value1 Error: Sub.F value2 Error: Sub.Pr(>F)1
## 0.65 NA 0.71
## Error: Sub.Pr(>F)2
## NA
L5Q6.aovtbl=model.tables(L5Q6aov, type='means')
L5Q6aovtbl=unlist(L5Q6.aovtbl)
df61=as.numeric(L5Q6sum['Error: Sub.Df1'])
df62=as.numeric(L5Q6sum['Error: Sub.Df2'])
SS61=as.numeric(L5Q6sum['Error: Sub.Sum Sq1'])
SS62=as.numeric(L5Q6sum['Error: Sub.Sum Sq2'])
MS61=as.numeric(L5Q6sum['Error: Sub.Mean Sq1'])
MS62=as.numeric(L5Q6sum['Error: Sub.Mean Sq2'])
F61=as.numeric(L5Q6sum['Error: Sub.F value1'])
P61=as.numeric(L5Q6sum['Error: Sub.Pr(>F)1'])
GM61=as.numeric(L5Q6aovtbl['tables.Grand mean'])
options(digits=2)
Part 3 There is no significant interaction between the class the student is in, the year they are in, or the department they are in on the attitude of open-sourced software, F(7,48)=0.65, MSe=5.89, p=0.71. Sum Sq=26.79. Grand Mean of 4.39.
Part 4 Accoring to Becker’s rule, since all of the factors cross one random variable s, you should use the Type II residula error, which the aov did use.
Part 5 Variables->s, C, Y, D Interactions-> s, C, Y, D, s.C, s.Y, s.D, C.Y, C.D, Y.D, s.C.Y, s.Y.D, s.C.D, C.Y.D, s.C.Y.D Nesting->s, C/YD, Y, D, s.C/YD, s.Y, s.D, Y.c/YD, D.c/YD, Y.D, s.Y.c/YD, s.Y.D, s.D.c/YD, Y.D.c/YD, s.Y.D.c/Y
MS=3.83 MSE=5.89
CF6=3.8/5.9
F(7, 48)=0.64 Which is the same as the given F value 0.65 from the aov output.