CONSORT
CONSORT
Richard Gonzalez
Psych 613
Version 2.5 (Oct 2016)
Reading Assignment
• Use randomized block and latin square designs as a stepping stone to factorial designs
1. Factorial ANOVA
The next task is to generalize the one-way ANOVA to test several factors simultane-
ously. We will develop the logic of k-way ANOVA by using two intermediate designs:
randomized block and the latin square. These designs are interesting in their own
right, but our purpose will be to use them as “stepping stones” to factorial ANOVA.
For example, the two-way ANOVA has two treatments, say, A and B. The structural
model is
where i refers to the levels of treatment A, j refers to the levels of treatment B, and
k refers to subjects in the i,j treatment combinations. The main effect for treatment
A tests whether the αs are all equal to zero, the main effect for treatment B tests
whether the βs are all equal to zero, and the interaction tests whether the αβs are all
equal to zero. The sum of squares decomposition for the two-way ANOVA involves
four components (one for each term in the structural model)
If we had ignored the factorial design structure and tested this design with a one-way
ANOVA having I×J cells (number of levels of treatment A times number of levels of
treatment B) SSW would be identical to the factorial ANOVA, and SSB = SSA +
SSB + SSI. Thus, a factorial design is one particular way of decomposing the entire
sum of squares between-subjects (note that Equation 4-2 does not contain a single SS
for groups but has three different SS terms: SSA for the A factor, SSB for the B factor
and SSI for the interaction). The pie chart below represents this relation between the
one way ANOVA and the two way ANOVA. Also, we will see that a factorial ANOVA
is identical to a ONEWAY ANOVA using a special set of orthogonal contrasts.
SSA
SSbet
SSB
SSW SSW
SSI
The signature of this design is that it looks as though it has two factors. However,
because there is only one subject per cell, the interaction term cannot be extracted1 . In
1
Tukey developed a special test of an interaction for the case when there is one observation per cell.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials4-3
a two-way layout when there is one subject per cell, the design is called a randomized
block design. When there are two or more subjects per cell (cell sizes need not be
equal), then the design is called a two-way ANOVA.
Consider this example (Ott, p. 664). An experimenter tests the effects of three differ-
ent insecticides on a particular variety of string beans. Each insecticide is applied to
four plots (i.e., four observations). The dependent variable is the number of seedlings.
Suppose we are unaware of the extra factor and “incorrectly” treat this design as a
one-way ANOVA to test the effects of insecticide. In this case, we treat plots as
“subjects” and get four observations per cell. The structural model is
The corresponding ANOVA source table appears below. We will use the ANOVA
and MANOVA SPSS commands over the next few lectures (e.g., see Appendix 4) and
the aov() command in R. Appendix 1 shows the SPSS commands that generated the
following source table.
The main effect for insecticide is significant. Thus, the null hypothesis that population
α1 = α2 = α3 = 0 is rejected.
Now, suppose each plot was divided into thirds allowing the three insecticides to be
used on the same plot of land. The data are the same but the design now includes
additional information.
But this concept of an interaction is restricted, and is not the same idea that is usually associated with
the concept of an interaction. Thus, I will not discuss this test in this class. For details, however, see
NWK p882-885. Note, in particular, their Equation 21.6 that specifies the special, restricted meaning of an
interaction in the Tukey test for additivity.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials4-4
In addition to the row means (treatment effects for insecticides) we now have column
structural means (treatment effects for plots). The new structural model for this design is
model:
randomized
block design Yij = µ + αi + βj + ij (4-4)
Note that j is not an index for “subjects” but refers to plot. There is only one ob-
servation per each insecticide × plot cell. Plot is considered a “blocking variable”.
We include it not because we are necessarily interested in the effects of plot, but be-
cause we hope it will “soak up” variance from the error term (i.e., decreasing SSerror ).
Some of the variability may be systematically due to plot and we could gain power by
reducing our error term.
sum of squares The sum of squares decomposition for this randomized block design is
decomposition:
randomized
block design SST = SSinsect + SSplot + SSerror (4-5)
where SST = (Yij − Y)2 , SSinsect = b (Yi − Y)2 , SSplot = t (Yj − Y)2 , b is the
P P P
number of blocks and t is the number of treatment conditions. Recall that Y is the
estimated grand mean. We will interpret SSerror later, but for now we can compute
it relatively easily by rearranging Eq 4-5,
The long way to compute SS error directly from raw data is by the definitional formula
Σ(Yij − Y i − Y j + Y )2 (4-7)
where Yij is the score of in row i column j and the other terms are the row mean, the
column mean and the grand mean, respectively.
The source table for the new model appears below. Appendix 2 gives the command
syntax that produced this output.
Compare this partition of SST to the partition we saw for the one-way ANOVA. In
both cases the SSinsect are identical but the SSerror (or SSresidual ) term differs.
What happened? The sum of squares in the one way ANOVA was 409.75. The ran-
domized block design picks up that some of the error term is actually due to the
variability of plot, thus the randomized block design performs an additional partition
of sum of squares–the 409.75 is decomposed into 386.25 for plot and 23.50 for error.
Thus, a major chunk of the original error term was actually due to plot. The random-
ized block design is based on a much smaller error term, and consequently provides a
more powerful test for the insecticide variable. Side by side pie charts helps illustrate
the difference.
Note that while contrasts decomposed SSB (as we saw in Lecture Notes #3), blocking
factors decompose the error SSW. This is an important distinction.
SS Total SS Total
SS Insect SS Insect
SS Within
SS Within SS Plot
Note how the SSW on the left is large (one way ANOVA) but the SSW on the right is
relatively small because the blocking factor Plot soaks up variability. The SSW on the left
equals the sum of SSPlot and SSW on the right.
Notice how in this pair of pie charts, the SSW on the left (the one from the usual
one-way ANOVA) is equal to SSW + SSPlot on the right. That is, adding the plot
blocking factor to the design served to partition some of the sums of squares that
would have been called error in the one-way ANOVA into sum of squares that can be
attributable to the plot factor.
With this more complicated design a change in terminology is needed. The error term
doesn’t necessarily mean the variability of each cell observation from its corresponding
cell mean. So rather than say “sums of squares within cells” we typically say the more
general “sums of squares error” or “sums of squares residual.” Still, some people get
sloppy and say “sum of squares within.”
Lecture Notes #4: Randomized Block, Latin Square, and Factorials4-6
Note that the degrees of freedom for error has dropped too (relative to the previous
analysis without the blocking factor). The formula for the error term in a randomized
block design is N - (number of rows minus one) - (number of columns minus 1) - 1.
The randomized block design allows you to use a variable as a “tool” to account for
some variability in your data that would otherwise be called “noise” (i.e., be put in the
SSerror ). I like to call them blocking variables; Kirk calls them nuisance variables.
But as in many things in academics, one researcher’s blocking variable may be another
researcher’s critical variable of study.
I’ll mention some examples of blocking variables in class. For a blocking variable to
have the desired effect of reducing noise it must be related to the dependent variable.
There is also the tradeoff between reduction of sums of squares error and reduction
in degrees of freedom. For every new blocking factor added to the design, you are
“penalized” on degrees of freedom error. Thus, one does not want to include too many
blocking variables.
The latin square design generalizes the randomized block design by having two block-
ing variables in addition to the treatment variable of interest. The latin square design
has a three way layout, making it similar to a three way ANOVA. The latin square
design only permits three main effects to be estimated because the design is incom-
plete. It is an “incomplete” factorial design because not all cells are represented. For
example, in a 4 × 4 × 4 factorial design there are 64 possible cells. But, a latin square
design where the treatment variable has 4 levels and each of the two blocking vari-
ables have 4 levels, there are only 16 cells. This type of design is useful when it is not
feasible to test all the cells required in a three-way ANOVA, say, because of financial
or time constraints in conducting a study with many cells.
The signature of a latin square design is that a given treatment of interest appears
only once in a given row and a given column. There are many ways of creating “latin
Lecture Notes #4: Randomized Block, Latin Square, and Factorials4-7
squares.” Here is a standard one for the case where there are four treatments, a
blocking factor with four levels and a second blocking factor with four levels.
A B C D
B C D A
C D A B
D A B C
One simple way to create a latin square is to make new rows by shifting the columns
of the previous row by one (see above).
sum of squares The sums of squares decomposition for the latin square design is
decomposition:
latin square
design SST = SStreatment + SSblock1 + SSblock2 + SSerror (4-9)
Appendix 3 shows how to code data from a latin square design so that SPSS can
analyze it.
As with the randomized block design, the latin square design uses blocking variables
to reduce the level of noise. For the latin square design to have the desired effect
the blocking variables must be related to the dependent variable, otherwise you lose
power because of the loss of degrees of freedom for the error term.
4. I’ll discuss the problem of performing contrasts and post hoc tests on randomized and
latin square designs later in the context of factorial designs. Remember that these
two designs are rarely used in psychology and I present them now as stepping stones
to factorial ANOVA.
The assumptions are identical to the one-way ANOVA (equal variance, normality, and
independence). In addition, we assume that the treatment variable of interest and the
blocking variable(s) combine additively (i.e., the structural model holds).
Lecture Notes #4: Randomized Block, Latin Square, and Factorials4-8
Because there is only one observation per cell, it is impossible to check the assumption
on a cell-by-cell basis. Therefore, the assumptions are checked by collapsing all other
variables. For example, in the string bean example mentioned earlier, one can check
the boxplots of the three insecticides collapsing across the plot blocking variable.
Normal probability plots could also be examined in this way. I suggest you also look
at the boxplot and normal probability plot on the blocking factor(s), collapsing over
the treatment variable.
6. Factorial ANOVA
We begin with a simple two-way ANOVA where each factor has two levels (i.e., 2 ×
structural 2 design). The structural model for this design is
model:
factorial anova
Yijk = µ + αi + βj + αβij + ijk (4-10)
The assumptions in a factorial ANOVA are the same as in a one-way ANOVA: equality
of cell variances, normality of cell distributions, and independence.
The only difference between the two-way factorial and the randomized block design is
that in the former more than one subject is observed per cell. This subtle difference
allows the estimation of the interaction effect as distinct from the error term. When
only one subject is observed per cell, then the interaction and the error are confounded
(i.e., they cannot be separated), unless one redefines the concept of interaction as
Tukey did in this “test for additivity,” as discussed in Maxwell & Delaney.
We now illustrate a factorial ANOVA with an example. The experiment involved the
presence or absence of biofeedback (one factor) and the presence or absence of a new
drug (second factor). The dependent variable was blood pressure (from Maxwell &
Delaney, 1990). The structural model tested for these data was Equation 4-10.
The cell means, marginal means (row and column means), and parameter estimates
are (figure of means with 95% CI follows):
biofeedback
drug present absent row means α’s
present 168 186 177 α̂ = −6
absent 188 190 189 α̂ = 6
col means 178 188
β̂’s β̂ = −5 β̂ = 5 µ̂ = 183
210
200
190
180
160 .00
95% CI BLOOD
150 1.00
N= 5 5 5 5
.00 1.00
The α’s are computed by subtracting the grand mean from each row mean; the β’s are
computed by subtracting the grand mean from each column mean. The “interaction”
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-10
ˆ are computed as
estimates αβ ij
ˆ
αβ ij = cell meanij − row meani − col meanj + grand mean (4-12)
biofeedback
drug present absent
present -4 4
absent 4 -4
The s, or residuals, are computed the same way as before: observed score minus
cell mean. Recall that residuals are what’s left over from the observed score after the
“model part” (grand mean, and all main effects and interactions) have been subtracted
out. In symbols,
The data in the format needed for SPSS, the command syntax, and the ANOVA
source table are:
Data are
1 1 158 1
1 1 163 1
1 1 173 1
1 1 178 1
1 1 168 1
1 0 188 2
1 0 183 2
1 0 198 2
1 0 178 2
1 0 193 2
0 1 186 3
0 1 191 3
0 1 196 3
0 1 181 3
0 1 176 3
0 0 185 4
0 0 190 4
0 0 195 4
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-11
0 0 200 4
0 0 180 4
In this example all three effects (two main effects and interaction) are statistically
significant at α = 0.05. To interpret the three tests, we need to refer to the table of
cell and marginal means (i.e., to find out which means are different from which and
the direction of the effects).
Note that each effect in this source table has one degree of freedom in the numerator.
Recall that contrasts have one degree of freedom in the numerator. This suggests
that each of these three effects can be expressed through contrasts. In this case we
have the main effect for biofeedback equivalent to the (1, 1, -1, -1) contrast, the main
effect for drug therapy equivalent to the (1, -1, 1, -1) contrast, and the interaction
equivalent to the (1, -1, -1, 1) contrast. Make sure you understand how the contrast
weights correspond directly to the main effects and interaction tests above.
I’ll now verify that these three contrasts lead to the same three tests as the factorial
ANOVA. I tested these contrasts using ONEWAY. I needed to recode the design to
make it into a one-way factorial. One method to “recode” is to enter a new column of
numbers that uniquely specify each cell (i.e., create a new column in the data set that
is the grouping variable with codes 1-4). The resulting output from the ONEWAY
command is
ANALYSIS OF VARIANCE
SUM OF MEAN F F
SOURCE D.F. SQUARES SQUARES RATIO PROB.
Grp 1 Grp 3
Grp 2 Grp 4
By squaring the observed t values one gets exactly the same results as the three F s
from the previous MANOVA output. For instance, take the t = -2.828 for contrast
1, square it, and you get 8.00, which is the same as the F for the main effect of
biofeedback. This verifies that for a 2 × 2 design these three contrasts are identical to
the tests in the factorial design. Also, what ONEWAY labels “between groups sums of
squares” (1540) is the same as the sum of the three treatment sums of squares in the
MANOVA (500 + 720 + 320). Both analyses yield identical MSE and df for
error. In some cases, the separate variance t test will differ from the pooled variance
t test, but in this contrived example all four cells have the identical standard deviation
of 7.9 so the Welch correction is identical to the pooled version.
Important The 2 × 2 factorial design breaks down into contrasts, as we have just seen. What does
point about
factorial the above exercise demonstrate? The main point is that we can express a factorial,
designs and
contrasts between-subjects design in terms of specific contrasts. How many contrasts does it
take to complete a factorial design? The number of cells minus one (in other words, the
sum of all the degrees of freedom associated with treatment effects and interactions).
More complicated factorial designs such as 3 × 3 designs can also be partitioned into
contrasts but the process is a bit trickier (i.e., getting the omnibus result from a set
of orthogonal contrasts). I defer that discussion to a later time.
I presented one technique, that is, one set of contrasts, to analyze this design. But,
there are other research questions one could ask. One could imagine a researcher
who just wanted to test whether getting a treatment differed from not getting a
treatment. The planned contrast for that hypothesis is (1 1 1 -3). The researcher
could also follow up the contrast with a Tukey test on the cell means (i.e., having
found the above contrast to be significant it would make sense to “fish around” to see
whether the three treatments differ from each other and whether the three treatments
differ from the control). The output from the ONEWAY command for the (1 1 1 -3)
contrast is listed below; the TUKEY pairwise comparisons on the cell means appears
in Appendix 6. Note that in order to get the Tukey test in SPSS on the cell means,
one must convert the design into a one-way factorial as was done here (though the
new procedure in SPSS, UNIANOVA, can perform pairwise comparisons directly in a
factorial design).
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-13
In Appendix 5 I show how to run contrasts directly in the MANOVA command. This
is a complicated command so I’ll explain the syntax in more detail latter.
We will return to this example later because it raises some deep issues about contrasts
and interactions.
7. Multiplicity
The factorial design produces more than one omnibus test per analysis. So new
terminology is needed to conceptualize different error rates. Experiment-wise error
rate is the overall error rate observed by the entire ANOVA. For example, the 2 × 2
factorial ANOVA above yielded three F tests. Obviously, if each is tested at α = 0.05
the multiple comparison problem is present. Few researchers actually do a Bonferroni
correction on main effects and interactions, though some recent textbooks argue that
we should. A second concept is family-wise error, which refers to the error rate within a
particular omnibus test (more correctly, the set of contrasts that one performs within a
particular main effect or interaction). In the one-way ANOVA the distinction between
family-wise and experiment-wise doesn’t exist (both are equivalent) because there is
only one omnibus test. Finally, we have the per-comparison error rate, which is the
α level at which each single-df contrast is tested.
Performing planned contrasts and post hoc tests in factorial designs are (almost)
identical to the way we did them for the one-way ANOVA. The subtle part is whether
we are making comparisons between cell means or between marginal means. The
difference creates a tiny change in the notation for the formulas. We need to take into
account the appropriate number of observations that went into the particular means
that are compared. The issue is merely one of proper book-keeping.
The SPSS ONEWAY command gives the correct result because it uses the right
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-14
error term. Let me explain. Suppose you had a 3 × 3 factorial design and want
to test the (1 -1 0) contrast for the row factor. Our method treats the design as
a one-way with 9 levels (the 9 cells). The contrast would be written out as (1,
-1, 0, 1, -1, 0, 1, -1, 0). This “lumps” together cells 1, 4, 7 and compares them
to cells 2, 5, 8 (ignoring the remaining three cells). The contrast has the correct
number of subjects and the correct error term, regardless of whether you do cell
or marginal comparisons.
Another way to do it by hand would be to take the relevant marginal means (in
this example, the three row means) and apply the following formula to compute
SSC
( a i Yi ) 2
P
(4-13)
P a2i
si
where Yi refers to the marginal means, i is the subscript over the marginal
means, and si is the number of subjects that went into the computation of the
ith marginal mean. Once you have SSC, then you divide it by the MSE from
the factorial ANOVA table to get the F value (the degrees of freedom for the
numerator is 1, the degrees of freedom in the denominator is the same as the
error term).
If you are doing pairwise comparisons of cell means, then the easiest thing to do is
recode the independent variables and run ONEWAY using the same procedures
we recommended for one-way ANOVA. SPSS will give the correct results. This
means that the Tukey and Scheffe will be tested using the number of cells minus
one. No one would question this practice for the Tukey test but some people
may argue that it is too conservative for the Scheffe. The logic of this critique
would be correct if you limited yourself to interaction contrasts (then you could
use the degrees of freedom for the interaction term). Researchers usually want
to test many contrasts so the practice I’m presenting of using “number of groups
- 1” is legitimate.
However, if you want to perform post hoc tests on the marginal means you are
stuck because SPSS does not compute such tests. Just take out your calculator.
The formulas for Tukey, SNK, and Scheffe in the factorial world are similar to
the formulas in the one-way world. The subtle difference is, again, the number of
subjects that went into the computation of the particular marginal means that
are being compared.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-15
Recall that for the one-way ANOVA the (equal n) formula for Tukey’s W is
s
MSE
W = qα (T,v) . (4-14)
n
where k is the number of means in the “family” (i.e., the number of marginal
means for row, or number of marginal means for column) and s is the total number
of subjects that went into the computation of the marginal mean. The MSE and
the associated df’s v is straight from the factorial source table. Comparable
changes are made to SNK.
Recall that
X a2
V(Î) = MSE i (4-17)
si
where df1 depends on the kind of test (either df for treatment A, df for treatment
B, or df for interaction–all these df appear in the ANOVA source table) and s
is the total number of subject that went into the computation of the relevant
means.
The Scheffe test will not yield the same result for contrasts applied to the
marginals as contrasts applied to the individual cells. This is because there
are generally fewer contrasts that could be computed on the marginals than on
the cell mean.
Numerical examples of both Tukey and Scheffe are given starting on page 4-26.
Not easily done in SPSS, so we’ll do them by hand. Exactly the same way as
the factorial design for marginal means. Use the MSE from the source table you
constructed to test the omnibus effects (i.e., the source table corresponding to
the structural model having no interactions).
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-16
effect size The effect size of a contrast (i.e., the analog to R2 , the percentage of variance
accounted for by that contrast) is given by
s
SSC
(4-18)
SSC + SSE
2 P a2
where SSC is the sum of squares for that contrast given by Î / nii and SSE is
the sum of squares error from the full source table. Equation 4-18 is the same
quantity that I called pc /(1-pb ) in Lecture Notes #3.
9. Caveat
You need to be careful when making comparisons between cell means in a factorial
design. The problems you may run into are not statistical, but involve possible con-
founds between the comparisons. Suppose I have a 2 × 2 design with gender and
self-esteem (low/high) as factors. It is not clear how to interpret a difference between
low SE/males and high SE/females because the comparison confounds gender and
self-esteem. Obviously, these confounds would occur when making comparisons that
crisscross rows and columns. If one stays within the same row or within the same
column, then these potential criticisms do not apply as readily. 2 An example where
2
When you limit yourself to comparisons within a row or column you limit the number of possible
comparisons in your “fishing expedition”. There are some procedures that make adjustments, in the same
spirit as SNK, to Tukey and Scheffe to make use of the limited fishing expedition (see Cicchetti, 1976,
Psychological Bulletin, 77, 405-408).
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-17
crisscrossing rows and columns makes sense is the 2 × 2 design presented at the be-
ginning of today’s notes (the biofeedback and drug study). It makes perfect sense to
compare the drug alone condition to the biofeedback alone condition. So, sometimes
it is okay to make comparisons between cell means, just approach the experimen-
tal inferences with caution because there may be confounds that make interpretation
difficult.
Earlier we saw that for the special case of the 2 × 2 factorial design the three omnibus
tests (two main effects and interaction) can be expressed in terms of three contrasts.
This complete equivalence between omnibus tests and contrasts only holds if every
factor has two levels (i.e., a 2 × 2 design, a 2 × 2 × 2 design, etc.). More generally,
whenever the omnibus test has one degree of freedom in the numerator, then it is
equivalent to a contrast. However, if factors have more than two levels, such as in
a 3 × 3 design, then the omnibus tests have more than one degree of freedom in
the numerator and cannot be expressed as single contrasts. As we saw in the one-
way ANOVA, the sums of squares between groups can be partitioned into separate
“pieces”, SSCi , with orthogonal contrasts. If the omnibus test has two or more degrees
of freedom in the numerator (say, T - 1 df’s), then more than one contrast is needed
(precisely, T - 1 orthogonal contrasts).
One conclusion from the connection between main effects/interactions and contrasts is
that main effects and interactions are “predetermined” contrasts. That is, main effects
and interactions are contrasts that make sense given a particular factorial design. For
example, in a 2 × 2 we want to compare row means, column means, and cell means.
SPSS ANOVA and MANOVA commands are programmed to create the omnibus tests
from a set of orthogonal contrasts. Indeed, one way to view a factorial designs is that
they commit the data analyst to a predefined set of orthogonal contrasts.
One is not limited to testing main effects and interactions. Sometimes other par-
titions of the sums of squares, or contrasts, may make more sense. Consider the
biofeedback/drug experiment discussed earlier. The three degrees of freedom could
be partitioned as a) -1 -1 -1 3 to test if there is an effect of receiving a treatment,
b) -1 -1 2 0 to test if receiving both treatments together differs from the addition of
receiving both treatments separately, and c) 0 -1 1 0 to test if there is a difference
between drug alone and biofeedback alone. These three contrasts are orthogonal with
each other. The SPSS ONEWAY output for these three contrasts is:
ANALYSIS OF VARIANCE
SUM OF MEAN F F
SOURCE D.F. SQUARES SQUARES RATIO PROB.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-18
Grp 1 Grp 3
Grp 2 Grp 4
CONTRAST 4 -1.0 -1.0 -1.0 3.0
CONTRAST 5 2.0 -1.0 -1.0 0.0
CONTRAST 6 0.0 -1.0 1.0 0.0
It is instructive to compare the results of these three contrasts to the results previously
obtained for the main effects and interaction. Pay close attention to the difference
between the two models and the null hypotheses they are testing.
11. Interactions
The null hypothesis for the standard interaction (i.e., the 1 -1 -1 1 contrast) in the
biofeedback example is
In other words, is the effect of receiving both drug and biofeedback treatments si-
multaneously relative to receiving nothing equal to the additive combination of 1)
receiving drug treatment alone relative to nothing and 2) receiving biofeedback treat-
ment alone relative to nothing? Said still another way, is the effect of receiving both
treatments simultaneously equal to the sum of receiving each treatment separately
(with everything relative to receiving no treatment)? The presence of a significant
interaction implies a nonadditive effect.
Note that Equation 4-20 is different than the (0 -1 -1 2) contrast comparing both
treatments alone to the two administered together. This contrast is a special case of
the interaction, i.e., when µdrug&bio = µneither then the two tests are the same.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-19
You need to be careful not to use the language of “interactions” if you deviate from the
standard main effect/interaction contrasts. Sloppy language in calling contrasts such
as (1 1 1 -3) “interaction contrasts” has led to much debate (e.g., see the exchange
between Rosenthal, Abelson, Petty and others in Psychological Science, July, 1996).
We will return to the issue of additivity later when discussing the role of transforma-
tions in interpreting interactions.
12. Using plots to interpret main effects and interactions as well as check assumptions
With plots it is relative easy to see the direction and magnitude of the effects. If
you place confidence intervals around the points (using the pooled error term) you
can even get some sense of the variability and visualize the patterns of statistical
significance.
Some people view interactions as the most important test one can do. One function
that interactions serve is to test whether an effect can be turned on or off, or if the
direction of an effect can be reversed. Thus, interactions allow one to test whether
one variable moderates the effects of a second independent variable.
SPSS doesn’t offer great graphics. You might want to invest time in learning a different
program that offers better graphics options such as the statistical program R, or at
least creating graphs in a spreadsheet like Excel. Here are some SPSS commands you
may find useful:
graph
/line(multiple)=mean(dv) by iv1 by iv2.
where dv represents the dependent variable, and iv1, iv2 represent the two independent
variables.
plot errorbars To have errorbars (i.e., 95% CIs around the means) do this instead:
graph
/errorbar(ci 95) = dv by iv1 by iv2.
The first command uses mean(dv) but the second command uses dv. Ideally, it would
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-20
be nice to have the first plot with confidence intervals too, but I haven’t figured out
how to do that in SPSS. Also, this shows how limited the menu system–on my version
of SPSS the menu system only permits one independent variable per plot, but it is
possible to get two independent variables in the same plot if you use syntax.
boxplot; spread The boxplot and the spread and level plot to check for assumption violations and
and level plots
possible transformations can be done in a factorial design as well. The syntax is
Consider the following experiment on learning vocabulary words (Keppel & Zedeck,
1989). A researcher wants to test whether computer-aided instruction is better than
the standard lecture format. He believes that the subject matter may make a difference
as to which teaching method is better, so he includes a second factor, type of lecture.
Lecture has three levels: physical science, social science, and history. Fifth graders are
randomly assigned to one of the six conditions. The same sixty “target” vocabulary
words are introduced in each lecture. All subjects are given a vocabulary test. The
possible scores range from 0-60.
The data in the format for SPSS are listed below. The first column codes type of
lecture, the second column codes method, the third column is the dependent measure,
and the fourth column is a “grouping variable” to facilitate contrasts in ONEWAY. In
Appendix 8 I show smarter ways of doing this coding that doesn’t require re-entering
codes.
1 1 53 1
1 1 49 1
1 1 47 1
1 1 42 1
1 1 51 1
1 1 34 1
1 2 44 2
1 2 48 2
1 2 35 2
1 2 18 2
1 2 32 2
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-21
1 2 27 2
2 1 47 3
2 1 42 3
2 1 39 3
2 1 37 3
2 1 42 3
2 1 33 3
2 2 13 4
2 2 16 4
2 2 16 4
2 2 10 4
2 2 11 4
2 2 6 4
3 1 45 5
3 1 41 5
3 1 38 5
3 1 36 5
3 1 35 5
3 1 33 5
3 2 46 6
3 2 40 6
3 2 29 6
3 2 21 6
3 2 30 6
3 2 20 6
One advantage of using the MANOVA command (in addition to those already men-
tioned) is that MANOVA has a built in subcommand to print boxplots3 :
/plot boxplots.
3
It is possible to get cell by cell boxplots and normal plots using the examine command: examine dv by
iv1 by iv2 /plot npplot, boxplot. Note the double use of the BY keyword, omitting the second BY produces
plots for marginal means instead of cell means.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-22
60
50
40
30
20
METHOD
10
comp
SCORE
0 stand
N= 6 6 6 6 6 6
LECTURE
The equality of variance assumption appears okay–not great, but we can live with it
because of the small sample size. No evidence of outliers.
Lecture
phy soc hist row marginal
comp 46 40 38 41.33
standard 34 12 31 25.67
column marginal 40 26 34.5
60
50
40
Computer
Standard
30
20
10
Y = µ + α + β + αβ + (4-22)
Lecture
phy soc hist
α̂1 = 7.83 α̂1 = 7.83 α̂1 = 7.83
comp β̂1 = 6.50 β̂2 = −7.50 β̂3 = 1.00
ˆ
αβ 11 = −1.83 ˆ = 6.17
αβ ˆ
αβ 13 = −4.33
12
All three effects (two main effects and interaction) are statistically significant at α =
0.05. Two of the three F tests are omnibus tests that are not easy to interpret without
further analysis–which one are those? (Hint: just look at the df column in the source
table.)
A variant of the previous command prints out more information such as boxplot as
well as marginal and cell means.
Now, suppose you had planned to test the contrast comparing the history conditions
to the average of the physical sciences and social sciences. An easy way to do this
would be to create a new grouping variable, ranging from 1 to 6, that codes the six
cells. We conveniently have that variable entered in the raw data file. The contrast
can be tested through the ONEWAY command. Suppose you also want to test the
difference between the physical sciences and social sciences conditions, but only within
the standard lecture format. That could also be tested within the ONEWAY com-
mand. You may also want to test all possible pairwise differences between cells (using
Tukey). The following command illustrates these tests.
ANALYSIS OF VARIANCE
SUM OF MEAN F F
SOURCE D.F. SQUARES SQUARES RATIO PROB.
BETWEEN GROUPS 5 4125.0000 825.0000 14.8381 .0000
WITHIN GROUPS 30 1668.0000 55.6000
TOTAL 35 5793.0000
THE RESULTS OF ALL PAIRWISE COMPARISONS BETWEEN CELLS. NOTE THAT THE q
VALUE USES 6 DF’S IN THE NUMERATOR (NUMBER OF CELL MEANS) AND n IS THE NUMBER
OF SUBJECTS IN THE CELL.
TUKEY-HSD PROCEDURE
RANGES FOR THE 0.050 LEVEL -
SUBSET 1
GROUP Grp 4
MEAN 12.0000
SUBSET 2
GROUP Grp 6 Grp 2 Grp 5 Grp 3
MEAN 31.0000 34.0000 38.0000 40.0000
SUBSET 3
GROUP Grp 2 Grp 5 Grp 3 Grp 1
MEAN 34.0000 38.0000 40.0000 46.0000
One way to understand the Subsets output is to use the picture below. Order the
means along the number line and draw a line that is as long as W (which here equals
13.09) and has one end on the smallest mean. Group means not included within that
line are statistically different from the smallest mean. In this case, all groups are
different from Group 4, creating the first subset. Then move the “line marker” over
to the next mean. Any mean not included in the span of the line marker is different
from the second mean–Group 1 is different from Group 6 (we’ve already determined
that Group 4 differs from Group 6 in the previous subset). Notice that all groups
within the “line marker” are not different from Group 6 by Tukey. Continue moving
the “line marker” to each new Group until the upper end of the line marker matches
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-26
the greatest mean; there we see that Group 6 differs from Group 1 (and also Group 4
differs from Group 1, but we already knew that from Subset 1).
GROUP: 4 6 2 5 3 1
Mean: 10 15 20 25 30 35 40 45
W = 13.09 Sub 1
Sub 2
Sub3
Suppose you want to test all possible pairwise differences between the three column
means (lecture). Do a Tukey (α = 0.05) using the MSE from the ANOVA source
table, look up the q value using degrees of freedom in the numerator equal to 3 (there
are three marginal means), and be sure to take into account the correct number of
subjects that went into that computation of the marginal mean. Note that for this
case on marginal means we will have a different W than in the previous case where
we looked at cell means (different number of means, different number of subjects per
mean).
s
MSE
W = q(k,v) (4-23)
s
r
55.6
= 3.49
12
= 7.51
Thus, any (absolute value of the) pairwise difference must exceed 7.51 to be significant
with an overall α = 0.05. Looking at the column marginals we see that physical v.
social and social v. history are significant comparisons, but physical v. history is not.
Just as an example, suppose we had not planned the (1, 1, -2) contrast on the lecture
marginals but got the idea to test it after seeing the results of the study. We could
perform a Scheffe test to adjust for the post hoc testing. One indirect way of computing
the Scheffe test in SPSS is to convert the problem into a one-way ANOVA. However,
even though we are implementing the contrast on six cells, we intend to interpret the
contrast as a main effect over three cells, hence k = 3. Plugging numbers from the
SPSS output into the Scheffe formula we have
r
S = V(Î)(k-1)Fα,k-1, v (4-24)
√
= 10.55 2 × 3.32
= 27.19
The estimate of the contrast value is -6, so we fail to reject the null hypothesis under
the Scheffe test. The estimate of the contrast (Î) as well as its standard error (10.55)
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-27
are available in the ONEWAY output. Note that the Î and se(Î) correspond to the (1
1 1 1 -2 -2) contrast on the cell means, but I still plug in k = 3 into the Scheffe formula
because the correction for multiplicity applies to the three marginal means (not the
six cells that I used merely as a computational shortcut). Equivalently, I could have
computed the (1 1 -2) on the marginal means directly by hand. This yields an Î = -3
and a se(Î) = 5.27 (this se is based on the three marginal means). The Scheffe test
computed on the marginals in this manner is identical because the two sets of numbers
(the pair from the SPSS output of Î -6 and se(Î) of 10.55 and the respective pair I
computed by hand on the marginals of -3 and 5.27) differ by a factor of 2, so tests
regarding whether Î is greater than S are the same.
Recall that the F test is a ratio of two variances. In a two-way ANOVA there are
three F tests (two main effects and one interaction). The estimates of the variance
are as follows (for cells having equal sample sizes)
where n is the cell sample size, a is the number of levels for factor A, and b is the
number of levels for factor B.
Recall the “don’t care + care divided by don’t care” logic introduced for the one way
ANOVA. Each of the three omnibus tests in the two way factorial ANOVA uses the
MSE term as the error term. In Lecture Notes 5 we will encounter cases where the
MSE term will not be the appropriate error term.
Here are a couple of references that discuss details of how to compute the expected
mean square terms. This could be useful as we introduce more complicated designs
in ANOVA. In class and in these lecture notes I’ll merely assert the expected mean
square terms (and you can memorize them), but those students interested in how
to derive the expected mean square terms can consult these papers. Millman and
Glass (1967), Rules of thumb for writing the ANOVA table, Journal of Educational
Measurement, 4, 41-51; Schultz (1955). Rules of thumb for determining expectations
of mean squares in analysis of variance. Biometrics, 11, 123-135. There are more if
you do a Google search, but these two are classics.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-28
There can be any number of factors. For instance, a 2 × 2 × 2 ANOVA has three
factors each with three levels. It contains three main effects, three two-way interac-
tions, and one three-way interaction. The main effects and two-way interactions are
interpreted exactly the same way as with a 2 × 2 design. For instance, the main effect
of the first factor compares just two means, the two marginal means of that factor
collapsing over all other cells in the design. The new idea is the three-way interaction.
One way to interpret a three-way interaction is to decompose it to smaller parts. For
instance, take just the four cells where the third factor is at the first level, which
creates a 2 × 2 interaction between the four remaining means. Interpret that interac-
tion. Now compute the 2 × 2 interaction for the cells when the third factor is at the
second level. Interpret that two-way interaction. A statistically significant three-way
interaction means that the two-way interaction tested at one level of the third factor
differs from the two-way interaction tested at the second level of the third factor.
This logic extends to any size design, such as a 3 × 4 × 2 means there are three
factors, where the first factor has three levels, the second factor has four levels and
the third factor has two levels.
For example, consider the 2 × 2 plot below. The lines are not parallel so we suspect
an interaction (whether or not the interaction is is statistically significant is a question
of power).
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-29
30 level 2
dep var
20
level 1
10
level 1 level 2
But, watch what happens when we apply a log transformation to the dependent
variable (i.e., we transform the y-axis to log units). The non-parallelism goes away.
level 2
level 1
dep var
level 1 level 2
Why did this happen? The first plot shows the lines are not parallel. We hastily
conclude that an interaction is present. However, using the fact that log(xy) = log(x)
+ log(y), if we had applied the log transform we would have converted the multiplica-
tive effect into an additive effect. For example, the lower left cell is log(6) = log(2)
+ log(3). Perhaps the investigator decided to use a log transformation in order to
satisfy the equality of variance assumption. You can see that the decision to use a
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-30
transformation to improve one assumption on, say, equality of variance, can influence
the presence or absence of the interaction term.
Which scale is correct? There is a sense in which they both are. The point is that
what appears as an interaction may really be a question of having the right scale (i.e.,
having the right model). You can see how two researchers, one who works from the
first, untransformed plot and one who works from the second, transformed plot, can
reach different conclusions about the interaction. Unfortunately, there is no general
statement that could be made to guide researchers about which transformations are
permissible and under which situations.
Let’s do another example. Imagine Galileo studying the relationship between distance,
time, and acceleration using ANOVA4 . What would that look like? How about a 3
× 3 design with three levels of time (shortest, shorter, short) and three levels of
acceleration (little gravity, some gravity, more gravity; say by varying the angle of the
incline). He rolls balls down inclines and measures the distance traveled. Here are
some simulated results.
101
91
81
71 level 3
2
dep var
61
51
41
level 1
31
21
11
1
Actually, these were created by defining time as 2, 4, and 6 units, defining acceleration
as 2, 4, and 6 units, applying the formula
and adding some random noise (from a normal distribution with mean 0 and variance
9). Let’s see what happens when we apply an additive structural model to something
that was created with a multiplicative model. Run MANOVA, examine boxplots, cell
and marginal means, and parameter estimates.
4
There are many legends about Galileo and how he accomplished his science given the instruments he
had available. For instance, when he collected data for the incline experiments, legend has it that he sang
opera to mark time, and when he tested his intuitions about pendulums–that the period of the pendulum
is independent of the mass of the object at the end–he used his pulse to mark time. I don’t know whether
these are true, but they are interesting and plausible stories given that he couldn’t go to the local Meijer’s
store to buy a stop watch.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-31
COMMANDS
[BOXPLOTS OMITTED]
CELL MEANS
Combined Observed Means for ACCEL BY TIME
Variable .. DISTPE
ACCEL 1 2 3
TIME
1 WGT. 2.61239 5.68376 10.30842
UNWGT. 2.61239 5.68376 10.30842
2 WGT. 13.24837 31.35449 48.67356
UNWGT. 13.24837 31.35449 48.67356
3 WGT. 36.79112 70.18670 107.97558
UNWGT. 36.79112 70.18670 107.97558
PARAMETER ESTIMATES
--- Individual univariate .9500 confidence intervals
CONSTANT
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-32
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
The source table shows all three omnibus effects (two main effects and interaction)
are statistically significant. We conclude that time and acceleration have an effect
on distance independent of each of the two main effects. I doubt Galileo would have
become famous reporting those kinds of results.
Now compare what happens when we transform the data to make the multiplicative
model into an additive model. We will use logs to get a structural model that does
not include an interaction.5
5
Test question: Why might a boxplot look worse (additional skewness, different variances, outliers) after
the transformation?
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-33
level 3
2
level 1
dep var
[BOXPLOTS OMITTED]
CELL MEANS
Combined Observed Means for ACCEL BY TIME
Variable .. LNDISTPE
ACCEL 1 2 3
TIME
1 WGT. 1.33736 1.91127 2.49816
UNWGT. 1.33736 1.91127 2.49816
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-34
PARAMETER ESTIMATES
--- Individual univariate .9500 confidence intervals
CONSTANT
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
The interaction is no longer significant. This factorial design is telling us that, on the
log scale, there are only two main effects. There is no interaction effect because the
distance traveled in the log scale is simply the sum of appropriate row and column
effects. Actually, the lack of interaction in the log scale suggests multiplication in the
original scale so that gets at the idea that acceleration and time multiply, which gets
us part of the way there to the law relating distance, acceleration and time.
These examples highlight two main points: 1) the need to be careful about interpreting
particular kinds of interactions and 2) the importance of thinking about the structural
model you are using.
Interactions are very sensitive to the particular scale one is using. There are no
decent nonparametric procedures to handle the general case of factorial designs (see
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-35
Busemeyer, 1980, Psych Bull, 88, 237-244 for a nice explanation of the problem of
scale types and interactions). Developing nonparametric tests for interactions is an
active area of research in statistics.
Before we can perform residual analysis in a sophisticated way, we need go over re-
gression, develop the general linear model, and recast the ANOVA framework into
this general linear model. The end result will be a general technique that can inform
us both about what the model is doing (the “positive side”) and inform us about what
the model is not doing (the “negative side”).
Command syntax:
1 1 56
1 2 49
1 3 65
1 4 60
2 1 84
2 2 78
2 3 94
2 4 93
3 1 80
3 2 72
3 3 83
3 4 85
Command Syntax:
Note how the design subcommand parallels the terms in the structural model.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-37
* * * * * * A N A L Y S I S O F V A R I A N C E * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * *
* W A R N I N G * Too few degrees of freedom in RESIDUAL *
* * error term (DF = 0). *
* * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * A N A L Y S I S O F V A R I A N C E -- DESIGN 1 * * * * * *
RESIDUAL .00 0 .
INSECT 1925.17 2 962.58 . .
PLOT 386.25 3 128.75 . .
INSECT BY PLOT 23.50 6 3.92 . .
Note what happened. The partitioning of sums of squares is identical to the previous source table.
However, because the program attempts to fit four terms when only three are available, the residual
sum of squares is left with zero. The interaction term picks up what before we called residual. Had
there been more than one subject per cell, the variability within cells (i.e., mean square residual)
could have been computed.
The main point. We showed that the SSerror in the randomized block design can be interpreted
as the variability of the cell observations. That is, SSerror is the “interaction” between the two
variables. Because there is only one observation per cell, the “interaction” is actually the error term.
When more than one observation per cell is available, then the interaction term is separate from the
residual term.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-38
Example from Ott (p. 675). A petroleum company was interested in comparing the miles per gallon
achieved by four different gasoline blends (I, II, III, IV). Because there can be considerable variability
due to drivers and due to car models, these two extraneous sources of variability were included as
blocking variables in the following Latin square design.
Each operator drove each car model over a standard course with the assigned gasoline blend by the
Latin square design below. The miles per gallon are the dependent variable.
Car Model
Driver 1 2 3 4
1 IV II III I
2 II III I IV
3 III I IV II
4 I IV II III
1 1 4 15.5
1 2 2 33.9
1 3 3 13.2
1 4 1 29.1
2 1 2 16.3
2 2 3 26.6
2 3 1 19.4
2 4 4 22.8
3 1 3 10.8
3 2 1 31.1
3 3 4 17.1
3 4 2 30.3
4 1 1 14.7
4 2 4 34.0
4 3 2 19.7
4 4 3 21.6
* * * * * * A N A L Y S I S O F V A R I A N C E * * * * * *
Tests of Significance for MPG using UNIQUE sums of squares
Source of Variation SS DF MS F Sig of F
treatment means
I = 23.57 1.31
II = 25.05 2.79
III = 18.05 -4.21
IV = 22.35 0.09
Driver means
1 = 22.92 0.66
2 = 21.27 -0.99
3 = 22.32 0.06
4 = 22.50 0.24
* * * * * * A N A L Y S I S O F V A R I A N C E * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * *
* W A R N I N G * UNIQUE sums-of-squares are obtained assuming *
* * the redundant effects (possibly caused by *
* * missing cells) are actually null. *
* * The hypotheses tested may not be the *
* * hypotheses of interest. Different reorderings *
* * of the model or data, or different contrasts *
* * may result in different UNIQUE sums-of-squares. *
* * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * *
* W A R N I N G * Too few degrees of freedom in RESIDUAL *
* * error term (DF = 0). *
* * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
RESIDUAL .00 0 .
GAS 108.98 3 36.33 . .
DRIVER 5.90 3 1.97 . .
MODEL 247.73 3 82.58 . .
GAS BY DRIVER 23.81 6 3.97 . .
GAS BY MODEL .00 0 . . .
DRIVER BY MODEL .00 0 . . .
GAS BY DRIVER BY MOD .00 0 . . .
Note that this partition does not equal the correct latin square
partition we observed previously. This is because there are missing
cells--this ANOVA is assuming 64 cells but we only supplied 16.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-41
Finally, compare the results of the latin square design to case where
only gasoline type is a factor (i.e., one-way ANOVA ignoring the two
other variables). Command syntax and source table follow.
* * * * * * A N A L Y S I S O F V A R I A N C E * * * * * *
Compare this SS and F with the ones from the latin square. Driver and
car model add considerable noise to the dependent variable. In this
example, the noise is large enough to mask the effects of treatment.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-42
SPSS provides several ways of calculating analysis of variance. You already know how to
use the ONEWAY command. We will discuss two additional commands: ANOVA and
MANOVA.
Unfortunately, there are minor differences between different versions of SPSS (both platform
and version number) in the subcommands of ANOVA and MANOVA. I list commands that
should work for most recent versions. If you are having trouble with your platform/version,
look at the online syntax chart to find the way to perform these commands using your setup.
We’ll be interested in this command as a stepping stone to the more complicated, but
more useful, MANOVA command.
(d) Allows one to do randomized block and latin square designs by not including
interaction terms in the structural model
(b) Be careful: different versions of SPSS have different defaults for handling unequal
sample sizes
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-43
(c) When using the correct approach to the unequal sample size problem (regression
approach) the terms of the structural model cannot be printed (at least on my
version of SPSS)
I think that once you see all the bells and whistles on the MANOVA command you
probably won’t use ANOVA. However, it is still worth spending a little time showing
what the ANOVA command is all about.
The syntax is very similar to the ONEWAY command. The command line reads
where dv stands for name of the dependent variable, and the grouping# refers to the
grouping variables (up to 10).
/maxorders = 1
will suppress all interaction terms. This is useful for fitting randomized block designs
and latin square designs. The default for /maxorders is all; you can specify maxorder
to be any integer relevant to your design. The MANOVA command also has this
feature within its /design subcommand.
You should also specify how the ANOVA command should deal with unequal sample
sizes. The options are unique, experimental, and hierarchical.
/method = unique
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-44
We will deal with the topic of unequal n’s later. For now, just take my word that
the “unique approach” (aka “regression approach”) is preferred. Note that if all cells
have the same number of subjects, then all three techniques (unique, hierarchical,
experimental) will yield the identical result. However, when the sample sizes differ,
then the three approaches will differ.
A very general command. Can do any factorial design. For now we will focus on the
special case of univariate statistics (i.e., one dependent variable). The same command
can be used to analyze repeated-measures and multiple dependent measures
(d) The default for handling unequal sample sizes (regression approach) is the best
of the three approaches
(f) Generates boxplots and normal plots (a nice feature in complicated designs)
(g) Some versions of SPSS also calculate the power of a nonsignificant test (one of
my favorite features). This power calculation can be used to estimate the number
of subjects needed to achieve a significant result given specified Type I and Type
II error rates.
(a) Quite complicated; many subcommands; easy to get the incorrect analysis with-
out being aware that it is incorrect
(c) The analysis of covariance capabilities are not very useful. We will perform
analysis of covariance with the REGRESSION command later.
4. MANOVA syntax
The two necessary requirements are that the command line specify the dependent
variable and list the independent variables. This is just like the ANOVA command.
I list the ones that I will talk about today. Other subcommands will be discussed
later.
DESIGN The DESIGN command is how the user specifies the structural model.
If the user wants all main effects and interactions in the model (i.e., a complete
factorial design), then the DESIGN subcommand can be omitted. That is, if
the DESIGN subcommand is omitted, the program assumes the user wants all
possible terms in the structural model. I’m compulsive about these things and
always write out the complete design (even when the default would automatically
do it for me).
While most of the time you will just use the default setting on the DESIGN
subcommand it is nice feature to have around (e.g., to calculate Latin Square
designs, to test specific models that don’t include all possible main effects and
interactions).
PRINT This subcommand has several options. The most useful include:
(a) CELLINFO: prints means, standard deviations, and confidence intervals (the
latter, according to the manual, if one has SET WIDTH WIDE).
CONTRAST A nice subcommand with many features. The most useful one is
SPECIAL. It allows a user to define the set of orthogonal contrast to test. For
example, consider the case of a 3 × 3 factorial design with treatA and treatB as
the independent variables. The researcher is interested in testing the contrasts
(1, -1, 0) and (1, 1, -2) on treatA. The command is:
The first line of that command contains the variable list. The CONTRAST
command defines an orthogonal set of contrasts for treatA. Note that the unit
vector must be included in the specification of SPECIAL. The PARTITION
subcommand is not required but I include it for completeness. PARTITION
lets SPSS know that you want to split the factor treatA into two pieces each
with one degree of freedom. Finally, the DESIGN subcommand tells SPSS to
calculate each contrast for treatA (as defined by the CONTRAST and PARTI-
TION subcommands), the main effect for treatB, and separately the interaction
of each contrast on treatA with the main effect on treatB.
There are other features of the CONTRAST subcommand, but they are not
as useful as user-defined SPECIAL. If you don’t specify the CONTRAST sub-
command, SPSS will by default calculate the DEVIATION contrasts–which are
equivalent to the parameters of the structural model (i.e., the α’s, β’s, αβ’s, etc.).
PLOT Can produce boxplots and normal plots. Unfortunately, on some versions of
SPSS normal plots are on the marginals even though the boxplots are cell by cell.
However, on some versions of SPSS both the boxplots and the normal plots are
cell by cell. See Footnote 3 on page 4-21 for an alternative using the EXAMINE
command.
You can use this line, for example, to get boxplots and normal probability plots.
ERROR Useful for random-effects models, nested designs, and dealing with unequal
sample sizes. More details on this later, but now I’ll give an example. Suppose
you have a 2 factor, factorial between subjects ANOVA with the usual structural
model Y = µ + α + β + αβ + . In this full model, the MSE is the usual
error term and corresponds to the keyword WITHIN in SPSS (e.g., /ERROR
WITHIN). However, in some situations that we will discuss later, you may want
to have different error terms. For instance, you may want to run the structural
model without the interaction µ + α + β + . In this case, there are three things
you could do with the error term. (1) You could keep the same MSE (that is,
ignore the portion of sum of squares that the interaction picks up). In this case,
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-47
/ERROR WITHIN tells SPSS to ignore the interaction completely. (2) You may
want to use the interaction term as the error term (and NOT use MSE). In this
case /ERROR RESIDUAL tells SPSS to ignore MSE and only use what is left
over in the structural model (i.e., the residual; the terms not explicitly stated
in the /DESIGN line), which here is the interaction term. (3) You may want
to combine the SSE and SSint into a single pooled error term. In this case,
/ERROR WITHIN+RESIDUAL tells SPSS to combine into a single error term
the MSE along with any term not explicitly stated in the design line. The default
in SPSS is /ERROR WITHIN+RESIDUAL. So, if you omit a term in the design
line it automatically gets incorporated into the error term.
POWER SPSS computes power within the MANOVA command by adding these
two lines to your MANOVA syntax.
/power exact
/print signif(all) parameters(all)
By default, MANOVA prints source tables to two values after the decimal places.
Sometimes you want more digits after the decimal place, such as when you need the
MSE to compute something by hand. Currently, there isn’t a straightforward way
around the rounding problem. Here are two temporary kludges:
(a) multiply your raw data by a large number such as 100 or 1000, analyze the new
data, and then divide the MSE in the source table by that number squared
/print error(stddev)
which causes an extra line of output–the square root of the MSE–to be printed to
five values after the decimal (at least on my version of SPSS does this). Simply
square that value to get MSE.
6. UNIANOVA command
The UNIANOVA command is similar to to the MANOVA command with a few ex-
ceptions. It does not require one to specify the levels of the independent variables.
So, one writes
rather than
UNIANOVA
blpr BY biofeed drug
/METHOD = SSTYPE(3)
/POSTHOC = biofeed drug ( TUKEY )
/PRINT = OPOWER TEST(LMATRIX)
/DESIGN = biofeed drug biofeed*drug .
We will talk about SSTYPE in Lecture Notes #5. Note the use of posthoc to define
TUKEY tests on the marginals. In this simple example, because there are two rows
there is no TUKEY test to compute on rows (and similarly, since there are two columns
TUKEY cannot be computed on the column factor either). The PRINT subcommand
also lists two things I want to mention: OPOWER prints out the observed power and
TEST(LMATRIX) presents a different way of printing out the contrasts that SPSS
actually computes. Recall we also found it helpful to print out the contrasts within
the MANOVA command.
The UNIANOVA command does have the ability to perform Tukey tests on the
marginal means, but not the individual cell means. It also computes Scheffe tests,
but as pairwise means rather than for arbitrary contrasts on marginal means (not on
cell means). Contrasts can be called the same way using the same “contrast()=special”
syntax.
There is also an LMATRIX subcommand that let’s you specify specific contrasts
by name without needing an entire set of orthogonal contrasts as required by the
“contrast()=special”.
UNIANOVA
blpr BY biofeed drug
/LMATRIX = "interaction contrast" biofeed*drug 1 -1 -1 1
/DESIGN = biofeed drug biofeed*drug .
If there is more than one contrast for an effect that you want to test you separate the
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-49
lines by a semicolon just repeating the part that goes after the label definition (i.e,.
after the quotes). I’ll explain the meaning of LMATRIX in Lecture Notes
I’m not as familiar with the UNIANOVA command, so best to look at the online help
(e.g., the syntax guide within SPSS for UNIANOVA). From what I can tell it is a
special case of the GLM command discussed next, so might as well just focus on GLM
if you want the latest and greatest SPSS has to offer.
7. GLM command
The GLM command is a relatively new command in SPSS, following similar syntax
to the UNIANOVA command.
For example, the randomized block design with contrasts can be specified like this:
The GLM command also has the POSTHOC marginal means capability as mentioned
above in the UNIANOVA command. There needs to be more than two levels in factor
for post hoc tests. If there are only two levels, then there is only one pairwise test on
the marginal means for that factor so multiple comparisons are not an issue.
I don’t know how to make GLM do posthoc tests like Tukey on individual cells in
a factorial design (the syntax right above performs Tukey on the marginal means).
You can get SPSS to do a Bonferroni correction for all possible cell means using the
subcommand below, but it doesn’t support the Tukey test.
/emmeans = tables(factor1*factor2)
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-50
compare(factor1) adj(bonferroni)
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-51
Command syntax
manova blood by biofeed(0,1) drug(0,1)
/contrast(biofeed) = special(1 1
1 -1)
/contrast(drug) = special(1 1
1 -1)
/design biofeed(1) drug(1) biofeed(1) by drug(1).
Source table
* * * * * * A N A L Y S I S O F V A R I A N C E * * * * * *
The tests printed in this source table are identical to the tests of the three contrasts. Recall
that all F s with one degree of freedom in the numerator are identical to t2 . Contrasts
always have one degree of freedom in the numerator.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-52
TUKEY-HSD PROCEDURE
RANGES FOR THE 0.050 LEVEL -
G G G G
r r r r
p p p p
Mean Group 1 3 2 4
168.0000 Grp 1
186.0000 Grp 3 *
188.0000 Grp 2 *
190.0000 Grp 4 *
SUBSET 1
GROUP Grp 1
MEAN 168.0000
SUBSET 2
Here is an experiment testing the effects of wall color and room size on anxiety level during
an interview (Hays, 1988). Assume that the anxiety measure is reliable. Lower numbers
reflect lower anxiety scores. The four room colors were red, yellow, green, and blue (coded
as 1, 2, 3, and 4, respectively). The three room sizes were small, medium, and large (coded
1, 2, and 3).
It will be useful to try the various SPSS features to get a feel for what happens. I will
now perform for your viewing pleasure several different runs of MANOVA on the same data
to illustrate many features. Of course, in most data analysis situations only one run of
MANOVA is required. All assumptions have been checked and appear okay; for simplicity
here I focus on the statistical analysis.
Data 2 2 156
2 2 159
2 3 83
2 3 89
1 1 160 2 3 79
1 1 155 2 4 110
1 1 170 2 4 87
1 2 134 2 4 100
1 2 139 3 1 180
1 2 144 3 1 154
1 3 104 3 1 141
1 3 175 3 2 170
1 3 96 3 2 133
1 4 86 3 2 128
1 4 71 3 3 84
1 4 112 3 3 86
2 1 175 3 3 83
2 1 152 3 4 105
2 1 167 3 4 93
2 2 159 3 4 85
NOW ADD A PRINT SUBCOMMAND TO GIVE INFO ON THE CELL MEANS AND PARAMETER
ESTIMATES OF THE STRUCTURAL MODEL. THE OMEANS COMMANDS GIVES MARGINAL
MEANS AS WELL. NOTE THAT THE DESIGN COMMANDS DOESN’T SAY ANYTHING SO IT
DEFAULTS TO THE PUTTING ALL POSSIBLE TERMS IN THE MODEL.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-54
SIZE small
COLOR red 161.667 7.638 3 142.694 180.640
COLOR yellow 139.000 5.000 3 126.579 151.421
COLOR green 125.000 43.486 3 16.975 233.025
COLOR blue 89.667 20.744 3 38.134 141.199
SIZE medium
COLOR red 164.667 11.676 3 135.661 193.672
COLOR yellow 158.000 1.732 3 153.697 162.303
COLOR green 83.667 5.033 3 71.163 96.170
COLOR blue 99.000 11.533 3 70.351 127.649
SIZE large
COLOR red 158.333 19.858 3 109.003 207.663
COLOR yellow 143.667 22.942 3 86.675 200.658
COLOR green 84.333 1.528 3 80.539 88.128
COLOR blue 94.333 10.066 3 69.327 119.340
For the entire sample 125.111 35.100 36 113.235 136.987
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
TURNS OUT THE PARAMETER VALUES ARE IDENTICAL TO THE ESTIMATES OF THE
STRUCTURAL MODEL (THE ALPHAS, BETAS, ALPHABETAS), BUT WE DON’T KNOW THE
CONTRASTS CORRESPONDING TO THOSE "I HATS". WE COULD USE DESIGN(SOLUTION) TO
FORCE SPSS TO PRINT OUT THE CONTRASTS IT USED.
NOW ASK FOR A PRINT OUT OF THE DESIGN MATRIX AS WELL AS ORTHOGONAL
PARAMETER ESTIMATES. I ALSO SPECIFY SPECIFIC CONTRASTS I WANT TO TEST.
NOTE HOW I SPECIFY SEPARATELY FOR EACH FACTOR.
1 2 1 2 3 4 5 6 7 8 9 10
1 1 -.50000 .61237 .35355 .50000 -.50000 -.50000 .61237 .61237 .61237 .35355
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-56
1 2 -.50000 .61237 .35355 .50000 .50000 .50000 .61237 -.61237 -.6123 .35355
1 3 -.50000 .61237 .35355 -.50000 .50000 -.50000 -.61237 -.61237 .61237 -.35355
1 4 -.50000 .61237 .35355 -.50000 -.50000 .50000 -.61237 .61237 -.61237 -.35355
2 1 -.50000 -.61237 .35355 .50000 -.50000 -.50000 -.61237 -.61237 -.61237 .35355
2 2 -.50000 -.61237 .35355 .50000 .50000 .50000 -.61237 .61237 .61237 .35355
2 3 -.50000 -.61237 .35355 -.50000 .50000 -.50000 .61237 .61237 -.61237 -.35355
2 4 -.50000 -.61237 .35355 -.50000 -.50000 .50000 .61237 -.61237 .61237 -.35355
3 1 -.50000 .00000 -.70711 .50000 -.50000 -.50000 .00000 .00000 .00000 -.70711
3 2 -.50000 .00000 -.70711 .50000 .50000 .50000 .00000 .00000 .00000 -.70711
3 3 -.50000 .00000 -.70711 -.50000 .50000 -.50000 .00000 .00000 .00000 .70711
3 4 -.50000 .00000 -.70711 -.50000 -.50000 .50000 .00000 .00000 .00000 .70711
1 2 11 12
1 1 .35355 .35355
1 2 -.35355 -.35355
1 3 -.35355 .35355
1 4 .35355 -.35355
2 1 .35355 .35355
2 2 -.35355 -.35355
2 3 -.35355 .35355
2 4 .35355 -.35355
3 1 -.70711 -.70711
3 2 .70711 .70711
3 3 .70711 -.70711
3 4 -.70711 .70711
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
1 2 1 2 3 4 5 6 7 8 9 10
1 1 -.50000 .61237 -.35355 .50000 -.50000 .50000 -.61237 .61237 -.61237 .35355
1 2 -.50000 .61237 -.35355 .50000 .50000 -.50000 -.61237 -.61237 .61237 .35355
1 3 -.50000 .61237 -.35355 -.50000 .50000 .50000 .61237 -.61237 -.61237 -.35355
1 4 -.50000 .61237 -.35355 -.50000 -.50000 -.50000 .61237 .61237 .61237 -.35355
2 1 -.50000 -.61237 -.35355 .50000 -.50000 .50000 .61237 -.61237 .61237 .35355
2 2 -.50000 -.61237 -.35355 .50000 .50000 -.50000 .61237 .61237 -.61237 .35355
2 3 -.50000 -.61237 -.35355 -.50000 .50000 .50000 -.61237 .61237 .61237 -.35355
2 4 -.50000 -.61237 -.35355 -.50000 -.50000 -.50000 -.61237 -.61237 -.61237 -.35355
3 1 -.50000 .00000 .70711 .50000 -.50000 .50000 .00000 .00000 .00000 -.70711
3 2 -.50000 .00000 .70711 .50000 .50000 -.50000 .00000 .00000 .00000 -.70711
3 3 -.50000 .00000 .70711 -.50000 .50000 .50000 .00000 .00000 .00000 .70711
3 4 -.50000 .00000 .70711 -.50000 -.50000 -.50000 .00000 .00000 .00000 .70711
1 2 11 12
1 1 -.35355 .35355
1 2 .35355 -.35355
1 3 .35355 .35355
1 4 -.35355 -.35355
2 1 -.35355 .35355
2 2 .35355 -.35355
2 3 .35355 .35355
2 4 -.35355 -.35355
3 1 .70711 -.70711
3 2 -.70711 .70711
3 3 -.70711 -.70711
3 4 .70711 .70711
R-Squared = .827
Adjusted R-Squared = .748
SIZE(1)
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
2 2.5000000000 7.19439 .34749 .73125 -12.34849 17.34849
SIZE(2)
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
3 14.8333333333 12.46105 1.19038 .24554 -10.88501 40.55168
COLOR(1)
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
4 116.4444444444 11.74839 9.91152 .00000 92.19696 140.69193
COLOR(2)
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
5 11.3333333333 11.74839 .96467 .34433 -12.91415 35.58082
COLOR(3)
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
6 18.0000000000 11.74839 1.53212 .13857 -6.24749 42.24749
SIZE(1) BY COLOR(1)
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
7 -54.0000000000 28.77756 -1.87646 .07280 -113.39397 5.39397
SIZE(1) BY COLOR(2)
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
8 -34.6666666667 28.77756 -1.20464 .24009 -94.06064 24.72730
SIZE(1) BY COLOR(3)
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
9 66.6666666667 28.77756 2.31662 .02938 7.27270 126.06064
SIZE(2) BY COLOR(1)
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
10 -20.6666666667 49.84420 -.41463 .68210 -123.54004 82.20671
SIZE(2) BY COLOR(2)
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
11 -40.0000000000 49.84420 -.80250 .43014 -142.87338 62.87338
SIZE(2) BY COLOR(3)
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
12 40.0000000000 49.84420 .80250 .43014 -62.87338 142.87338
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
2 164.6666666667 10.17441 16.18440 .00000 143.66773 185.66561
3 158.3333333333 10.17441 15.56193 .00000 137.33439 179.33227
COLOR
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
4 139.0000000000 10.17441 13.66173 .00000 118.00106 159.99894
5 125.0000000000 10.17441 12.28573 .00000 104.00106 145.99894
6 89.6666666667 10.17441 8.81296 .00000 68.66773 110.66561
SIZE BY COLOR
Parameter Coeff. Std. Err. t-Value Sig. t Lower -95% CL- Upper
7 158.0000000000 10.17441 15.52916 .00000 137.00106 178.99894
8 83.6666666667 10.17441 8.22325 .00000 62.66773 104.66561
9 99.0000000000 10.17441 9.73030 .00000 78.00106 119.99894
10 143.6666666667 10.17441 14.12040 .00000 122.66773 164.66561
11 84.3333333333 10.17441 8.28877 .00000 63.33439 105.33227
12 94.3333333333 10.17441 9.27163 .00000 73.33439 115.33227
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-60
The R syntax for factorial ANOVAs is just a simple extension of the one-way ANOVA
version described in LN3. The aov() command takes the structural model as the main
argument, so the only difference from LN3 is how you specify the structural model.
The code below assumes equal number of subjects per cell and an orthogonal set of contrasts.
More general code will be given in Lecture Notes 5.
This example estimates a randomized block design (a plus sign between the two factors)
A factorial design is estimated by replacing the + with a ∗ (where ∗ means the interaction
and include all lower terms):
or, equivalently, if you want to write out the complete structural model you do the following
where the colon “:” denotes the specific interaction term (analogous to the word BY in SPSS)
The above can all be done using the lm() command instead of the aov() command. I use
the lm() command when running orthogonal contrasts; still run lm() with nonorthogonal
contrasts just careful with how I interpret the betas in the regression (more in LN 5 and
when we get to regression).
You compute contrasts the same way as described in LN3 for the one-way ANOVA. Each
factor will have contrasts defined for it using the contrast() command, and you print out
the source table and t-tests as described in LN3.
I prefer NOT to use default contrasts in R. I define contrasts for all factors before doing
any analyses. The default R contrasts are dummy codes and they can produce very strange
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-61
results sometimes. For example, it can produce incorrect results using fit.contrasts when
defining main effect contrasts. If you want to test this where factorA has 3 levels and
factorB has 2 levels
you’ll get an incorrect test because the other factor contrast isn’t defined and reverts to the
default dummy code. Instead, one needs to define all contrasts for all factors as in
and this yields the correct result for the -1, 1, 0 marginal contrast on factorA.
For a completely between-subjects factorial design (what we’re doing throughout this set
of lecture notes) you could instead convert the factorial structure into a single one-way
ANOVA (e.g., a 2x3 is recoded as a single factor with six groups), and then you apply the
same commands as described in LN3. This just makes use of the fact that a completely
between-subjects factorial ANOVA is equivalent to a one-way ANOVA with as many group
as cells in the factorial design (see last Appendix in this lecture notes). In that case, the
code I wrote for the separate variance contrast test and the Scheffe test (LN3) will work for
recoded factorial designs. You can also use the tukeyHSD() command to test all possible
pairwise differences in the individual cells. This recoding procedure to convert a factorial
into a one-way ANOVA unfortunately looses the ability to perform Tukey tests on the
marginal means since main effect information is lost. But you can compute those by hand.
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-62
Variable B
1 2 3 4
1
2
3
Now I’ll put in the codes for row and column denoting each cell.
Variable B
Variable A 1 2 3 4
1 1,1 1,2 1,3 1,4
2 2,1 2,2 2,3 2,4
3 3,1 3,2 3,3 3,4
Variable B
Variable A 1 2 3 4
1 83 59 24 63
2 31 25 48 67
3 22 35 19 81
In SPSS I would enter the data as follows (first column codes the row variable, the second
column codes the column variable, and the third column lists data).
1 1 8
1 1 3
1 2 5
1 2 9
1 3 2
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-63
1 3 4
1 4 6
1 4 3
2 1 3
2 1 1
2 2 2
2 2 5
2 3 4
2 3 8
2 4 6
2 4 7
3 1 2
3 1 2
3 2 3
3 2 5
3 3 1
3 3 9
3 4 8
3 4 1
To recode this factorial design as a oneway ANOVA I could do one of three things:
1. Create a new column of data manually that codes the 12 groups from 1 to 12. This is
tedious and will work properly, but is probably not something you want to do when
you have 100s or 1000s of subjects because of all the typing (and chances to make
errors).
2. Use a series of if-then statements in SPSS. For instance, the following creates a new
set of codes ranging from 1 to 12:
3. The “I can do it in one line” procedure. In SPSS, the following line creates a new
grouping code ranging from 1 to 12:
Lecture Notes #4: Randomized Block, Latin Square, and Factorials
4-64
On some versions of SPSS you may need to follow that compute line with the “execute.”
command.
Double check that this formula works as advertised. When varA = 1 and varB = 1,
newcode will be 1; ETC.; when varA = 3 and varB = 4, newcode will be 12.
If your codes do not start at 1, you’ll need to adjust the formula accordingly.
Any of the above procedures can be used to achieve the identical result of re-coding a
factorial, between-subjects ANOVA into a oneway ANOVA.