Help the Stat Consulting Group by giving a gift

Design and Analysis by Keppel

Chapter 11

Example 11.1a..SPSS MANOVA

Example 11.1b. SPSS GLM

Example 11.1c. SAS PROC GLM

Example 11.2b SPSS GLM

Example 11.2c SAS PROC GLM

Example 11.3b SPSS GLM

Example 11.3c SAS PROC GLM

**11.1 Comparison of Marginal Means, Page 234 of Keppel**

Assume you wish to perform a comparison of marginal means comparing level

a_{1}toa_{3 }as shown on page 234 of section 11.1 in Keppel. This can be analyzed using SPSSmanova, SPSSglm, or SASglm. All of these examples use theCHAP10(SPSS, SAS) data file.

**Example 11.1a. SPSS MANOVA**

MANOVA errors BY a(1,3) b(1,2) /ERROR = W /CONTRAST(a) = SPECIAL(1 1 1 1 0 -1 1 -2 1) /DESIGN = a(1) a(2) b a by b.

The

/contrastsubcommand supplies the contrast coefficients to be applied to factorA. The first row of coefficients is a series of 1's (corresponding to the number of levels of factorA). This row is always required. The coefficients in the second and third row form the first and second contrast applied to factorA. The second row specifies the contrast of interest, comparinga_{1}toa_{3}. Because thespecialmatrix must be square, a third row of coefficients is required (preferably orthogonal to the previous rows), hence the third row comparinga_{2}to(a_{1}&a_{3}) was included.

The

/design = a(1)subcommand tells SPSS to test the effect of the first contrast applied toa(i.e. the second row of thespecialmatrix). Therefore, the/design = a(1)subcommand tells SPSS to comparea_{1}toa_{3}, the comparison of interest. The/error=wsubcommand tells SPSS to use the within cells variance for computing the error term (some versions of SPSS use WITHIN+RESIDUAL as the error term).

**Example 11.1b. SPSS GLM**

GLM errors BY a b /LMATRIX = 'a1 vs. a3' a 1 0 -1 a*b 1/2 1/2 0 0 -1/2 -1/2 .

The

/lmatrixsubcommand is used to in this example to comparea_{1}toa_{3}. As this example shows, the contrast coefficients of 1 0 -1 are applied toa. For the contrast to be estimable in SPSSglm(version 7.5 or below), contrast coefficients must be supplied for any higher order effects which are present in the model. In this example, there is a higher order effect present, thea*binteraction. The coefficients applied toamust be distributed evenly acrossa*bfor the test to be estimable. This is the reason for the coefficients which are applied to a*b in the/lmatrixsubcommand in this example. It is possible that this requirement may be removed in future versions of SPSSglm.

**Example 11.1c. SAS PROC GLM**

PROC GLM DATA=chap10; CLASS a b; MODEL errors = a b a*b; CONTRAST 'a1 vs a3' a 1 0 -1 ; RUN;

The

contrastsubcommand is used inproc glmto comparea_{1}toa_{3}. As this example shows, the contrast coefficients of1 0 -1are applied toato perform this comparison. Note that unlike SPSSglm, it is not necessary to provide contrast coefficients for the higher order effects. SASproc glmautomatically performs this distribution for you.

**Summary: 11.1 Comparison of Marginal Means **

SPSS

manovaand SASproc glmseem to offer the simplest method of obtaining simple comparisons. SPSSmanovaadds the additional burden that you must supply a square matrix of (preferably orthogonal) contrast coefficients, whereas SASproc glmpermits you to supply only the contrasts you wish to test in thecontraststatement. When analyzing a factorial design, SPSSglmposes the complication of needing to supply contrast coefficients for not only the effect of interest, but also all higher order interactions involving that effect

**11.2 Analyzing Simple Effects, Page 241 of Keppel**

In section 11.3, page 241, Keppel shows how to test the simple effect of "

Aatb_{1}" and "Aatb_{2}" This analysis can be performed in SPSSmanova, SPSSglm, or SASproc glm. All of these examples theCHAP10(SPSS, SAS) data file.

**Example 11.2a. SPSS MANOVA**

MANOVA errors BY a(1,3) b(1,2) /ERROR = W /DESIGN = b a WITHIN b(1) a WITHIN b(2).

The

/designsubcommand is used to specify a simple effect. In this example, thea within b(1)effect tests the effect of "Aatb_{1}", and thea within b(2)effect tests the effect of "Aatb_{2}". The/error=wsubcommand is used to use the within cells variance as the error term.

**Example 11.2b. SPSS GLM**

GLM errors BY a b /EMMEANS TABLES(a*b) COMPARE(a).

Simple effects in SPSS GLM can be requested using the

/emmeanssubcommand with thetables(a*b)andcompare(a)options. In this example, these options request the simple effect of factorAat each level of factorB, in this case the simple effect of "Aatb_{1}" and "Aatb_{2}". Note that thecompareoption became available in SPSS version 7.5.

**Example 11.2c. SAS PROC GLM**

PROC GLM DATA=chap10; CLASS a b; MODEL errors = a b a*b; LSMEANS a*b / SLICE = b; run;

Simple effects can be requests in SAS

proc glmusing thelsmeanscommand with thesliceoption. Theslice = boption requests that thea*binteraction be examined at each level of factorA, in other words it requests the simple effect of "Aatb_{1}" and "Aatb_{2}".

