# Chapter VII

Document Sample

```					   VII. Factorial experiments
VII.A         Design of factorial experiments
VII.C         An example two-factor CRD experiment
VII.D         Indicator-variable models and estimation for
factorial experiments
VII.E         Hypothesis testing using the ANOVA method
for factorial experiments
VII.F         Treatment differences
VII.G         Nested factorial structures
VII.H         Models and hypothesis testing for three-
factor experiments
Statistical Modelling Chapter VII                                1
Factorial experiments
• Often be more than one factor of interest to the
experimenter.
• Definition VII.1: Experiments that involve more than one
randomized or treatment factor are called factorial
experiments.
• In general, the number of treatments in a factorial
experiments is the product of the numbers of levels of the
treatment factors.
• Given the number of treatments, the experiment could be
laid out as
– a Completely Randomized Design,
– a Randomized Complete Block Design or
– a Latin Square
with that number of treatments.
• BIBDs or Youden Squares are not suitable.

Statistical Modelling Chapter VII                                      2
VII.A Design of factorial experiments
a) Obtaining a layout for a factorial experiment in R
•      Layouts for factorial experiments can be
obtained in R using expressions for the chosen
design when only a single-factor is involved.
•      Difference with factorial experiments is that the
several treatment factors are entered.
– Their values can be generated using fac.gen.
• fac.gen(generate, each=1, times=1,
order="standard")
• It is likely to be necessary to use either the
each or times arguments to generate the
replicate combinations.
• The syntax of fac.gen and examples are given
in Appendix B, Randomized layouts and sample
size computations in R.
Statistical Modelling Chapter VII                                  3
Example VII.1 Fertilizing oranges
• Suppose an experimenter is interested in investigating
the effect of nitrogen and phosphorus fertilizer on yield of
oranges.
• Investigate 3 levels of Nitrogen (viz 0,30,60 kg/ha) and 2
levels of Phosphorus (viz. 0,20 kg/ha).
• The yield after six months was measured.
• Treatments are all possible combinations of the
3 Nitrogen  2 Phosphorus levels: 32 = 6 treatments.
• The treatment combinations, arranged in standard order,
are:
Treatment    N    P
1        0    0
2        0   20
3       30    0
4       30   20
5       60    0
6       60   20
Statistical Modelling Chapter VII                                        4
Generating a layout in R for a CRD
with 3 reps
> #
Specifies units
> # CRD                                  indexed by Seedling
> #                                      with 18 levels.
> n <- 18
> CRDFac2.unit <- list(Seedling = n)
> CRDFac2.ran <- fac.gen(list(N = c(0, 30, 60), P = c(0,
20)), times = 3)
> CRDFac2.lay <- fac.layout(unrandomized = CRDFac2.unit,
+                     randomized = CRDFac2.ran, seed = 105)
> remove("CRDFac2.unit“, "CRDFac2.ran")
Creates 3 copies of the
Does CRD                            Remove excess objects   levels combinations of N
randomization                                               and P, with 3 and 2 levels;
stores these in the
data.frame
CRDFac2.ran.
Statistical Modelling Chapter VII                                                     5
The layout
> CRDFac2.lay
Units Permutation Seedling N P
1      1           2        1 30 20
2      2          18        2 0 0
3      3           4        3 30 0
4      4           5        4 30 0
5      5           7        5 30 20
6      6          12        6 30 0
7      7          15        7 60 0
8      8          13        8 0 0
9      9           6        9 60 0
10    10           1       10 60 0
11    11          10       11 30 20
12    12          16       12 60 20
13    13           8       13 0 20
14    14          14       14 0 20
15    15           3       15 0 0
16    16          11       16 60 20
17    17           9       17 60 20
18    18          17       18 0 20

Statistical Modelling Chapter VII             6
• Suppose we decide on a RCBD with three blocks
— how many units per block would be required?
• In factorial experiments not limited to two factors
• Thus we may have looked at Potassium at 2
levels as well. How many treatments in this
case?

Statistical Modelling Chapter VII                               7
experiments
a) Interaction in factorial experiments
• The major advantage of factorial experiments is
that they allow the detection of interaction.
• Definition VII.2: Two factors are said to interact
if the effect of one, on the response variable,
depends upon the level of the other.
• If they do not interact, they are said to be
independent.
• To investigate whether two factors interact, the
simple effects are computed.

Statistical Modelling Chapter VII                              8
Effects
• Definition VII.3: A simple effect, for the means
computed for each combination of at least two factors, is
the difference between two of these means having
different levels of one of the factors but the same levels
for all other factors.
• We talk of the simple effects of a factor for the levels of
the other factors.
• If there is an interaction, compute an interaction effect
from the simple effects to measure the size of the
interaction
• Definition VII.4: An interaction effect is half the
difference of two simple effects for two different levels of
just one factor (or is half the difference of two interaction
effects).
• If there is not an interaction, can separately compute the
main effects to see how each factor affects the response.
• Definition VII.5: A main effect of a factor is the
difference between two means with different levels of that
factor, each mean having been formed from all
observations having the same level of the factor.               9
Statistical Modelling Chapter VII
Example VII.2 Chemical reactor experiment
• Investigate the effect of catalyst and temperature on the
yield of chemical from a chemical reactor.
• Table of means from the experiment was as follows:
Temperature (°C)
160     180
A      60      72
Catalyst
B     52       64

• For A the temperature effect is 72-60 = 12
• For B the temperature effect is 64-52 = 12
• These are called the simple effects of temperature.
• Clearly, the difference between (effect of) the
temperatures is independent of which catalyst is used.
• Interaction effect: [12 - 12]/2 = 0
Statistical Modelling Chapter VII                                     10
Illustrate using an interaction plot
Effects of catalyst and temperature on yield
- no interaction

75

70

65
Y
i 60                                                                      A
e
l 55                                                                      B
d
50

45

40
150              160                 170                 180    190
Temperature

• A set of parallel lines indicates no interaction

Statistical Modelling Chapter VII                                                            11
Interaction & independence are
symmetrical in factors
• Thus,
– the simple catalyst effect at 160°C is 52-60 = -8
– the simple catalyst effect at 180°C is 64-72 = -8
• Thus the difference between (effect of) the
catalysts is independent of which temperature is
used.
• Interaction effect is still 0 and factors are additive.

Statistical Modelling Chapter VII                                   12
Conclusion when independent
• Can consider each factor separately.
• Looking at overall means will indicate what is happening in
the experiment.
Temperature (°C)
160     180

Mean     56       68
Catalyst
A         B

Mean     66       58
• So differences between the means in these tables are the
main effects of the factors.
– That is, the main effect of Temperature is 12 and that of Catalyst
is -8.
• Having used 2-way table of means to work out that there
is no interaction, abandon it for summarizing the results.
Statistical Modelling Chapter VII                                                      13
Example VII.3 Second chemical reactor
experiment

• Suppose results from experiment with 2nd reactor as
follows:
Temperature (°C)
160     180
A      60      72
Catalyst
B     52       83

• The simple temperature effect for A is 72-60 = 12
• The simple temperature effect for B is 83-52 = 31
• Difference between (effect of) temperatures depends on
which catalyst is used.
• Statement symmetrical in 2 factors — say 2 factors
Statistical Modelling Chapter VII                                     14
Interaction plot
Effects of catalyst and temperature on yield
- interaction

85
80
75
Y   70
i   65                                                                   A
e
l   60                                                                   B
d   55
50
45
40
150           160                 170                 180    190
Temperature

• Clearly an interaction as lines have different
slopes.
• So cannot use overall means.
Statistical Modelling Chapter VII                                                            15
Why using overall means is
inappropriate
• Overall means are:                 • Main effects:
Temperature (°C)            – cannot be equal to simple
160     180                 effects as these differ
– have no practical
Mean       56       77.5              interpretation.
• Look at means for the
Catalyst
A         B
combinations of the factors

Mean       66       67.5
• Interaction effect:
[(72-60) - (83-52)]/2
= [12 - 31]/2 = -9.5
Temperature (°C)
160     180      or [(52-60) - (83-72)]/2
A      60      72             = [-8 - 9]/2 = -9.5.
Catalyst                            • two non-interacting factors
B      52      83
Statistical Modelling Chapter VII
is the simpler              16
a-time experiments
• Sometimes suggested better to keep it simple and
investigate one factor at a time.
• However, this is wrong.
• Unable to determine whether or not there is an interaction.
• Take temperature-catalyst experiment at 2nd reactor.
Experiment 1
Temperature (°C)
160     180
A      60      ?
Experiment 2 Catalyst
B     52       83
• WELL YOU HAVE ONLY APPLIED THREE OF THE
FOUR POSSIBLE COMBINATIONS OF THE TWO
FACTORS
• Catalyst A at 180°C has not been tested but catalyst B at
160°C has been tested twice as indicated above.
Statistical Modelling Chapter VII                                       17
Limitation of inability to detect
interaction
• The results of the experiments would indicate
that:
– temperature increases yield by 31 gms
– the catalysts differ by 8 gms in yield.
• If we presume the factors act additively, predict
the yield for catalyst A at 160°C to be:
– 60+31 = 83 + 8 = 91.
• This is quite clearly erroneous.
• Need the factorial experiment to determine if
there is an interaction.

Statistical Modelling Chapter VII                             18
• Exactly the same total amount of resources are involved
in the two alternative strategies, assuming the number of
replicates is the same in all the experiments.
effects are estimated with greater precision in factorial
experiments.
• In the one-factor-at-a time experiments
– the effect of a particular factor is estimated as the difference
between two means each based on r observations.
• In the factorial experiment
– the main effects of the factors are the difference between two
means based on 2r observations
– which represents a sqrt(2) increase in precision.
• The improvement in precision will be greater for more
factors and more levels

Statistical Modelling Chapter VII                                                  19
experiments
if the factors interact, factorial experiments
allow this to be detected and estimates of
the interaction effect can be obtained,
and
if the factors are independent, factorial
experiments result in the estimation of the
main effects with greater precision.

Statistical Modelling Chapter VII                      20
VII.C An example two-factor CRD
experiment

• Modification of ANOVA: instead of a single
source for treatments, will have a source
for each factor and one for each possible
combinations of factors.

Statistical Modelling Chapter VII                    21
a) Determining the ANOVA table for a
two-Factor CRD
a) Description of pertinent features of the study
1. Observational unit
–     a unit
2. Response variable
–     Y
3. Unrandomized factors
–     Units
4. Randomized factors
–     A, B
5. Type of study
–     Two-factor CRD

b) The experimental structure
Structure    Formula
unrandomized n Units
randomized   a A*b B
Statistical Modelling Chapter VII                          22
c) Sources derived from the structure formulae
• Units            = Units
• A*B              = A + B + A#B
d) Degrees of freedom and sums of squares
• Hasse diagrams for this study with
– degrees of freedom                       Unrandomized terms          Randomized terms
– M and Q matrices
                         
Unrandomized terms                 Randomized terms                MG        MG               MG       MG

                                 
1       1                         1       1
Unit     U       A      A                 B      B
s
MU     MU-MG     MA   MA-MG               MB   MB-MG

Unit        U         A         A                     B        B
s
n         n-1        a        a-1                    b       b-1                   AB             A#B
MAB        MAB-MA-MB+MG

AB                  A#B
ab               (a-1)(b-1)
Statistical Modelling Chapter VII                                                                                    23
e) The analysis of variance table

Source            df         SSq
Units            n-1        YQUY
A             a-1        YQ A Y
B             b-1        YQB Y
A#B        (a-1)(b-1)   YQ ABY
Residual    ab(r-1)     YQURes Y

Statistical Modelling Chapter VII                             24
f) Maximal expectation and variation models

• Assume the randomized factors are fixed and that
the unrandomized factor is a random factor.
• Then the potential expectation terms are A, B and
AB.
• The variation term is: Units.
• The maximal expectation model is
– y = E[Y] = AB
• and the variation model is
– var[Y] = Units

Statistical Modelling Chapter VII                         25
g) The expected mean squares
• The Hasse diagrams, with contributions to
expected mean squares, for this study are:

Unrandomized terms                     Randomized terms

                                      
1        1                              1       1

Unit             U      A        A                         B       B
s2
U
U
2
qA  ψ  qA  ψ                   qB ψ  qB  ψ 

AB                     A#B
qAB  ψ                qAB  ψ 

Statistical Modelling Chapter VII                                                                      26
ANOVA table with E[MSq]

Source                       df         SSq            E[MSq]
Units                       n-1        YQUY
A                         a-1        YQ A Y     U  qA  y 
2

B                         b-1        YQB Y      U  qB  y 
2

A#B                    (a-1)(b-1)   YQ ABY      U  qAB  y  
2

Residual                ab(r-1)     YQURes Y   U
2

Statistical Modelling Chapter VII                                                27
b) Analysis of an example
Example VII.4 Animal survival experiment
• To demonstrate the analysis I will use the example from
Box, Hunter and Hunter (sec. 7.7).
• In this experiment                         Treatment
1      2       3    4
three poisons and               I 0.31   0.82    0.43 0.45
four treatments                   0.45   1.10    0.45 0.71
(antidotes) were                  0.46   0.88    0.63 0.66
0.43   0.72    0.76 0.62
investigated.
• The 12 combinations            II 0.36   0.92    0.44 0.56
of poisons and        Poison      0.29   0.61    0.35 1.02
treatments were                   0.40   0.49    0.31 0.71
applied to animals                0.23   1.24    0.40 0.38
using a CRD and the           III 0.22   0.30    0.23 0.30
survival times of the             0.21   0.37    0.25 0.36
animals measured                  0.18   0.38    0.24 0.31
(10 hours).                       0.23   0.29    0.22 0.33

Statistical Modelling Chapter VII                                      28
A. Description of pertinent features of the study
1. Observational unit         • These are the
– a animal                   steps that need to
2. Response variable            be performed
– Survival Time              before R is used
3. Unrandomized factors         to obtain the
– Animals                    analysis.
4. Randomized factors         • The remaining
– Treatments, Poisons        steps are left as
5. Type of study                an exercise for
– Two-factor CRD             you.
B. The experimental structure
Structure    Formula
unrandomized 48 Animals
randomized   3 Poisons*4 Treatments
Statistical Modelling Chapter VII                       29
Interaction plot

0.9
Treat

0.8
2
4
3
1

0.7
mean of Surv.Time

0.6
0.5
0.4
0.3
0.2

1   2            3

Poison

• There is some evidence of an interaction in that
the traces for each level of Treat look to be
different.
Statistical Modelling Chapter VII                                                          30
Hypothesis test for the example
Step 1:  Set up hypotheses
a) H0: there is no interaction between Poison and
Treatment
H1: there is an interaction between Poison and
Treatment

b) H0: r1 = r2 = r3
H1: not all population Poison means are equal

c) H0: t1 = t2 = t3 = t4
H1: not all population Treatment means are equal

Set a = 0.05.

Statistical Modelling Chapter VII                                  31
Hypothesis test for the example
(continued)
Step 2:    Calculate test statistics
• The ANOVA table for a two-factor CRD, with
random factors being the unrandomized factors
and fixed factors the randomized factors, is:
Source                df   SSq    MSq        E[MSq]          F    Prob
Animals               47 3.0051
Poison               2 1.0330 0.5165  2  q y
A    P          23.22 <.000

Treatment            3 0.9212 0.3071    A  qT  y 
2               13.81 <.001

Poison#Treat         6 0.2501 0.0417    A  qPT  y 
2               1.87   0.112

Residual            36 0.8007 0.0222  A
2

Statistical Modelling Chapter VII                                                       32
Hypothesis test for the example
(continued)

Step 3: Decide between hypotheses
Interaction of Poison and Treatment is not
significant, so there is no interaction.
Both main effects are highly significant,
so both factors affect the response.
• Also, it remains to perform the usual
diagnostic checking.

Statistical Modelling Chapter VII                      33
VII.D Indicator-variable models and
estimation for factorial
experiments
• The models for the factorial experiments will
depend on the design used in assigning the
treatments — that is, CRD, RCBD or LS.
• The design will determine the unrandomized
factors and the terms to be included involving
those factors.
• They will also depend on the number of
randomized factors.
• Let the total number of observations be n and the
factors be A and B with a and b levels,
respectively.
• Suppose that the combinations of A and B are
each replicated r times — that is, n = abr.
Statistical Modelling Chapter VII                         34
a)            Maximal model for two-factor
CRD experiments
• The maximal model used for a two-factor CRD
experiment, where the two randomized factors A and B
are fixed, is:
 
y AB = E  Y  = X AB a and V =  UIn
2

where
Y   is the n-vector of random variables for the response
variable observations,
(a) is the ab-vector of parameters for the A-B
combinations,,
XAB       is the nab matrix giving the combinations of A and B
that occurred on each unit, i.e. X matrix for AB,
 U is the variability arising from different units.
2

• Our model also assumes Y ~ N(yAB, V)
Statistical Modelling Chapter VII                                         35
Standard order
• Expression for X matrix in terms of direct
products of Is and 1s when A and B are in
standard order.
• Previously used standard order — general
definition in notes.
• The values of the k factors A1, A2, …, Ak with a1,
a2, …, ak levels, respectively, are systematically
ordered in a hierarchical fashion:
– they are ordered according to A1, then A2, then A3, …
and then Ak.
• Suppose, the elements of the Y vector are
arranged so that the values of the factors A, B
and the replicates are in standard order, as for a
systematic layout.
• Then X AB = Ia  Ib  1r
Statistical Modelling Chapter VII                                       36
Example VII.5 22 Factorial experiment
• Suppose A and B have 2 levels each and that
each combination of A and B has 3 replicates.
• Hence, a = b = 2, r = 3 and n = 12.

• Then  a  = a11 a12 a 21 a 22 
• Now Y is arranged so that the              X AB
values of A, B and the reps are     A    1 1 2                              2
in standard order — that is         B    1 2 1                              2
1   0   0   0
1   0   0   0
Y = Y111 Y112 Y113 Y121 Y122 Y123 Y211 Y212 Y213 Y221 Y222 Y223    1   0   0   0
0   1   0   0
0   1   0   0
• Then X AB = I2  I2  13                                       0
0
1   0   0
0   1   0
0   0   1   0
0           0
• so that XAB for 4 level AB is:
0   1
0   0   0   1
0   0   0   1
0           1
    0   0    
Statistical Modelling Chapter VII                                                          37
Example VII.5 22 Factorial experiment
(continued)
• For the maximal model,
 a 11 
 a  
1    0   0   0                       11 
1    0   0   0                  a 11 
1    0   0   0                  a 12 
0            0
 a 11   a 12 
1   0
0            0

1   0         a    a  
0
y AB = E  Y  = X AB    
a = 0
0
1
0
0
1   0
      12  =       12 
 a 21   a 21 
0            0
0
0   1        a 22   a 21 
          
0
a 21 
0   1
0    0   0   1                          
0    0   0   1                 a 22 
0            1                 a  
     0   0    
 a 22 
 22 
         

• That is, the maximal model allows for a different
response for each combination of A and B.
Statistical Modelling Chapter VII                                                           38
b) Alternative expectation models —
marginality-compliant models
Rule VII.1: The set of expectation models
corresponds to the set of all possible
combinations of potential expectation terms,
subject to restriction that terms marginal to
another expectation term are excluded from the
model;
• it includes the minimal model that consists of a
single term for the grand mean.
• For marginality of terms refer to Hasse diagrams
and can be deduced using definition VI.9.
• This definition states that one generalized factor
is marginal to another if
– the factors in the marginal generalized factor are a
subset of those in the other and
– this will occur irrespective of the replication of the
levels of the generalized factors.
Statistical Modelling Chapter VII                                        39
Unrandomized terms        Randomized terms

Two-factor                                                      
1       1               1       1
CRD
Unit        U    A    A                     B       B
s
n         n-1   a   a-1                    b       b-1

• For all randomized factors fixed, the potential
expectation terms are A, B and AB.                          AB                  A#B
• Maximal model                                                 ab               (a-1)(b-1)

– includes all terms: E[Y] = A + B + AB
– However, marginal terms must be removed
– so the maximal model reduces to E[Y] = AB
• Next model leaves out AB giving additive
model E[Y] = A + B
– no marginal terms in this model.
• A simpler model than this is either E[Y] = A
and E[Y] = B.
• Only other possible model is one with neither
A nor B: E[Y] = G.
Statistical Modelling Chapter VII                                                                 40
Alternative expectation models in
terms of matrices
y AB = X AB a               A and B interact
in effect on response   
y A+B      = X A a  XB  
A and B independently
affect response                      
y A = X Aa                     A only affects response 
yB = XB                       B only affects response 
yG = XG                      no factors affect response 
• Expressions for X matrices in terms of direct
products of Is and 1s when A and B are in
standard order.
Statistical Modelling Chapter VII                                                 41
X matrices
• Again suppose, the elements of the Y vector are
arranged so that the values of the factors A, B
and the replicates are in standard order, as for a
systematic layout.
• Then the X matrices can be written as the
following direct products:

X G = 1a  1b  1r = 1abr
X A = Ia  1b  1r
XB = 1a  Ib  1r
X AB = Ia  Ib  1r

Statistical Modelling Chapter VII                                42
Example VII.5 22 Factorial experiment
(continued)

• Remember A and B have two levels each and that each
combination of A and B is replicated 3 times.
• Hence, a = b = 2, r = 3 and n = 12. Then
a = a1 a 2 
 =  1  2 

 
a = a11 a12 a 21 a 22 

• Suppose Y is arranged so that the values of A, B and the
replicates are in standard order — that is
Y = Y111 Y112 Y113 Y121 Y122 Y123 Y211 Y212 Y213 Y221 Y222 Y223 

• Then

Statistical Modelling Chapter VII                                                43
Example VII.5 22 Factorial experiment
(continued)     XG     XA      XB                              X AB
A         1 2                  1 1 2 2
B                   1 2        1 2 1 2
1   1   0   1   0   1   0   0   0
1   1   0   1   0   1   0   0   0
X G = 12  12  13 = 112              1   1   0   1   0   1   0   0   0
1   1   0   0   1   0   1   0   0
X A = I2  12  13                    1   1   0   0   1   0   1   0   0
1   1   0   0   1   0   1   0   0
XB = 12  I2  13                    1   0   1   1   0   0   0   1   0
1   0   1   1   0   0   0   1   0
X AB = I2  I2  13                     1   0   1   1   0   0   0   1   0
1   0   1   0   1   0   0   0   1
1   0   1   0   1   0   0   0   1
1
    0
    1
   0
    1
   0
    0   0   1

Notice, irrespective of the replication of the levels of AB ,
• XG can be written as a linear combination of the columns
of each of the other three
• XA and XB can be written as linear combinations of the
columns of XAB.
Statistical Modelling Chapter VII                                                   44
Example VII.5 22 Factorial experiment
(continued)
• Marginality of indicator-variable terms (for generalized
factors)
– XG  XAa, XB, XAB(a).
– XAa, XB  XAB(a).
– More loosely, for terms as seen in the Hasse diagram, we say
that
• G < A, B, AB
• A, B < AB
• Marginality of models
– yG  yA, yB, yA+B, yAB
[yG = XG, yA = XAa, yB = XB, yA+B = XAa + XB, yAB = XAB(a)]
– yA, yB  yA+B, yAB
[yA = XAa, yB = XB, yA+B = XAa + XB, yAB = XAB(a)]
– yA+B  yAB
[yA+B = XAa + XB, yAB = XAB(a)]
– More loosely,
• G < A, B, A+B, AB,
• A, B < A+B, AB
• A+B < AB.
Statistical Modelling Chapter VII                                                 45
Estimators of the fitted values for the
expectation models
• They are all functions of means.
• So can be written in terms of mean operators, Ms.
• If Y is arranged so that the associated factors A, B and
the replicates are in standard order, the M operators
written as the direct product of I and J matrices:
Model                         Estimator
 
y AB = X AB a      y AB =  A  B  = MABY = r -1Ia  Ib  Jr Y
ˆ
y A+B = X A a  XB y A+B = A  B - G
ˆ
y A = X Aa                                 -1
y A = A = MA Y =  br  Ia  Jb  Jr Y
ˆ
yB = XB                                  -1
y = B = M Y =  ar  J  I  J Y
ˆ  B         B             a   b     r
yG = XG             yG = G = MGY = n -1Ja  Jb  Jr Y
ˆ

G, A, B and A  B are the n-vectors of means, the latter
for the combinations of A and B, that is for the
generalized factor AB.
Statistical Modelling Chapter VII                                            46
Example VII.5 22 Factorial experiment
(continued)
• The mean vectors, produced by an MY, are as follows:

G    A        B         A Β

 A1     B1     A1  B1 
G                        A1  B1 
G      A1     B1 
 A1     B1    A B 
G                        1     1
A      B 
G 
 A1    B2      A1  B2 
G                        A1  B2 
G      1      2
 A1    B2      A1  B2 
                         A2  B1 
G      A2     B1 
 A2     B1    A B 
G                        2     1
 A2     B1 
G 
 A2    B2      A2  B1 
G                        A2  B2 
G     A      B 
 A2    B2      A2  B2 
G 
       2      2      A2  B2 
         

Statistical Modelling Chapter VII                                       47
VII.E Hypothesis testing using the ANOVA
method for factorial experiments
• Use ANOVA to choose between models.
• In this section will use generic names of A, B and Units
for the factors
• Recall ANOVA for two-factor CRD.
Source                       df         SSq            E[MSq]
Units                       n-1        YQUY
A                        a-1        YQ A Y     U  qA  y 
2

B                        b-1        YQB Y      U  qB  y 
2

A:B                   (a-1)(b-1)   YQ ABY      U  qAB  y  
2

Residual               ab(r-1)     YQURes Y   U
2

Statistical Modelling Chapter VII                                                48
a) Sums of squares for the
analysis of variance
• Require estimators of the following SSqs for a
two-factor CRD ANOVA:
– Total or Units; A; B; A#B and Residual.
• Use Hasse diagram.

Statistical Modelling Chapter VII                          49
Unrandomized terms          Randomized terms

Vectors                                                                     
MG        MG                MG       MG
for sums
of squares                                 Unit
s
U        A      A                 B      B
MU     MU-MG      MA   MA-MG               MB   MB-MG

AB             A#B
MAB        MAB-MA-MB+MG

Total or Units SSq:                 QUY =  MU - MG  Y = Y - G = DG
A SSq:                              Q A Y =  MA - MG  Y = A - G = A e   • All the Ms
and Qs are
B SSq:                              QBY =  MB - MG  Y = B - G = Be        symmetric
A:B SSq:                            Q ABY =  MAB - MA - MB  MG  Y        and
= A  B - A - B  G =  A  B e   idempotent.
Residual SSq:                       QURes Y =  MU - MAB  Y = Y -  A  B  = D AB

Statistical Modelling Chapter VII
= Y -  A  B e - Ae - Be - G                                      50
SSq (continued)
• From section VII.C, Models and estimation
for factorial experiments, we have that

G = MGY = n -1Ja  Jb  Jr Y
-1
A = MA Y =  br  Ia  Jb  Jr Y
-1
B = MBY =  ar  Ja  Ib  Jr Y
 A  B  = MABY = r -1Ia  Ib  Jr Y

Statistical Modelling Chapter VII                                      51
SSq (continued)
• So SSqs for the ANOVA are given by

YQUY = D DG
G
YQ A Y = A Ae
e
YQBY = B Be
e

YQ ABY =  A  B e  A  B e
YQURes Y = DABDAB

Statistical Modelling Chapter VII                                 52
ANOVA table constructed as follows:
Source                df             SSq              MSq                   E[MSq]            F       p
Units               n-1             YQUY
YQA Y         YQ A Y                  U  qA  y  sA sURes
A                  a-1                                                     2             2  2        pA
= sA
2
a -1
B                  b-1             YQB Y        YQB Y
= sB
2              U  qB  y 
2               2  2
sB sURes   pB
b -1
A#B            (a-1)(b-1) YQABY                 YQ AB Y
= sAB
2          2
 
2  U  qAB y sAB sU
2    pAB
 a - 1 b - 1
Res

Residual         ab(r-1)          YQURes Y    YQURes Y                 U
2
=    2
sURes
ab  r - 1

Total              abr-1            YQUY

• Can compute the SSqs by decomposing y as follows:
y = g  ae  be   a b e  dAB
Statistical Modelling Chapter VII                                                                           53
d) Expected mean squares
• The E[MSq]s involve three quadratic functions of
the expectation vector:
 
qA y = yQ A y  a - 1 ,

qB  y  = yQBy  b - 1 ,

qAB  y  = yQ ABy  a - 1 b - 1 .
• That is, numerators are SSqs of
– QAy = (MA-MG)y,
– QBy = (MB-MG)y and
– QABy = (MAB-MA-MB+MG)y,
where y is one of the models                        • Require
– yG = XG                                           expressions
– yA = XAa                                           for the
– yA+B = XAa + XB                                   functions
– yAB = XAB(a)                                     under each of
Statistical Modelling Chapter VII                                  these models. 54
Source
Expectation                A              B                 A#B
model
yG = XG                                
qA y G = 0 qB y G = 0 qAB y G = 0       
y Α = X Aa              qA  y Α     qB  y Α  = 0    qAB  y Α  = 0
yΒ = XB              qA  yB  = 0     qB  y B       qAB  yB  = 0
y A+B = X A a  XB    qA  y Α+B     qB  y A+B     qAB  y A+B  = 0
y AB = X AB a       qA  y ΑB      qB  y AB        qAB  y AB 

• Firstly, considering the column for source A#B,
– the only model for which qAB(y)  0 is yAB = XAB(a).
– Consequently, A#B is significant indicates that qAB(y) > 0 and that
the maximal model is the appropriate model.
• Secondly, considering the column for source A,
– qA(y)  0 implies either a model that includes XAa or the maximal
model XAB(a):
if A#B is significant, know need maximal model and test for A irrelevant.
If A#B is not significant, know maximal model is not required and so
significant A indicates that the model should include XAa.
• Thirdly for source B, provided A#B is not significant, a significant B
indicates that the model should include XB.
Statistical Modelling Chapter VII                                                               55
Choosing an expectation model
for a two-factor CRD
pa                                        p>a
A:B hypothesis
reject H0                                  retain H0

Factors interact
in their effect on response variable.
Use maximal model yAB= XAB(a).

one or both p  a
A and B hypotheses
reject H0(s)

for both p > a
retain all H0s

Factors independent              Factors have no effect
in their effect on response variable.      on response variable.
Use a model that includes significant   Use minimal model yG= XG.
terms, that is a single factor or

Statistical Modelling Chapter VII                                                                  56
• In the notes show that the non-zero q-functions are given
by:                        a
rb a i - a. 
2

 
qA y Α = qA y Α+B =                 i =1
 a - 1
b
ra   j - . 
2

         
qB yB = qB y A+B =                  j =1
 b - 1

  a ij - a i. - a . j  a .. 
a       b                                              2
r

qAB y AB =         i =1 j =1
 a - 1 b - 1
• So q-functions are zero when expressions in parentheses
are zero.
• That is when a i = a.,  j = . and a ij = a i .  a . j - a ..
• That is equality or an additive pattern obtain.
• These, or equivalent, expressions are given for H0.
Statistical Modelling Chapter VII                                                                   57
e) Summary of the hypothesis test
Step 1:  Set up hypotheses
a) H0: there is no interaction between A and B
(or model simpler than XAB(a) is
a    ij
- a i . - a . j  a .. = 0   for all i, j   
H1: there is an interaction between Poison and
Treatment

a    ij
- a i . - a . j  a ..  0 for some i, j        
b) H0: a1 = a2 = … = aa (or XAa not required in model)
H1: not all population Poison means are equal

c) H0: 1 = 2 = … = b (or XB not required in model)
H1: not all population Treatment means are equal
Set a = 0.05.
Statistical Modelling Chapter VII                                                                     58
Hypothesis test for the example
(continued)
Step 2:                Calculate test statistics
Source                df             SSq              MSq                   E[MSq]          F       p
Units                n-1            YQUY
YQA Y         YQ A Y                  U  qA  y  sA sURes
A                   a-1                                                    2             2  2      pA
= sA
2
a -1
B                   b-1            YQB Y        YQB Y
= sB
2              U  qB  y  sB sURes
2             2  2      pB
b -1
A#B            (a-1)(b-1) YQABY                 YQ AB Y
= sAB
2          2
 
2  U  qAB y sAB sU
2    pAB
 a - 1 b - 1
Res

Residual         ab(r-1)          YQURes Y    YQURes Y                 U
2
=    2
sURes
ab  r - 1

Total              abr-1            YQUY
Statistical Modelling Chapter VII                                                                         59
Hypothesis test for the example
(continued)
Step 3:     Decide between hypotheses
If A#B is significant, we conclude that the maximal
model yAB = E[Y] = XAB(a) best describes the data.

If A#B is not significant, The choice between
these models depends on which of A and B are
not significant. A term corresponding to the
significant source must be included in the model.

For example, if both A and B are significant, then
the model that best describes the data is the
additive model yA+B = E[Y] = XAa + XB.
Statistical Modelling Chapter VII                                 60
f) Computation of ANOVA and
diagnostic checking in R
• The assumptions underlying a factorial
experiment will be the same as for the
basic design employed, except that
residuals-versus-factor plots of residuals
are also produced for all the factors in the
experiment.

Statistical Modelling Chapter VII                        61
Example VII.4 Animal survival
experiment (continued)
• Previously determined the following experimental
structure for this experiment.
Structure    Formula
unrandomized 48 Animals
randomized   3 Poisons*4 Treatments

• From this we conclude that the model to be used
for aov function is
Surv.Time ~ Poison * Treat +
Error(Animals).

Statistical Modelling Chapter VII                               62
R instructions
• First data entered into R data.frame Fac2Pois.dat.
Fac2Pois.dat <- fac.gen(generate = list(Poison = 3, 4, Treat=4))
Fac2Pois.dat <- data.frame(Animals = factor(1:48), Fac2Pois.dat)
Fac2Pois.dat\$Surv.Time <-
c(0.31,0.82,0.43,0.45,0.45,1.10,0.45,0.71,0.46,0.88,0.63,0.66,
0.43,0.72,0.76,0.62,0.36,0.92,0.44,0.56,0.29,0.61,0.35,1.02,
0.40,0.49,0.31,0.71,0.23,1.24,0.40,0.38,0.22,0.30,0.23,0.30,
0.21,0.37,0.25,0.36,0.18,0.38,0.24,0.31,0.23,0.29,0.22,0.33)
attach(Fac2Pois.dat)                          Treatment
Fac2Pois.dat                             1    2      3    4
I   0.31   0.82   0.43   0.45
0.45   1.10   0.45   0.71
0.46   0.88   0.63   0.66
0.43   0.72   0.76   0.62

II   0.36   0.92   0.44   0.56
Poison         0.29   0.61   0.35   1.02
0.40   0.49   0.31   0.71
0.23   1.24   0.40   0.38

III   0.22   0.30   0.23   0.30
0.21   0.37   0.25   0.36
0.18   0.38   0.24   0.31
Statistical Modelling Chapter VII                         0.23   0.29   0.22   0.33   63
R output
> Fac2Pois.dat
Animals Poison Treat Surv.Time
1       1      1     1      0.31   25   25   2   1   0.40
2       2      1     2      0.82   26   26   2   2   0.49
3       3      1     3      0.43   27   27   2   3   0.31
4       4      1     4      0.45   28   28   2   4   0.71
5       5      1     1      0.45   29   29   2   1   0.23
6       6      1     2      1.10   30   30   2   2   1.24
7       7      1     3      0.45   31   31   2   3   0.40
8       8      1     4      0.71   32   32   2   4   0.38
9       9      1     1      0.46   33   33   3   1   0.22
10      10      1     2      0.88   34   34   3   2   0.30
11      11      1     3      0.63   35   35   3   3   0.23
12      12      1     4      0.66   36   36   3   4   0.30
13      13      1     1      0.43   37   37   3   1   0.21
14      14      1     2      0.72   38   38   3   2   0.37
15      15      1     3      0.76   39   39   3   3   0.25
16      16      1     4      0.62   40   40   3   4   0.36
17      17      2     1      0.36   41   41   3   1   0.18
18      18      2     2      0.92   42   42   3   2   0.38
19      19      2     3      0.44   43   43   3   3   0.24
20      20      2     4      0.56   44   44   3   4   0.31
21      21      2     1      0.29   45   45   3   1   0.23
22      22      2     2      0.61   46   46   3   2   0.29
23      23      2     3      0.35   47   47   3   3   0.22
24      24      2     4      1.02   48   48   3   4   0.33

Statistical Modelling Chapter VII                               64
R instructions and output
interaction.plot(Poison, Treat, Surv.Time, lwd=4)
Fac2Pois.aov <- aov(Surv.Time ~ Poison * Treat +
Error(Animals), Fac2Pois.dat)
summary(Fac2Pois.aov)

• Function interaction.plot to produce the plot for
initial graphical exploration.
• Boxplots not relevant as single factor.
> interaction.plot(Poison, Treat, Surv.Time, lwd = 4)
> Fac2Pois.aov <- aov(Surv.Time ~ Poison * Treat +
Error(Animals), Fac2Pois.dat)
> summary(Fac2Pois.aov)
Error: Animals
Df Sum Sq Mean Sq F value     Pr(>F)
Poison        2 1.03301 0.51651 23.2217 3.331e-07
Treat         3 0.92121 0.30707 13.8056 3.777e-06
Poison:Treat 6 0.25014 0.04169 1.8743      0.1123
Residuals    36 0.80073 0.02224
Statistical Modelling Chapter VII                                65
Diagnostic checking
• As experiment was set up as a CRD, the assumptions
underlying its analysis will be the same as for the CRD
• Diagnostic checking the same — in particular, Tukey’s
computed.
• The R output produced by the expressions that deal with
diagnostic checking is as follows:
>   #
>   # Diagnostic checking
>   #
>   res <- resid.errors(Fac2Pois.aov)
>   fit <- fitted.errors(Fac2Pois.aov)
>   plot(fit, res, pch=16)
>   plot(as.numeric(Poison), res, pch=16)
>   plot(as.numeric(Treat), res, pch=16)
>   qqnorm(res, pch=16)
>   qqline(res)
Statistical Modelling Chapter VII                                   66
Diagnostic checking (continued)                                                                                                   Normal Q-Q Plot

0.4
0.4

0.2
0.2

Sample Quantiles
res

0.0
0.0

-0.2
-0.2

0.2    0.3    0.4     0.5         0.6    0.7    0.8    0.9                                    -2         -1               0                   1         2

fit                                                                                 Theoretical Quantiles

0.4
0.4

0.2
0.2

res
res

0.0
0.0

-0.2
-0.2

1.0         1.5            2.0           2.5         3.0                               1.0        1.5        2.0         2.5           3.0       3.5       4.0

as.numeric(Poison)                                                                              as.numeric(Treat)

• All plots indicate a problem with the assumptions — will
a transformation fix the problem?
Statistical Modelling Chapter VII                                                                                                                                                           67
g) Box-Cox transformations for correcting
• Box, Hunter and Hunter (sec. 7.9) describe the
Box-Cox procedure for determining the
appropriate power transformation for a set of
data.
• It has been implemented in the R function
boxcox supplied in the MASS library that comes
with R.
• When you run this procedure you obtain a plot of
the log-likelihood of l, the power of the
transformation to be used (for l = 0 use the ln
transformation).
• However, the function does not work with
aovlist objects and so the aov function must
be repeated without the Error function.
Statistical Modelling Chapter VII                            68
Example VII.4 Animal survival experiment
(continued)

> Fac2Pois.NoError.aov <- aov(Surv.Time ~ Poison *
Treat, Fac2Pois.dat)
> library(MASS)

The following object(s) are masked from package:MASS
:

Animals
boxcox(Fac2Pois.NoError.aov, lambda=seq(from = -2.5,
to = 2.5, len=20), plotit=T)

 The message reporting the masking of Animals is saying
that there is a vector Animals that is part of the MASS
library that is being overshadowed by Animals in
Fac2Pois.dat.

Statistical Modelling Chapter VII                                 69
Example VII.4 Animal survival experiment
(continued)

30
95%

20
10
log-Likelihood

0
-10
-20
-30
-40

-2   -1   0   1   2

• Output indicates that, as the log likelihood is a maximum
around l = -1, the reciprocal transformation should be
used.
• The reciprocal of the survival time will be the death rate
— the number that die per unit time
Statistical Modelling Chapter VII                                                  70
Repeat the analysis on the
reciprocals
•    detach Fac2Pois.dat data.frame
•    add Death.Rate to the data.frame
•    reattach the data.frame to refresh info in R.
•    repeat expressions from the original analysis with
Surv.time replaced by Death.Rate appropriately.
Treat

1
3
4
4

2
mean of Death.Rate

3
2

1   2            3

Poison

• Looking like no interaction.
Statistical Modelling Chapter VII                                                             71
Repeat the analysis on the
reciprocals (continued)
> detach(Fac2Pois.dat)
> Fac2Pois.dat\$Death.Rate <- 1/Fac2Pois.dat\$Surv.Time
> attach(Fac2Pois.dat)

The following object(s) are masked from package:MASS :

Animals

> interaction.plot(Poison, Treat, Death.Rate, lwd=4)
> Fac2Pois.DR.aov <- aov(Death.Rate ~ Poison * Treat +
Error(Animals), Fac2Pois.dat)
> summary(Fac2Pois.DR.aov)

Error: Animals
Df Sum Sq Mean Sq F value    Pr(>F)
Poison         2 34.877 17.439 72.6347 2.310e-13
Treat          3 20.414  6.805 28.3431 1.376e-09
Poison:Treat 6 1.571     0.262 1.0904     0.3867
Residuals    36 8.643    0.240

Statistical Modelling Chapter VII                                            72
Repeat the analysis on the
reciprocals (continued)                                                                                              Normal Q-Q Plot

1.0
1.0

0.5
0.5

Sample Quantiles
res

0.0
0.0

-0.5
-0.5

-2         -1                  0                    1         2
2                3               4
Theoretical Quantiles
fit

1.0
1.0

0.5
0.5

res
res

0.0
0.0

-0.5
-0.5

1.0       1.5          2.0           2.5   3.0                             1.0        1.5        2.0            2.5            3.0       3.5       4.0

as.numeric(Poison)                                                                       as.numeric(Treat)

• Looking good
Statistical Modelling Chapter VII                                                                                                                                              73
Comparison of untransformed and
transformed analyses
UNTRANSFORMED                TRANSFORMED
Source                    df     MSq    F   Prob        df   MSq    F    Prob

Animals                    47                           47
Poison                     2   0.5165   23.22 0.0000    2 17.439   72.63 <0.001
Treatment                  3   0.3071   13.81 0.0000    3 6.805    28.34 <0.001
Poison#Treat               6   0.0417    1.87 0.1112    6 0.262     1.09 0.387
Residual                  36   0.0222                  36 0.240

• The analysis of the transformed data indicates that there is
no interaction on the transformed scale — confirms plot.
• The main effect mean squares are even larger than before
indicating that we are able to separate the treatments even
more on the transformed scale.
• Diagnostic checking now indicates all assumptions are met.
Statistical Modelling Chapter VII                                                      74
VII.F Treatment differences

• As usual the examination of treatment
differences can be based on multiple
comparisons or submodels.

Statistical Modelling Chapter VII                 75
a) Multiple comparison procedures

• For two factor experiments, there will be
altogether three tables of means, namely
one for each of A, B and A#B.
• Which table is of interest depends on the
results of the hypothesis tests outlined
above.
• However, in all cases Tukey’s HSD
procedure will be employed to determine
which means are significantly different.

Statistical Modelling Chapter VII                     76
A#B Interaction significant
• In this case you look at the table of means for the
AB combinations.
A
1       2     3      .     .       .     a
1    x       x     x      .     .       .     x
2    x       x     x      .     .       .     x
.    .       .     .      .     .       .     .
B         .    .       .     .      .     .       .     .
.    .       .     .      .     .       .     .
b    x       x     x      .     .       .     x

q ab,,0.05           q ab,,0.05     2
w  5%  =                     sxd =                 s
2                     2          r
• In this case you look at the table of means for the
AB combinations.
Statistical Modelling Chapter VII                                                     77
A#B interaction not significant
• In this case examine the A and B tables of
means for the significant lines.

A                                                         B
1      2         3   .        .       .      a           1       2         3   .       .        .        b
Means       x      x         x   .        .       .      x   Means   x       x         x   .       .        .        x

q a,,0.05           q a,,0.05      2                    q b,,0.05           q b,,0.05        2
w  5% =                  sxd =                s           w  5% =                sxd =                s
2                  2         rb                           2                  2           ra

• That is, we examine each factor separately.

Statistical Modelling Chapter VII                                                                                           78
Example VII.4 Animal survival experiment
(continued)
• Tables of means and studentized ranges:
> #
> # multiple comparisons
> #
> model.tables(Fac2Pois.DR.aov, type="means")
Tables of means
Grand mean
Poison:Treat
Treat
2.622376                       Poison 1      2     3     4
1 2.487 1.163 1.863 1.690
Poison                              2 3.268 1.393 2.714 1.702
Poison                               3 4.803 3.029 4.265 3.092
> q.PT <- qtukey(0.95, 12, 36)
1      2    3
> q.PT
1.801 2.269 3.797              [1] 4.93606
> q.P <- qtukey(0.95, 3, 36)
Treat                         > q.P
Treat                          [1] 3.456758
> q.T <- qtukey(0.95, 4, 36)
1      2    3     4
> q.T
3.519 1.862 2.947 2.161        [1] 3.808798
Statistical Modelling Chapter VII                                            79
Example VII.4 Animal survival experiment
(continued)

• For our example, as the interaction is not significant, the
overall tables of means are examined.
• For the Poison means
3.456758   0.240  2
Poison                            w  5% =          
1     2     3                                2        16
1.801 2.269 3.797                         = 0.42

• All Poison means are significantly different.
• For the Treat means
Treat                                       3.808798   0.240  2
1     2     3     4           w  5% =          
2        12
3.519 1.862 2.947 2.161                   = 0.54
• All but Treats 2 and 4 are different.
Statistical Modelling Chapter VII                                          80
Plotting the means in a bar chart
>   # Plotting means
>   #
>   Fac2Pois.DR.tab <- model.tables(Fac2Pois.DR.aov, type="means")
>   Fac2Pois.DR.Poison.Means <-
+            data.frame(Poison = levels(Poison),
+                       Death.Rate = as.vector(Fac2Pois.DR.tab\$tables\$Poison))
>   barchart(Death.Rate ~ Poison, main="Fitted values for Death rate",
+                                 ylim=c(0,4), data=Fac2Pois.DR.Poison.Means)
>   Fac2Pois.DR.Treat.Means <-
+              data.frame(Treatment = levels(Treat),
+                         Death.Rate = as.vector(Fac2Pois.DR.tab\$tables\$Treat))
>   barchart(Death.Rate ~ Treat, main="Fitted values for Death rate",
+                                ylim=c(0,4), data=Fac2Pois.DR.Treat.Means)
Fitted values for Death rate
Fitted values for Death rate

3
3

Death.Rate
Death.Rate

2                                                       2

1                                                       1

1                  2               3

• Max death rate with Poison 3 and Treats 1.
1          2               3       4

• Min death rate with Poison 1 and either Treats 2 or 4.
Statistical Modelling Chapter VII                                                                                                  81
If interaction significant, 2 possibilities
• Possible researcher’s objective(s):
i. finding levels combination(s) of the factors that
maximize (or minimize) response variable or
describing response variable differences between all
levels combinations of the factors
ii. for each level of one factor, finding the level of the
other factor that maximizes (or minimizes) the
response variable or describing the response
variable differences between the levels of the other
factor
iii. finding a level of one factor for which there is no
difference between the levels of the other factor
• For i: examine all possible pairs of differences
between all means.
• For ii & iii: examine pairs of mean differences
between levels of one factor for each level of
other factor i.e. in slices for each level of other
factor.
Statistical Modelling Chapter VII                                        82
Table of Poison by Treat means
Poison:Treat
Treat
Poison 1                            2         3         4
1 2.487                        1.163     1.863     1.690
2 3.268                        1.393     2.714     1.702
3 4.803                        3.029     4.265     3.092
4.93606   0.240  2
w  5%  =        
2        4
= 1.21

• Look for overall max or max in each column
• Do not do for this example as interaction is not
significant
Statistical Modelling Chapter VII                                       83
b) Polynomial submodels
• As stated previously, the formal expression for
maximal indicator-variable model for a two-factor
CRD experiment, where the two randomized
factors A and B are fixed, is:
 
y AB = E  Y  = X AB a and V =  UIn
2

•       In respect of fitting polynomial submodels, two
situations are possible:
i. one factor only is quantitative, or
ii. both factors are quantitative.

Statistical Modelling Chapter VII                                    84
One quantitative (B) and one qualitative
factor (A)
• Following set of models for E[Yijk] is considered:
E Yijk  = a ij
                                         depends on combination of A and B

E Yijk  = a i  a i1 x  j  a i 2 x  j
 
2

quadratic response to B, differing for A
E Yijk  = a i  a i1 x  j
                                         linear response to B, differing for A
indicator          E Yijk  = a i   j
                                         nonsmooth, independent response to A & B
-variable          E Yijk  = a i   1x  j   2 x  j
2
quadratic response to B, intercept differs for A
 
models             E Yijk  = a i   1x  j                   linear response to B, intercept differs for A
 
E Yijk  = a i
                                         nonsmooth response, depends on A only
E Yijk  =  j
                                         nonsmooth response, depends on B only
E Yijk  =    1x  j   2 x  j
 
2
quadratic response to B, A has no effect

E Yijk  =    1x  j
                                         linear response to B, A has no effect

E Yijk  = 
                                         neither factor affects the response
Statistical Modelling Chapter VII                                                                               85
Matrix expressions for models
E  Y  = X AB a                             depends on combination of A and B
E  Y  = X A a  X A1  a 1  X A2  a 2   quadratic response to B, differing for A
E  Y  = X A a  X A1 a 1                   linear response to B, differing for A
E  Y  = X A a  X B                          nonsmooth, independent response to A & B
E  Y  = X A a  X1 1  X 2 2                quadratic response to B, intercept differs for A
E  Y  = X A a  X1 1                         linear response to B, intercept differs for A
E Y = XAa                                     nonsmooth response, depends on A only
E  Y  = X B                                  nonsmooth response, depends on B only
E  Y  = X G   X1 1  X 2 2                quadratic response to B, A has no effect
E  Y  = X G   X1 1                         linear response to B, A has no effect
E  Y  = XG                                   neither factor affects the response
 a  = a ij  is an ab-vector of effects              X1 is an n-vector containing the values of the levels of B

 a 1 = a i1 is an a-vector of linear coefficients X 2 is an n-vector containing the (values) of the levels of B
2

X A1 is an n  a matrix whose ith column contains
 a 2 = a i 2  is an a-vector of quadratic coeffients        the values of the levels of B for just those units that
a = a i  is an a-vector of effects                        received the ith level of A
  is a b-vector of effects
 = j                                               X A2 is an n  a matrix whose ith column contains
 =  1  2 
2                                                           the (values)2 of the levels of B for just those units
Statistical Modelling Chapter VII                                                                                      86
Example VII.6 Effect of operating temperature
on light output of an oscilloscope tube
• Suppose an experiment conducted to investigate the effect of the
operating temperatures 75, 100, 125 and 150, for three glass types,
on the light output of an oscilloscope tube.
• Further suppose that this was done using a CRD with 2 reps.
• Then X matrices for the analysis of the experiment:
 75                       75    0     0                                 5625     0       0 
 75                       75    0     0                                 5265     0       0 
100                      100    0     0                                10000     0       0 
100                      100    0     0                                10000     0       0 
125                      125    0     0                                15625     0       0 
125                      125    0     0                                15625     0       0 
150                      150    0     0                                22500     0       0 
150                      150    0     0                                22500     0       0 
 75                       0     75    0                                 0       5625     0 
 75                       0     75    0                                 0       5625     0 
100                       0    100    0   a                        0      10000     0   a  
                                      0   a 11  ,                                     0   a 12 
X1 1 = 100   1, X A1  a 1 =  0
0   21
X A2  a 2
0   22 
100                                     = 0      10000
125                         0    125                                          0    15625
125 
    
 0
      125     0  a 31
        
 0
        15625     0  a 32 
       
150                       0    150    0                                 0      22500     0 
150                       0    150    0                                 0      22500     0 
 75                       0      0    75                                0         0     5625 
 75                       0      0    75                                0         0     5625 
100                       0      0   100                                0         0    10000 
100                       0      0   100                                0         0    10000 
125                       0      0   125                                0         0    15625 
125                       0      0   125                                0         0    15625 
150                       0      0   150                                0         0    22500 
150 
                          0
        0   150 
                               0
           0    22500 

Statistical Modelling Chapter VII                                                                                           89
Why this set of expectation
models?
• As before, s are used for the coefficients of polynomial
terms
– a numeric subscript for each quantitative fixed factor in the
experiment is placed on the s to indicate the degree(s) to which
the factor(s) is(are) raised.
• The above models are ordered from the most complex to
the simplest.
• They obey two rules:
• Rule VII.1: The set of expectation models corresponds to
the set of all possible combinations of potential
expectation terms, subject to restriction that terms
marginal to another expectation term are excluded from
the model;
• Rule VII.2: An expectation model must include all
polynomial terms of lower degree than a polynomial term
that has been put in the model.
Statistical Modelling Chapter VII                                                   90
Definitions to determine if a
polynomial term is of lower degree
• Definition VII.7: A polynomial term is one in
which the X matrix involves the quantitative
levels of a factor(s).
• Definition VII.8: The degree for a polynomial
term with respect to a quantitative factor is the
power to which levels of that factor are to be
raised in this term.
• Definition VII.9: A polynomial term is said to be
of lower degree than a second polynomial term
if,
– for each quantitative factor in first term, its degree is
less than or equal to its degree in the second term and
– the degree of at least one factor in the first term is less
than that of the same factor in the second term.
Statistical Modelling Chapter VII                                          91
Marginality of terms and models
• Note that the term X11 is not marginal to X22 — the
column X1 is not a linear combination of the column X2.
• However,
– the degree of X11 is less than that of X22
– the degree rule above implies that if term X22 is included in the
model, so must the term X11.
• As far as the marginality of models is concerned, the
model involving just X11 is marginal to the model
consisting of X11 and X22
E  Y = XG  X1 1  E  Y = XG  X1 1  X2 2
• Also note that the term X11 is marginal to XA1(a)1 since
X1 is the sum of the columns of XA1.
• Consequently, a model containing XA1(a)1 will not
contain X11.
• In general, the models to which a particular model is
marginal will be found above it in the list.
Statistical Modelling Chapter VII                                              92
ANOVA table for a two-factor CRD
with one quantitative factor
Source              df          SSq
Units              n-1        YQUY
A                 a-1        YQ A Y
B                 b-1         YQB Y
Linear            1         YQBL Y
Deviations       b-3       YQBDev Y
A#B           (a-1)(b-1)     YQ ABY
A#BLinear        a-1       YQ ABL Y
Deviations   (a-1)(b-3)    YQ ABDev Y
Residual      (r-1)(ab-1)   YQURes Y

Statistical Modelling Chapter VII                                 93
Strategy in determining models to be
used to describe the data.
For Deviations
• Only if the terms to which a term is marginal are not significant then, if
P(F  Fcalc)  a, the evidence suggests that H0 be rejected and the
term must be incorporated in the model.
• Deviations for B is marginal to Deviations for A#B so that if the latter is
significant, the Deviations for B is not tested; indeed no further testing
occurs as the maximal model has to be used to describe the data.
• Only if the polynomial terms are not of lower degree than a significant
polynomial term then, if P(F  Fcalc)  a, the evidence suggests that
H0 be rejected and the term be incorporated in the model.
• A#BLinear is of lower degree than to A#BQuadratic so that if the latter is
significant, A#BLinear is not tested.
For A, Linear for B, Quadratic for B
• Only if the terms to which a term is marginal and the polynomial terms
of higher degree are not significant then, if P(F  Fcalc)  a, the
evidence suggests that H0 be rejected and the term be incorporated in
the model.
• For example, for the Linear term for B, it is of lower degree than the
Quadratic term for B and it is marginal to A#BLinear so that if either of
these is significant, Linear for B is not tested.
Statistical Modelling Chapter VII                                                  94
Both factors quantitative
• Example VII.7 Muzzle velocity of an antipersonnel
weapon
• In a two-factor CRD experiment with two replicates the
effect of
– Vent volume and
– Discharge hole area
on the muzzle velocity of a mortar-like antipersonnel
weapon was investigated.
Vent              Discharge hole area
volume     0.016      0.03    0.048      0.062
0.29      294.9     295.0    270.5      258.6
294.1     301.1    263.2      255.9
0.40     301.7     293.1    278.6      257.1
307.9     300.6    267.9      263.6
0.59     285.5     285.0    269.6      262.6
298.6     289.1    269.1      260.3
0.91     303.1     277.8    262.2      305.3
305.3     266.4    263.2      304.9
Statistical Modelling Chapter VII                                         95
Interaction.Plot produced
using R
Hole.Area

300
0.062
0.016
0.03
0.048
290
mean of Velocity

280
270
260

0.29   0.4   0.59              0.91

Vent.Vol

• Pretty clear that there is an interaction.
Statistical Modelling Chapter VII                                                                        96
Maximal polynomial submodel, in
terms of a single observation
E Yijk  =    10 xai   20 xai   01x  j   02 x  j
 
2                       2

 11xai x  j   12 xai x  j   21xai x  j   22 xai x  j
2          2                2 2

where
• Yijk is the random variable representing the response
variable for the kth unit that received the ith level of factor
A and the jth level of factor B,
•  is the overall level of the response variable in the
experiment,
• xa is the value of the ith level of factor A,
i
• x  is the value of the jth level of factor B,
j
• s are the coefficients of the equation describing the
change in response as the levels of A and/or B changes
with the first subscript indicating the degree with respect to
factor A and the second subscript indicating the degree
with respect to factor B.
Statistical Modelling Chapter VII                                                                      97
Maximal polynomial submodel, in
matrix terms
E  Y = XG  X22
where  =  10  20  01  02  11  12  21  22 
22

X =  X10      X 20   X01 X 02   X11 X12   X 21 X 22 

• X is an n  8 matrix whose columns are the
products of the values of the levels of A and B as
indicated by the subscripts in X.
• For example
– 3rd column consists of the values of the levels of B
– 7th column the product of the squared values of the
levels of A with the values of the levels of B.
Statistical Modelling Chapter VII                                             98
Set of expectation models considered
when both factors are quantitative
 
E  Y  = X AB a                    depends on combination of A and B
E  Y  = XG   X22                smooth response in A and B
 or some subset of X22 that obeys the degrees rule 
E  Y  = X A a  X B               nonsmooth, independent response to A & B

non-   E  Y  = X A a  X 01 01  X 02 02 quadratic response for B, intercept differs for A
smooth E  Y  = X A a  X 01 01            linear response for B, intercept differs for A
E Y = XAa
A
nonsmooth response, depends on A only

non-   E  Y  = XB  X10 10  X 20 20        quadratic response for A, intercept differs for B
smooth E  Y  = XB  X10 10                   linear response for A, intercept differs for B
B
E  Y  = X B                            nonsmooth response, depends on B only
where        a  = a ij 
a = a i 
 
 = j
 =  10
22             20  01  02  11  12  21  22 
Statistical Modelling Chapter VII                                                                 99
Set of expectation models (continued)
• Again, rules VII.1 and VII.2 were used in deriving
this set of models.
• Also, the subsets of terms from 22 mentioned
above include the null subset and must conform
to rule VII.2 so that whenever a term from X22 is
added to the subset, all terms of lower degree
must also be included in the subset.
– X1111 < X1212 so model with X1212 must include X1111
– X1212  X2121 so model with X1212 does not need
X2121
• Further, if for a term the Deviation for a marginal
term is significant, polynomial terms are not
considered for it.
Statistical Modelling Chapter VII                                      100
Interpreting the fitted models
• models in which there are only single-factor polynomial
terms define
–      a plane if both terms linear
–      a parabolic tunnel if one term is linear and the other quadratic
–      a paraboloid if both involve quadratic terms
• models including interaction submodels define nonlinear
surfaces
–      they will be monotonic for factors involving only linear terms,
–      for interactions involving quadratic terms, some candidate
shapes are:

Statistical Modelling Chapter VII                                                        101
ANOVA table for a two-factor CRD
with both factors quantitative
Source                             df          SSq
Units                             n-1         YQUY
A                                a-1         YQA Y
Linear                         1          YQ AL Y
Q

Deviations                  a-3        YQBDev Y
B                               b-1         YQB Y
Linear                       1         YQBL Y

Deviations                  b-3        YQBDev Y
A#B                          (a-1)(b-1)     YQABY
ALinear#BLinear                1         YQ ALBL Y
ALinear#BQuadratic           1         YQ A B Y
L Q

Deviations              (a-1)(b-1)-4   YQ ABDev Y
Residual                    (r-1)(ab-1)    YQU YRes

Statistical Modelling Chapter VII                                                 102
Step 3: Decide between hypotheses
For Deviations
• Only if the terms to which a term is marginal are not
significant then, if Pr{F  F0} = p  a, the evidence
suggests that H0 be rejected and the term must be
incorporated in the model.
• Deviations for A and B are marginal to Deviations for A#B
so that if the latter is significant, neither the Deviations for
A nor for B is tested; indeed no further testing occurs as
the maximal model has to be used to describe the data.
For all Linear and Quadratic terms
• Only if the polynomial terms are not of lower degree than a
significant polynomial term and the terms to which the
term is marginal are not significant then, if Pr{F  F0} = p 
a, the evidence suggests that H0 be rejected; the term and
all polynomial terms of lower degree must be incorporated
in the model.
• For example, Alinear#BLinear is marginal to A#B and is of
lower degree than all other polynomial interaction terms
and so is not tested if any of them is significant.
Statistical Modelling Chapter VII                                       103
Example VII.7 Muzzle velocity of an
antipersonnel weapon (continued)
•   Here is the analysis produced using R, where
> attach(Fac2Muzzle.dat)
> interaction.plot(Vent.Vol, Hole.Area, Velocity, lwd=4)
> Vent.Vol.lev <- c(0.29, 0.4, 0.59, 0.91)
> Fac2Muzzle.dat\$Vent.Vol <-
ordered(Fac2Muzzle.dat\$Vent.Vol, levels=Vent.Vol.lev)
> contrasts(Fac2Muzzle.dat\$Vent.Vol) <- contr.poly(4,
scores=Vent.Vol.lev)
> contrasts(Fac2Muzzle.dat\$Vent.Vol)
> Hole.Area.lev <- c(0.016, 0.03, 0.048, 0.062)
> Fac2Muzzle.dat\$Hole.Area <-
ordered(Fac2Muzzle.dat\$Hole.Area,levels=Hole.Area.lev)
> contrasts(Fac2Muzzle.dat\$Hole.Area) <- contr.poly(4,
scores=Hole.Area.lev)
> contrasts(Fac2Muzzle.dat\$Hole.Area

both factors are converted to ordered
and polynomial contrasts for unequally-
spaced levels obtained
Statistical Modelling Chapter VII                                    104
Contrasts
> contrasts(Fac2Muzzle.dat\$Vent.Vol)
.L         .Q          .C
0.29 -0.54740790 0.5321858 -0.40880670
0.4 -0.31356375 -0.1895091 0.78470636
0.59 0.09034888 -0.7290797 -0.45856278
0.91 0.77062277 0.3864031 0.08266312
> contrasts(Fac2Muzzle.dat\$Hole.Area)
.L   .Q         .C
0.016 -0.6584881 0.5 -0.2576693
0.03 -0.2576693 -0.5 0.6584881
0.048 0.2576693 -0.5 -0.6584881
0.062 0.6584881 0.5 0.2576693
> summary(Fac2Muzzle.aov, split = list(
+         Vent.Vol = list(L=1, Q=2, Dev=3),
+         Hole.Area = list(L=1, Q= 2, Dev=3),
+         "Vent.Vol:Hole.Area" = list(L.L=1, L.Q=2, Q.L=4, Q.Q=5, Dev=c(3,6:9))))
Factor                              B
Table shows                                         Contrast    1     2     3
numbering of                               Contrast  Label      L     Q    Dev
1        L       L.L   L.Q   Dev
contrasts                                                      (1)   (2)   (3)
(standard order;                    A         2        Q       Q.L
(4)
Q.Q
(5)
Dev
(6)
by rows).                                     3       Dev      Dev   Dev   Dev
(7)   (8)   (9)   105
Statistical Modelling Chapter VII
split used for both
R ANOVA                                          factors and interactions
> summary(Fac2Muzzle.aov, split = list(               in the summary function.
+         Vent.Vol = list(L=1, Q=2, Dev=3),
+         Hole.Area = list(L=1, Q= 2, Dev=3),
+         "Vent.Vol:Hole.Area" = list(L.L=1, L.Q=2, Q.L=4, Q.Q=5, Dev=c(3,6:9))))

Error: Test
Df   Sum Sq Mean Sq F value    Pr(>F)
Vent.Vol                                3    379.5   126.5  5.9541 0.0063117
Vent.Vol: L                           1    108.2   108.2  5.0940 0.0383455
Vent.Vol: Q                           1     72.0    72.0  3.3911 0.0841639
Vent.Vol: Dev                         1    199.2   199.2  9.3771 0.0074462
Hole.Area                               3   5137.2 1712.4 80.6092 7.138e-10
Hole.Area: L                          1   4461.2 4461.2 210.0078 1.280e-10
Hole.Area: Q                          1    357.8   357.8 16.8422 0.0008297
Hole.Area: Dev                        1    318.2   318.2 14.9776 0.0013566
Vent.Vol:Hole.Area                      9   3973.5   441.5 20.7830 3.365e-07
Vent.Vol:Hole.Area:            L.L    1   1277.2 1277.2 60.1219 8.298e-07
Vent.Vol:Hole.Area:            L.Q    1     89.1    89.1  4.1962 0.0572893
Vent.Vol:Hole.Area:            Q.L    1   2171.4 2171.4 102.2166 2.358e-08
Vent.Vol:Hole.Area:            Q.Q    1    308.5   308.5 14.5243 0.0015364
Vent.Vol:Hole.Area:            Dev    5    127.2    25.4  1.1975 0.3541807
Residuals                              16    339.9    21.2

Statistical Modelling Chapter VII                                                   106
Analysis summary
Source                         df    SSq      MSq       F        p
Runs                      31
Vent.Vol                  3         379.5    126.5     5.95   0.006
Linear                       1     108.2    108.2     5.09   0.038
Quadratic                    1      72.0     72.0     3.39   0.084
Deviations                   1     199.2    199.2     9.38   0.007
Hole.Area                 3        5137.2   1712.4    80.61   0.000
Linear                       1    4461.2   4461.2   210.01   0.000
Quadratic                    1     357.8    357.8    16.84   0.001
Deviations                   1     318.2    318.2    14.98   0.001
Vent.Vol#Hole.Area        9        3973.5    441.5    20.78   0.000
VLinear#HLinear              1    1277.2   1277.2    60.12   0.000
VLinear#HQuadratic           1      89.1     89.1     4.20   0.057
VQuadratic#HLinear           1    2171.4   2171.4   102.22   0.000
Deviations                   5     127.2     25.4     1.20   0.354
Residual                 16         339.9     21.2
• 5 interaction Deviations lines have been pooled — df and SSq have
• While the Deviations for the interaction is not significant (p = 0.354),
those for both the main effects are significant (p = 0.007 and p = 0.001).
– Hence a smooth response function cannot be fitted.
that interaction terms are required.
• In this case, we must revert to the maximal model.
Statistical Modelling Chapter VII                                                         107
Fitting these submodels in R
• Extension of the procedure for a single factor:
• Having specified polynomial contrasts for each
quantitative factor, the list argument of the summary
function is used to obtain SSqs.
• The general form of the summary function for one factor,
B say, quantitative is (details in Appendix C.5, Factorial
experiments.):
summary(Experiment.aov, split = list(
B = list(L = 1, Q = 2, Dev = 3:(b-1)),
"A:B" = list(L = 1, Q = 2, Dev = 3:(b-1))))
• and for two factors, A and B say, quantitative is
summary(Experiment.aov, split = list(
A = list(L = 1, Q = 2, Dev = 3:(a-1)),
B = list(L = 1, Q = 2, Dev = 3:(b-1)),
"A:B" = list(L.L=1, L.Q=2, Q.L=b, Q.Q=(b+1),
Dev=c(3:(b-1),(b+2:(a-1)(b-1)))))
Statistical Modelling Chapter VII                                      108
VII.G Nested factorial structures
• Nested factorial structures commonly arise when
– a control treatment is included or
– an interaction can be described in terms of one cell being
different to the others.
• Set up
– a factor (One say) with two levels:
• for the control treatment or the different cell
• for the other treatments or cells.
– A second factor (Treats say) with same number of levels as there
are treatments or cells.
• Structure for these two factors is One/Treats
• Terms in the analysis are One + Treats[One].
– One compares the control or single cell with the mean of the
others.
– Treats[One] reflects the differences between the other treatments
or cells.
• Can be achieved using an orthogonal contrast, but
nested factors is more convenient.

Statistical Modelling Chapter VII                                               109
General nested factorial structure
set-up

• An analysis in which there is:
– a term that reflects the average differences
between g groups;
– a term that reflects the differences within
groups or several terms each one of which
reflects the differences within a group.

Statistical Modelling Chapter VII                              110
Example VII.8 Grafting experiment

• For example, consider the following RCBD
experiment involving two factors each at two
levels.
• The response is the percent grafts that take.

B        1             2
A    1        2    1        2
I       64       23   30       15†
II       75       14   50       33
Block III       76       12   41       17
IV        73       33   25       10
†observation  missing; value inserted
so that residual is zero.
Statistical Modelling Chapter VII                                                111
Example VII.8 Grafting experiment
(continued)
a) Description of pertinent features of the study
1. Observational unit
–     a plot
2. Response variable
–     % Take
3. Unrandomized factors
–     Blocks, Plots
4. Randomized factors
–     A, B
5. Type of study
–     Two-factor RCBD

b) The experimental structure
Structure    Formula
unrandomized 4 Blocks/4 Plots
randomized   2 A*2 B
Statistical Modelling Chapter VII                      112
R output
> attach(Fac2Take.dat)
> Fac2Take.dat

70
B

Blocks Plots A B Take                                               1
2

1       1     1 1 1   64

60
2       1     2 2 1   23
3       1     3 1 2   30

50
mean of Take
4       1     4 2 2   15
5       2     1 1 1   75

40
6       2     2 2 1   14
7       2     3 1 2   50

30
8       2     4 2 2   33
9       3     1 1 1   76

20
10      3     2 2 1   12            1                          2

11      3     3 1 2   41                               A

12      3     4 2 2   17                          An interaction
13      4     1 1 1   73
14      4     2 2 1   33
15      4     3 1 2   25
16      4     4 2 2   10
> interaction.plot(A, B, Take, lwd=4)

Statistical Modelling Chapter VII                                                  113
R output (continued)
•    > Fac2Take.aov <- aov(Take ~ Blocks + A * B +
•    +                      Error(Blocks/Plots), Fac2Take.dat)
•    > summary(Fac2Take.aov)
•    Error: Blocks
•           Df Sum Sq Mean Sq
•    Blocks 3 221.188 73.729
•    Error: Blocks:Plots
•              Df Sum Sq Mean Sq F value    Pr(>F)
•    A          1 4795.6 4795.6 52.662 4.781e-05
•    B          1 1387.6 1387.6 15.238 0.003600
•    A:B        1 1139.1 1139.1 12.509 0.006346
•    Residuals 9 819.6      91.1

Statistical Modelling Chapter VII                                    114
R output (continued)
> res <- resid.errors(Fac2Take.aov)
> fit <- fitted.errors(Fac2Take.aov)
> plot(fit, res, pch=16)
> plot(as.numeric(A), res, pch=16)
> plot(as.numeric(B), res, pch=16)
> qqnorm(res, pch=16)
> qqline(res)
> tukey.1df(Fac2Take.aov, Fac2Take.dat,
+                            error.term = "Blocks:Plots")
\$Tukey.SS
[1] 2.879712

\$Tukey.F
[1] 0.02820886

\$Tukey.p
[1] 0.870787

\$Devn.SS
[1] 816.6828
Statistical Modelling Chapter VII                                   115
Recompute for missing value
• Recalculate either in R or in Excel.
• See notes for Excel details
>   #
>   # recompute for missing value
>   #
>   MSq <- c(73.729, 4795.6, 1387.6, 1139.1, 2.8797)
>   Res <- c(rep(819.6/8, 4), 816.6828/7)
>   df.num <- c(3,rep(1,4))
>   df.den <- c(rep(8, 4),7)
>   Fvalue <- MSq/Res
>   pvalue <- 1-pf(Fvalue, df.num, df.den)
>   data.frame(MSq,Res,df.num,df.den,Fvalue,pvalue)
MSq      Res df.num df.den      Fvalue       pvalue
1     73.7290 102.4500      3      8 0.71965837 0.5677335580
2   4795.6000 102.4500      1      8 46.80917521 0.0001320942
3   1387.6000 102.4500      1      8 13.54416789 0.0062170009
4   1139.1000 102.4500      1      8 11.11859444 0.0103158259
5      2.8797 116.6690      1      7 0.02468266 0.8795959255

Statistical Modelling Chapter VII                                   116
Diagnostic checking
Normal Q-Q Plot

15
15

10
10

5
5

Sample Quantiles
res

0
0

-5
-5

-10
-10

20         30   40            50     60         70         80                            -2          -1            0              1           2

fit                                                                               Theoretical Quantiles
15

15
10

10
5

5
res

res
0

0
-5

-5
-10

-10

1.0        1.2        1.4            1.6        1.8        2.0                                      1.0   1.2     1.4             1.6       1.8   2.0
as.numeric(A)                                                                                as.numeric(B)

Statistical Modelling Chapter VII                                                                                                                                               117
Hypothesis test for this example
• Step 1: Set up hypotheses
a) H0: (a)21 - (a)11 - (a)22 + (a)12 = 0
H1: (a)21 - (a)11 - (a)22 + (a)12  0
b) H0: a1 = a2
H1: a1 = a2
c) H0: 1 = 2
H1: 1 = 2
Set a = 0.05.

Statistical Modelling Chapter VII                            118
Hypothesis test for this example (continued)
Step 2: Calculate test statistics
• The ANOVA table for the two-factor RCBD is:
Source            df   SSq     MSq      E[MSq]       F     Prob
Blocks           3     221.9   73.7  BP  4 B
2       2    0.72   0.568

Plots[Blocks]    12    8141.8
A              1     4795.6 4795.6  BP  qA  y  46.81 <0.001
2

B              1     1387.6 1387.6  BP  qB  y  13.54 0.006
2

A#B            1     1139.1 1139.1  BP  qAB  y  11.12 0.010
2

Residual        8†    819.6 102.4  S
2

Nonadditivity 1         2.9  2.9             0.02 0.880
Deviations     7     816.7 116.7
†
Residual degrees of freedom have been reduced by one to allow
for the missing observation
Step 3: Decide between hypotheses
• Note residuals-versus-fitted-values plot reveals nothing untoward, test
for nonadditivity is not significant and the normal probability plot also
appears to be satisfactory.
• Significant interaction between A and B so fitted model is E[Y] =
XAB(a).
Statistical Modelling Chapter VII                                                      119
Table of means
•    Means for combinations of A and B need to be examined.
•    Suppose the researcher wants to determine the level of A that has the greatest take
for each level of B.
> #
> # multiple comparisons
> #
> Fac2Take.tab <- model.tables(Fac2Take.aov,
type="means")
> Fac2Take.tab\$tables\$"A:B"
B
A   1     2
1 72.00 36.50
2 20.50 18.75                        4.52881 102.4  2
> q <- qtukey(0.95, 4, 8)    w  5% =        
2      4
> q
[1] 4.52881                          = 22.91

• no difference between A at level two of B
• there is an A difference at level one of B —
level one of A maximizes.

Statistical Modelling Chapter VII                                                                  120
Best description
> Fac2Take.tab\$tables\$"A:B"
Dim 1 : A
Dim 2 : B
1     2
1 72.00 36.50
2 20.50 18.75
• A and B both at level 1 different from either A or B not at
level 1.
• However, the results are only approximate because of the
missing value.
• Testing for this can be achieved by setting up a factor for
the 4 treatments and a two-level factor that compares the
cell with A and B both at level 1 with the remaining
factors.
• The four-level factor for treatments is then specified as
nested within the two-level factor.

Statistical Modelling Chapter VII                                  121
Re-analysis achieved in R
>  Fac2Take.dat\$Cell.1.1 <- factor(1 + as.numeric(A != "1" | B != "1"))
>  Fac2Take.dat\$Treats <- fac.combine(list(A, B))
>  detach(Fac2Take.dat)
>  attach(Fac2Take.dat)
>  Fac2Take.dat
Blocks Plots A B Take Cell.1.1 Treats
1        1      1 1 1   64       1      1
2        1      2 2 1   23       2      3
3        1      3 1 2   30       2      2
4        1      4 2 2   15       2      4
5        2      1 1 1   75       1      1
6        2      2 2 1   14       2      3
7        2      3 1 2   50       2      2
8        2      4 2 2   33       2      4
9        3      1 1 1   76       1      1
10       3      2 2 1   12       2      3
11       3      3 1 2   41       2      2
12       3      4 2 2   17       2      4
13       4      1 1 1   73       1      1
14       4      2 2 1   33       2      3
15       4      3 1 2   25       2      2
16       4      4 2 2   10       2      4

Statistical Modelling Chapter VII                                        122
Re-analysis (continued)
> Fac2Take.aov <- aov(Take ~ Blocks + Cell.1.1/Treats +
Error(Blocks/Plots), Fac2Take.dat)
> summary(Fac2Take.aov)

Error: Blocks
Df Sum Sq Mean Sq
Blocks 3 221.188 73.729

Error: Blocks:Plots
Df Sum Sq Mean Sq F value     Pr(>F)
Cell.1.1          1 6556.7 6556.7 72.0021 1.378e-05
Cell.1.1:Treats 2 765.5      382.8 4.2032    0.05139
Residuals         9 819.6     91.1
> # recompute for missing value
> MSq <- c(73.729,6556.7,382.8)
> Res <- rep(819.6/8, 3)
> df.num <- c(3, 1, 2)
> Fvalue <- MSq/Res
> pvalue <- 1-pf(Fvalue, df.num, 8)
> data.frame(MSq,Res,df.num,Fvalue,pvalue)
MSq    Res df.num      Fvalue       pvalue
1   73.729 102.45       3 0.7196584 5.677336e-01
2 6556.700 102.45       1 63.9990239 4.367066e-05
3 382.800 102.45        2 3.7364568 7.146140e-02
Statistical Modelling Chapter VII                                 123
Revised analysis of variance table
Source           df    SSq       MSq        F      Prob
Blocks            3    221.9      73.7     0.72    0.568

Plots[Blocks]      12 8141.8
Cell 1,1 vs rest 1 6556.7 6556.7 64.00 <0.001
Among rest        2    765.5     382.8     3.74   0.071
Residual          8†   819.6     102.4
†
the Residual and Total degrees of freedom have been
reduced by one to allow for the missing observation

• Appears difference between the treatments is best
summarized in terms of this single degree of freedom
contrast between cell1,1 and the others.
• The mean for cell 1,1 is 72.0 and, for the other three
treatments, the mean is 25.2, a difference of 46.8.
• Such one-cell interactions are a very common form of
interaction.
Statistical Modelling Chapter VII                                               124
Example VII.9 Spraying sultanas
• An experiment was conducted to investigate the effects of
tractor speed and spray pressure on the quality of dried
sultanas.
• Response was lightness of the dried sultanas measured
using a Hunterlab D25 L colour difference meter.
• Three tractor speeds and two spray pressures resulting in
6 treatment combinations which were applied to 6 plots,
each consisting of 12 vines, using a RCBD with 3 blocks.
• However, these 6 treatment combinations resulted in only
4 rates of spray application as indicated in the following
table.
Table of application rates for the sprayer experiment

-1
Tractor Speed (km hour )
Pressure (kPa)       3.6             2.6                1.8
140            2090            2930               4120
330            2930            4120               5770

Statistical Modelling Chapter VII                                                   125
Set up for analysis
• To analyze this experiment set up:
– a factor, Rates, with 4 levels to compare 4 rate means
– two factors with 3 levels, Rate2 and Rate3, each of
which compares the means of 2 treatment
combinations with the same rate.
Table of factor levels for Rate2 and Rate3 in the sprayer experiment

Rate2                     Rate3
-1              3.6    2.6     1.8       3.6     2.6    1.8
Tractor Speed (km hour )
Pressure (kPa)
140                         1       2      1         1       1     2
330                         3       1      1         1       3     1

• The experimental structure for this experiment is:

Structure    Formula
unrandomized 3 Blocks/ 6 Plots
randomized   4 Rates/(3 Rate2+3 Rate3)
Statistical Modelling Chapter VII                                                                 126
Sources in the ANOVA table
Source           df          E[MSq]
Blocks            2    BP   B
2      2

Plots[Blocks]    15
Rates           3    BP  qR  y 
2

Rate2[Rates]    1    BP  qR2  y 
2

Rate3[Rates]    1    BP  qR3  y 
2

Residual       10    BP
2

Total            17

Statistical Modelling Chapter VII                              127
VII.H Models and hypothesis testing
for three-factor experiments
• Experiment with
– factors A, B and C with a, b and c levels
– each of the abc combinations of A, B and C replicated
r times.
– n = abcr observations.
• The analysis is an extension of that for a two-
factor CRD.
• Initial exploration using interaction plots of two
factors for each level of the third factor.
• use interaction.ABC.plot from the DAE
library.
Statistical Modelling Chapter VII                                   128
a) Using the rules to determine the ANOVA
table 3-factor CRD experiment
a) Description of pertinent features of the study
1. Observational unit
–     a unit
2. Response variable
–     Y
3. Unrandomized factors
–     Units
4. Randomized factors
–     A, B, C
5. Type of study
–     Three-factor CRD

b) The experimental structure
Structure    Formula
unrandomized n Units
randomized   a A*b B*c C
Statistical Modelling Chapter VII                      129
c) Sources derived from the structure formulae

• Randomized only
A*B*C = A + (B*C) + A#(B*C)
= A + B + C + B#C
+ A#B + A#C + A#B#C

Statistical Modelling Chapter VII                    130
d) Degrees of freedom and sums of squares
• The df can be derived by the cross product rule.
– For each factor in the term, calculate the number of
levels minus one and multiply these together.
Unrandomized factors

                                    Randomized factors
MG       MG


MG       MG
Units               U
MU               MU-MG
A           A                B                 B              C        C
MA        MA-MG              MB           MB-MG               MC     MC-MG

AB          A#B          AC                     A#C           BC      B#C
MAB      MAB-MA-MB+MG     MAC            MAC-MA-MC+MG           MBC MBC-MB-MC+MG

ABC                         A#B#C

MABC                 MABC-MAB-MAC-MBC
+MA+MB+MC-MG
Statistical Modelling Chapter VII                                                                        131
e) The analysis of variance table
• Enter the sources for the study, their degrees of
freedom and quadratic forms, into the ANOVA
table below.

f) Maximal expectation and variation models

• Given that the only random factor is Units, the
following are the symbolic expressions for the
maximal expectation and variation models:
– var[Y] = Units
– y = E[Y] = ABC

Statistical Modelling Chapter VII                             132
g)          The expected mean squares

Source                            df            SSq           E[MSq]
Units                            n-1           YQUY
A                              a-1           YQ A Y     U  qA  y 
2

B                              b-1           YQBY       U  qB  y 
2

A#B                         (a-1)(b-1)      YQ ABY      U  qAB  y 
2

C                              c-1           YQCY       U  qC  y 
2

A#C                         (a-1)(c-1)      YQ ACY      U  qAC  y 
2

B#C                         (b-1)(c-1)      YQBCY       U  qBC  y 
2

A#B#C                     (a-1)(b-1)(c-1)   YQ ABCY     U  qABC  y 
2

Residual                     abc(r-1)       YQURes Y   U2

Total                           abcr-1         YQUY

Statistical Modelling Chapter VII                                                    133
b) Indicator-variable models and
estimation for the three-factor CRD
• The models for the expectation:                                              a  = a ijk 
E  Y  = X ABC a  
 a  = a ij 
E  Y  = X AB a   X AC a   XBC   
  =    jk 
 and equivalent models with a pair of 
E  Y  = X AB a   X AC a       two-factors interactions               a  = a  
                                                      ik

 and equivalent models with two factors    a = a i 
 
E  Y  = X A a  XBC                 interacting and one factor independent   
                                            =  j 
 and equivalent models with two factors     =  
 
E  Y  = X AB a                         interacting                                     k
                                          
 and other models consisting of 
           
E  y  = X A a  XB   X C                                
 only main effects              
E  Y  = XG 
• Altogether 19 different models.
Statistical Modelling Chapter VII                                                                   134
Fitted values
• Expressions for fitted values for each model given in
terms of following mean vectors:
A, B,  A  B  , C,  A  C  , Β  C  and  A  Β  C 
• Being means vectors can be written in terms of mean
operators, Ms.                         1 MG =   abcr
Ja  Jb  Jc  Jr

• Further, if Y is arranged so             MA =    1
bcr
Ia  Jb  Jc  Jr
that the associated factors              MB =    1     Ja  Ib  Jc  Jr
acr
A, B, C and the replicates
are in standard order                  MAB =      1
cr
Ia  Ib  Jc  Jr
M operators can be written               MC =    1
abr
Ja  Jb  Ic  Jr
as the direct product of I and
J matrices as follows:                 MAC =     1
br
Ia  Jb  Ic  Jr
MBC =     1
ar
Ja  Ib  Ic  Jr

Statistical Modelling Chapter VII
MABC =     1
r
Ia  Ib  Ic  Jr   135
c) Expected mean squares under
alternative models
• Previously given the E[MSq]s under the maximal model.
• Also need to consider them under alternative models so
that we know what models are indicated by the various
hypothesis tests.
• Basically, need to know under which models q(y) = 0.
• From two-factor case, q(y) = 0 only when the model does
not include a term to which the term for the source is
marginal.
• So, when doing the hypothesis test for a MSq for a fixed
term,
– provided terms to which it is marginal have been ruled out by
prior tests,
– it tests whether the expectation term corresponding to it is zero.
• For example, consider the A#B mean square.
Statistical Modelling Chapter VII                                                    136
An example: the A:B mean square
• Its expected value is  U  qAB  y 
2

• Now, q(y)  0 for models involving the AB term or terms
to which the AB term is marginal.
• All models are of the form         • So q(y)  0 for the models
E  Y  = X ABC a               E  Y  = X ABC a  

            
E  Y  = X AB a  X AC a  XBC                       
E  Y  = X AB a  X AC a   
E  Y  = X AB a   X AC a                                  XBC   
E  Y  = X A a   XBC   
E  Y  = X AB a   XBC   
E  Y  = X AB  a 
E  Y  = X AB a   X AC a 
E  y = X A a   XB    X C  
E  Y  = X AB a   X C 
E  Y  = XG 
E  Y  = X AB a 
• Hence test for A#B, provides a test for whether AB should
be included in the model, provided that the test for A#B#C
has already indicated that ABC can be omitted.
Statistical Modelling Chapter VII                                                    137
d) The hypothesis test
Step 1:       Set up hypotheses                                                                    Term being tested
 a  - a  - a  - a                      
a)      H0:        ijk         ij .         i .k      . jk
                                   ABC
  a   a   a  - a  = 0 for all i,j,k 
           i ..          . j.         ..k      ...     
 a  - a  - a  - a                        
H1:                                                          
ijk          ij .         i .k     . jk
  a   a   a  - a   0 for some i,j,k 
           i ..          . j.         ..k       ...      
b)          
H0: a ij - a i . - a . j  a .. = 0 for all i,j                                     AB
H1:  a     ij
- a i . - a . j  a ..  0      for some i,j          
c)      H0:  a ik
- a i . - a .k  a .. = 0       for all i,k                        AC
H1:  a ik
- a i . - a .k  a ..  0       for some i,k          
d)      H0:       jk
-    j . -   .k    .. = 0    for all j,k                       BC
H1:       jk
-    j . -   .k    ..  0    for some j,k             
e)    H0: a1 = a2 = ... = aa                                                                              A
H1: not all population A means are equal
f)    H0: 1 = 2 = ... = b                                                                              B
H1: not all population B means are equal
g)    H0: 1 = 2 = ... = c                                                                              C
H1: not all population C means are equal
Set a = 0.05.
Statistical Modelling Chapter VII                                                                                              138
Step 2: Calculate test statistics
Source                  df            SSq           E[MSq]
Units                  n-1           YQUY
A                    a-1           YQ A Y     U  qA  y 
2

B                    b-1           YQBY       U  qB  y 
2

A#B               (a-1)(b-1)      YQ ABY      U  qAB  y 
2

C                    c-1           YQCY       U  qC  y 
2

A#C               (a-1)(c-1)      YQ ACY      U  qAC  y 
2

B#C               (b-1)(c-1)      YQBCY       U  qBC  y 
2

A#B#C           (a-1)(b-1)(c-1)   YQ ABCY     U  qABC  y 
2

Residual           abc(r-1)       YQURes Y   U2

Total                 abcr-1         YQUY

• MSqs would be added to this table by taking each SSq
and dividing by its df,
• F statistics computed by dividing all MSqs, except the
Residual MSq, by the Residual MSq, and
• p values obtained for each F statistic.
Statistical Modelling Chapter VII                                                    139
Step 3: Decide between hypotheses
For A#B#C interaction source
• If Pr{F  F0} = p  a, the evidence suggests that
H0 be rejected and the term should be
incorporated in the model.
For A#B, A#C and B#C interaction sources
• Only if A#B#C is not significant, then if Pr{F  F0}
= p  a, the evidence suggests that H0 be
rejected and the term corresponding to the
significant source should be incorporated in the
model.
For A, B and C source
• For each term, only if the interactions involving
the term are not significant, then if Pr{F  F0} = p
 a, the evidence suggests that H0 be rejected
and the term corresponding to the significant
source should be incorporated in the model.
Statistical Modelling Chapter VII                            140
VII.J Exercises
• Ex. VII-1 asks for the complete analysis of a
factorial experiment with qualitative factors
• Ex. VII-2 involves a nested factorial analysis –
not examinable
• Ex. VII-3 asks for the complete analysis of a
factorial experiment with both factors quantitative
• Ex. VII-4 asks for the complete analysis of a
factorial experiment with random treatment
factors
• Ex. VII-5 asks for the complete analysis of a
factorial experiment with interactions between
unrandomized and randomized factors

Statistical Modelling Chapter VII                           141

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 0 posted: 10/8/2012 language: English pages: 139