**Summary: 11.2 Analyzing Simple Effects**

There are no striking advantages or disadvantages among the three strategies shown for obtaining simple effects. Each of these strategies offer a straightforward method of requesting simple effects.

**11.3 Analyzing Simple Comparisons, Page 246 of Keppel**

On page 246 of Keppel, simple comparisons are illustrated comparing

a_{1}toa_{2}atB_{1}anda_{1}toa_{2}atB_{2}. This simple comparison can be performed in SPSSmanova, SPSSglm, and SASproc glmas shown in the following examples. These examples use theCHAP10(SPSS, SAS)data file.

**Example 11.3a. SPSS MANOVA.**

MANOVA errors BY a(1,3) b(1,2) /ERROR = W /CONTRAST(a) = SPECIAL(1 1 1 1 -1 0 1 1 -2) /DESIGN = b a(1) WITHIN b(1) a(1) WITHIN b(2) a(2) WITHIN b(1) a(2) WITHIN b(2).

The

/contrastsubcommand is used to supply the contrast coefficients to comparea_{1}toa_{2}(via the second row of thespecialmatrix,1 -1 0). The/designsubcommand is used to specify the simple comparison, "Aat_{comp.}b_{1}" . For example,a(1) within b(1)means to compare"a_{1}toa_{2}atB. The_{1}"/error = wsubcommand instructs SPSS to use the within cells variance as the error term.

**Example 11.3b. SPSS GLM.**

GLM errors BY a b /LMATRIX = 'a1 vs a2 at b1' a 1 -1 0 a*b 1 0 -1 0 0 0 /LMATRIX = 'a1 vs a2 at b2' a 1 -1 0 a*b 0 1 0 -1 0 0.

In SPSS

glm, the/lmatrixsubcommand is used to request a simple comparison. The first/lmatrixsubcommand requests the comparison ofa_{1}versusa_{2}atB_{1}. Such a comparison is requested by simultaneously applying contrast coefficients toaand toa*b. The "a_{1}versusa_{2}atB_{1}" effect is requested by applying a contrast to factorawhich comparesa_{1}versusa_{2}(i.e.,1 -1 0) and a contrast toa*bwhich comparesa_{1}versusa_{2}only withinB. Think of the contrast coefficients applied to_{1}a*bas having 3 rows corresponding to the three levels ofAand 2 columns corresponding to the 2 levels ofB, as illustrated below.

b1 b2 a1 1 0 a2 -1 0 a3 0 0

The second

/lmatrixsubcommand also requests a simple comparison of "a_{1}vsa_{2}atB". The coefficients applied to_{2}aare the same as the first example because both compareavs_{1}a. The difference lies in the contrasts applied to_{2}a*b. In the second example, the contrast is in the second column of thea*bmatrix, indicating that the comparison takes place withinB._{2}

Note:It may appear thatarepresents rows andbrepresents columns because the terma*bwas used in the/lmatrixsubcommand. Actually, this ordering is determined by the order of the variables in theglmcommand. Becauseaprecededbin theglmcommand,arepresents rows andbrepresents columns.

The

a*bmatrix can also be thought of as one long vector whereaincrements slowest, andbincrements faster (becauseaappeared first in theglmcommand it increments slowest). Hence, the items in thea*bcontrast matrix are in the following order,

a_{1}b_{1}a_{1}b_{2}a_{2}b_{1}a_{2}b_{2}a_{3}b_{1}a_{3}b_{2}

**Example 11.3c. SAS PROC GLM.**

PROC GLM DATA=chap10; CLASS a b; MODEL errors = a b a*b; CONTRAST 'a1 vs a2 at b1' a 1 -1 0 a*b 1 0 -1 0 0 0 ; CONTRAST 'a1 vs a2 at b2' a 1 -1 0 a*b 0 1 0 -1 0 0; RUN;

When using SAS

proc glm, thecontrastcommand is used to request a simple comparison. Comparing Example 11.3b with Example 11.3c shows that SPSSglmand SASproc glmuse the same contrast coefficients to request a simple comparisons. Please refer to to example 11.3b for an explanation of how the contrast coefficients were chosen to request this simple comparison.

Note:It may appear thatarepresents rows andbrepresents columns because the terma*bwas used in thecontrastsubcommand. Actually, this ordering is determined by the order of the variables in theclasscommand. Becauseaprecededbin theclasscommand,arepresents rows andbrepresents columns.

The

a*bmatrix can also be thought of as one long vector whereaincrements slowest, andbincrements faster (becauseaappeared first in theclasscommand it increments slowest). Hence, the items in thea*bcontrast matrix are in the following order,

a_{1}b_{1}a_{1}b_{2}a_{2}b_{1}a_{2}b_{2}a_{3}b_{1}a_{3}b_{2}

**Summary: 11.3 Analyzing Simple Comparisons**

SPSS

manovamay offer the simplest strategy for requesting simple comparisons because it does not require the coding of contrast coefficients like SPSSglmand SASproc glm. Constructing contrast coefficients for simple comparisons can be very tricky, and there are very few checks to ensure that the contrast you have input corresponds to the contrast you truly desire. If there are features in SPSSglmor SASproc glmwhich provide a compelling reason for using these programs, it may be prudent to run the same analysis in SPSSmanovato double check the results.

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.