Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
The TRANSREG Procedure

ANOVA Codings

This set of examples illustrates several different ways to code the same two-way ANOVA model. Figure 65.33 displays the input data set.

   title 'Two-way ANOVA Models';

   data x;
      input a b @@;
      do i = 1 to 2; input y @@; output; end;
      drop i;
      datalines;
   1 1   16 14         1 2   15 13
   2 1    1  9         2 2   12 20
   3 1   14  8         3 2   18 20
   ;

   proc print label;
   run;

Two-way ANOVA Models

Obs a b y
1 1 1 16
2 1 1 14
3 1 2 15
4 1 2 13
5 2 1 1
6 2 1 9
7 2 2 12
8 2 2 20
9 3 1 14
10 3 1 8
11 3 2 18
12 3 2 20

Figure 65.33: Input Data Set

The following statements fit a cell-means model. See Figure 65.34 and Figure 65.35.

   proc transreg data=x ss2 short;
      title2 'Cell-Means Model';
      model identity(y) = class(a * b / zero=none);
      output replace;
   run;

   proc print label;
   run;

Two-way ANOVA Models
Cell-Means Model

The TRANSREG Procedure

Identity(y)
Algorithm converged.

The TRANSREG Procedure Hypothesis Tests for Identity(y)

Univariate ANOVA Table Based on the Usual Degrees of Freedom
Source DF Sum of Squares Mean Square F Value Pr > F
Model 5 234.6667 46.93333 3.20 0.0946
Error 6 88.0000 14.66667    
Corrected Total 11 322.6667      

Root MSE 3.82971 R-Square 0.7273
Dependent Mean 13.33333 Adj R-Sq 0.5000
Coeff Var 28.72281    

Univariate Regression Table Based on the Usual Degrees of Freedom
Variable DF Coefficient Type II
Sum of
Squares
Mean Square F Value Pr > F Label
Class.a1b1 1 15.0000000 450.000 450.000 30.68 0.0015 a 1 * b 1
Class.a1b2 1 14.0000000 392.000 392.000 26.73 0.0021 a 1 * b 2
Class.a2b1 1 5.0000000 50.000 50.000 3.41 0.1144 a 2 * b 1
Class.a2b2 1 16.0000000 512.000 512.000 34.91 0.0010 a 2 * b 2
Class.a3b1 1 11.0000000 242.000 242.000 16.50 0.0066 a 3 * b 1
Class.a3b2 1 19.0000000 722.000 722.000 49.23 0.0004 a 3 * b 2

Figure 65.34: Cell-Means Model

The parameter estimates are

\hat{\mu}_{11} & = & \overline{y}_{11} = 15 \\hat{\mu}_{12} & = & \overline{y}_{...
 ...}_{31} & = & \overline{y}_{31} = 11 \\hat{\mu}_{32} & = & \overline{y}_{32} = 19

Two-way ANOVA Models
Cell-Means Model

Obs _TYPE_ _NAME_ y Intercept a 1 *
b 1
a 1 *
b 2
a 2 *
b 1
a 2 *
b 2
a 3 *
b 1
a 3 *
b 2
a b
1 SCORE ROW1 16 . 1 0 0 0 0 0 1 1
2 SCORE ROW2 14 . 1 0 0 0 0 0 1 1
3 SCORE ROW3 15 . 0 1 0 0 0 0 1 2
4 SCORE ROW4 13 . 0 1 0 0 0 0 1 2
5 SCORE ROW5 1 . 0 0 1 0 0 0 2 1
6 SCORE ROW6 9 . 0 0 1 0 0 0 2 1
7 SCORE ROW7 12 . 0 0 0 1 0 0 2 2
8 SCORE ROW8 20 . 0 0 0 1 0 0 2 2
9 SCORE ROW9 14 . 0 0 0 0 1 0 3 1
10 SCORE ROW10 8 . 0 0 0 0 1 0 3 1
11 SCORE ROW11 18 . 0 0 0 0 0 1 3 2
12 SCORE ROW12 20 . 0 0 0 0 0 1 3 2

Figure 65.35: Cell-Means Model, Design Matrix

The following statements fit a reference cell model. The default reference level is the last cell (3,2). See Figure 65.36 and Figure 65.37.

   proc transreg data=x ss2 short;
      title2 'Reference Cell Model, (3,2) Reference Cell';
      model identity(y) = class(a | b);
      output replace;
   run;

   proc print label;
   run;

Two-way ANOVA Models
Reference Cell Model, (3,2) Reference Cell

The TRANSREG Procedure

Identity(y)
Algorithm converged.

The TRANSREG Procedure Hypothesis Tests for Identity(y)

Univariate ANOVA Table Based on the Usual Degrees of Freedom
Source DF Sum of Squares Mean Square F Value Pr > F
Model 5 234.6667 46.93333 3.20 0.0946
Error 6 88.0000 14.66667    
Corrected Total 11 322.6667      

Root MSE 3.82971 R-Square 0.7273
Dependent Mean 13.33333 Adj R-Sq 0.5000
Coeff Var 28.72281    

Univariate Regression Table Based on the Usual Degrees of Freedom
Variable DF Coefficient Type II
Sum of
Squares
Mean Square F Value Pr > F Label
Intercept 1 19.0000000 722.000 722.000 49.23 0.0004 Intercept
Class.a1 1 -5.0000000 25.000 25.000 1.70 0.2395 a 1
Class.a2 1 -3.0000000 9.000 9.000 0.61 0.4632 a 2
Class.b1 1 -8.0000000 64.000 64.000 4.36 0.0817 b 1
Class.a1b1 1 9.0000000 40.500 40.500 2.76 0.1476 a 1 * b 1
Class.a2b1 1 -3.0000000 4.500 4.500 0.31 0.5997 a 2 * b 1

Figure 65.36: Reference Cell Model, (3,2) Reference Cell

The parameter estimates are

\hat{\mu}_{32} & = & \overline{y}_{32} = 19 \\hat{\alpha}_{1} & = & \overline{y}...
 ...at{\mu}_{32} + \hat{\alpha}_{2} + \hat{\beta}_{1}) =
5 - (19 + -3 + -8) = -3 \ \

The structural zeros are

\alpha_3 \equiv \beta_2 \equiv \gamma_{12}
\equiv \gamma_{22} \equiv \gamma_{31} \equiv \gamma_{32} \equiv 0

Two-way ANOVA Models
Reference Cell Model, (3,2) Reference Cell

Obs _TYPE_ _NAME_ y Intercept a 1 a 2 b 1 a 1 *
b 1
a 2 *
b 1
a b
1 SCORE ROW1 16 1 1 0 1 1 0 1 1
2 SCORE ROW2 14 1 1 0 1 1 0 1 1
3 SCORE ROW3 15 1 1 0 0 0 0 1 2
4 SCORE ROW4 13 1 1 0 0 0 0 1 2
5 SCORE ROW5 1 1 0 1 1 0 1 2 1
6 SCORE ROW6 9 1 0 1 1 0 1 2 1
7 SCORE ROW7 12 1 0 1 0 0 0 2 2
8 SCORE ROW8 20 1 0 1 0 0 0 2 2
9 SCORE ROW9 14 1 0 0 1 0 0 3 1
10 SCORE ROW10 8 1 0 0 1 0 0 3 1
11 SCORE ROW11 18 1 0 0 0 0 0 3 2
12 SCORE ROW12 20 1 0 0 0 0 0 3 2

Figure 65.37: Reference Cell Model, (3,2) Reference Cell, Design Matrix

The following statements fit a reference cell model, but this time the reference level is the first cell (1,1). See Figure 65.38 through Figure 65.39.

   proc transreg data=x ss2 short;
      title2 'Reference Cell Model, (1,1) Reference Cell';
      model identity(y) = class(a | b / zero=first);
      output replace;
   run;

   proc print label;
   run;

Two-way ANOVA Models
Reference Cell Model, (1,1) Reference Cell

The TRANSREG Procedure

Identity(y)
Algorithm converged.

The TRANSREG Procedure Hypothesis Tests for Identity(y)

Univariate ANOVA Table Based on the Usual Degrees of Freedom
Source DF Sum of Squares Mean Square F Value Pr > F
Model 5 234.6667 46.93333 3.20 0.0946
Error 6 88.0000 14.66667    
Corrected Total 11 322.6667      

Root MSE 3.82971 R-Square 0.7273
Dependent Mean 13.33333 Adj R-Sq 0.5000
Coeff Var 28.72281    

Univariate Regression Table Based on the Usual Degrees of Freedom
Variable DF Coefficient Type II
Sum of
Squares
Mean Square F Value Pr > F Label
Intercept 1 15.000000 450.000 450.000 30.68 0.0015 Intercept
Class.a2 1 -10.000000 100.000 100.000 6.82 0.0401 a 2
Class.a3 1 -4.000000 16.000 16.000 1.09 0.3365 a 3
Class.b2 1 -1.000000 1.000 1.000 0.07 0.8027 b 2
Class.a2b2 1 12.000000 72.000 72.000 4.91 0.0686 a 2 * b 2
Class.a3b2 1 9.000000 40.500 40.500 2.76 0.1476 a 3 * b 2

Figure 65.38: Reference Cell Model, (1,1) Reference Cell

The parameter estimates are

\hat{\mu}_{11} & = & \overline{y}_{11} = 15 \\hat{\alpha}_{2} & = &
\overline{y}...
 ...at{\mu}_{11} + \hat{\alpha}_{3} + \hat{\beta}_{2}) =
19 - (15 + -4 + -1) = 9 \ \

The structural zeros are

\alpha_1 \equiv \beta_1 \equiv \gamma_{11}
\equiv \gamma_{12} \equiv \gamma_{21}
\equiv \gamma_{31} \equiv 0

Two-way ANOVA Models
Reference Cell Model, (1,1) Reference Cell

Obs _TYPE_ _NAME_ y Intercept a 2 a 3 b 2 a 2 *
b 2
a 3 *
b 2
a b
1 SCORE ROW1 16 1 0 0 0 0 0 1 1
2 SCORE ROW2 14 1 0 0 0 0 0 1 1
3 SCORE ROW3 15 1 0 0 1 0 0 1 2
4 SCORE ROW4 13 1 0 0 1 0 0 1 2
5 SCORE ROW5 1 1 1 0 0 0 0 2 1
6 SCORE ROW6 9 1 1 0 0 0 0 2 1
7 SCORE ROW7 12 1 1 0 1 1 0 2 2
8 SCORE ROW8 20 1 1 0 1 1 0 2 2
9 SCORE ROW9 14 1 0 1 0 0 0 3 1
10 SCORE ROW10 8 1 0 1 0 0 0 3 1
11 SCORE ROW11 18 1 0 1 1 0 1 3 2
12 SCORE ROW12 20 1 0 1 1 0 1 3 2

Figure 65.39: Reference Cell Model, (1,1) Reference Cell, Design Matrix

The following statements fit a deviations-from-means model. The default reference level is the last cell (3,2). This coding is also called effects coding. See Figure 65.40 and Figure 65.41.

   proc transreg data=x ss2 short;
      title2 'Deviations From Means, (3,2) Reference Cell';
      model identity(y) = class(a | b / deviations);
      output replace;
   run;

   proc print label;
   run;

Two-way ANOVA Models
Deviations From Means, (3,2) Reference Cell

The TRANSREG Procedure

Identity(y)
Algorithm converged.

The TRANSREG Procedure Hypothesis Tests for Identity(y)

Univariate ANOVA Table Based on the Usual Degrees of Freedom
Source DF Sum of Squares Mean Square F Value Pr > F
Model 5 234.6667 46.93333 3.20 0.0946
Error 6 88.0000 14.66667    
Corrected Total 11 322.6667      

Root MSE 3.82971 R-Square 0.7273
Dependent Mean 13.33333 Adj R-Sq 0.5000
Coeff Var 28.72281    

Univariate Regression Table Based on the Usual Degrees of Freedom
Variable DF Coefficient Type II
Sum of
Squares
Mean Square F Value Pr > F Label
Intercept 1 13.3333333 2133.33 2133.33 145.45 <.0001 Intercept
Class.a1 1 1.1666667 8.17 8.17 0.56 0.4837 a 1
Class.a2 1 -2.8333333 48.17 48.17 3.28 0.1199 a 2
Class.b1 1 -3.0000000 108.00 108.00 7.36 0.0349 b 1
Class.a1b1 1 3.5000000 73.50 73.50 5.01 0.0665 a 1 * b 1
Class.a2b1 1 -2.5000000 37.50 37.50 2.56 0.1609 a 2 * b 1

Figure 65.40: Deviations-From-Means Model, (3,2) Reference Cell

The parameter estimates are

\hat{\mu} & = & \overline{y} = 13.33333 \\hat{\alpha}_{1} & = & (\overline{y}_{1...
 ... \hat{\alpha}_{2} + \hat{\beta}_{1}) =
5 - (13.33333 + -2.83333 + -3) = -2.5 \ \

The structural zeros are

\alpha_3 \equiv \beta_2 \equiv \gamma_{12}
\equiv \gamma_{22} \equiv \gamma_{31} \equiv \gamma_{32} \equiv 0

Two-way ANOVA Models
Deviations From Means, (3,2) Reference Cell

Obs _TYPE_ _NAME_ y Intercept a 1 a 2 b 1 a 1 * b 1 a 2 * b 1 a b
1 SCORE ROW1 16 1 1 0 1 1 0 1 1
2 SCORE ROW2 14 1 1 0 1 1 0 1 1
3 SCORE ROW3 15 1 1 0 -1 -1 0 1 2
4 SCORE ROW4 13 1 1 0 -1 -1 0 1 2
5 SCORE ROW5 1 1 0 1 1 0 1 2 1
6 SCORE ROW6 9 1 0 1 1 0 1 2 1
7 SCORE ROW7 12 1 0 1 -1 0 -1 2 2
8 SCORE ROW8 20 1 0 1 -1 0 -1 2 2
9 SCORE ROW9 14 1 -1 -1 1 -1 -1 3 1
10 SCORE ROW10 8 1 -1 -1 1 -1 -1 3 1
11 SCORE ROW11 18 1 -1 -1 -1 1 1 3 2
12 SCORE ROW12 20 1 -1 -1 -1 1 1 3 2

Figure 65.41: Deviations-From-Means Model, (3,2) Reference Cell, Design Matrix

The following statements fit a deviations-from-means model, but this time the reference level is the first cell (1,1). This coding is also called effects coding. See Figure 65.42 through Figure 65.43.

   proc transreg data=x ss2 short;
      title2 'Deviations From Means, (1,1) Reference Cell';
      model identity(y) = class(a | b / deviations zero=first);
      output replace;
   run;

   proc print label;
   run;

Two-way ANOVA Models
Deviations From Means, (1,1) Reference Cell

The TRANSREG Procedure

Identity(y)
Algorithm converged.

The TRANSREG Procedure Hypothesis Tests for Identity(y)

Univariate ANOVA Table Based on the Usual Degrees of Freedom
Source DF Sum of Squares Mean Square F Value Pr > F
Model 5 234.6667 46.93333 3.20 0.0946
Error 6 88.0000 14.66667    
Corrected Total 11 322.6667      

Root MSE 3.82971 R-Square 0.7273
Dependent Mean 13.33333 Adj R-Sq 0.5000
Coeff Var 28.72281    

Univariate Regression Table Based on the Usual Degrees of Freedom
Variable DF Coefficient Type II
Sum of
Squares
Mean Square F Value Pr > F Label
Intercept 1 13.3333333 2133.33 2133.33 145.45 <.0001 Intercept
Class.a2 1 -2.8333333 48.17 48.17 3.28 0.1199 a 2
Class.a3 1 1.6666667 16.67 16.67 1.14 0.3274 a 3
Class.b2 1 3.0000000 108.00 108.00 7.36 0.0349 b 2
Class.a2b2 1 2.5000000 37.50 37.50 2.56 0.1609 a 2 * b 2
Class.a3b2 1 1.0000000 6.00 6.00 0.41 0.5461 a 3 * b 2

Figure 65.42: Deviations-From-Means Model, (1,1) Reference Cell

The parameter estimates are

\hat{\mu} & = & \overline{y} = 13.33333 \\hat{\alpha}_{2} & = & (\overline{y}_{2...
 ...y} + \hat{\alpha}_{3} + \hat{\beta}_{2}) =
19 - (13.33333 + 1.66667 + 3) = 1 \ \

The structural zeros are

\alpha_1 \equiv \beta_1 \equiv \gamma_{11}
\equiv \gamma_{12} \equiv \gamma_{21}
\equiv \gamma_{31} \equiv 0

Two-way ANOVA Models
Deviations From Means, (1,1) Reference Cell

Obs _TYPE_ _NAME_ y Intercept a 2 a 3 b 2 a 2 * b 2 a 3 * b 2 a b
1 SCORE ROW1 16 1 -1 -1 -1 1 1 1 1
2 SCORE ROW2 14 1 -1 -1 -1 1 1 1 1
3 SCORE ROW3 15 1 -1 -1 1 -1 -1 1 2
4 SCORE ROW4 13 1 -1 -1 1 -1 -1 1 2
5 SCORE ROW5 1 1 1 0 -1 -1 0 2 1
6 SCORE ROW6 9 1 1 0 -1 -1 0 2 1
7 SCORE ROW7 12 1 1 0 1 1 0 2 2
8 SCORE ROW8 20 1 1 0 1 1 0 2 2
9 SCORE ROW9 14 1 0 1 -1 0 -1 3 1
10 SCORE ROW10 8 1 0 1 -1 0 -1 3 1
11 SCORE ROW11 18 1 0 1 1 0 1 3 2
12 SCORE ROW12 20 1 0 1 1 0 1 3 2

Figure 65.43: Deviations-From-Means Model, (1,1) Reference Cell, Design Matrix

The following statements fit a less-than-full-rank model. The parameter estimates are constrained to sum to zero within each effect. See Figure 65.44 and Figure 65.45.

   proc transreg data=x ss2 short;
      title2 'Less Than Full Rank Model';
      model identity(y) = class(a | b / zero=sum);
      output replace;
   run;

   proc print label;
   run;

Two-way ANOVA Models
Less Than Full Rank Model

The TRANSREG Procedure

Identity(y)
Algorithm converged.

The TRANSREG Procedure Hypothesis Tests for Identity(y)

Univariate ANOVA Table Based on the Usual Degrees of Freedom
Source DF Sum of Squares Mean Square F Value Pr > F
Model 5 234.6667 46.93333 3.20 0.0946
Error 6 88.0000 14.66667    
Corrected Total 11 322.6667      

Root MSE 3.82971 R-Square 0.7273
Dependent Mean 13.33333 Adj R-Sq 0.5000
Coeff Var 28.72281    

Univariate Regression Table Based on the Usual Degrees of Freedom
Variable DF Coefficient Type II
Sum of
Squares
Mean Square F Value Pr > F Label
Intercept 1 13.3333333 2133.33 2133.33 145.45 <.0001 Intercept
Class.a1 1 1.1666667 8.17 8.17 0.56 0.4837 a 1
Class.a2 1 -2.8333333 48.17 48.17 3.28 0.1199 a 2
Class.a3 1 1.6666667 16.67 16.67 1.14 0.3274 a 3
Class.b1 1 -3.0000000 108.00 108.00 7.36 0.0349 b 1
Class.b2 1 3.0000000 108.00 108.00 7.36 0.0349 b 2
Class.a1b1 1 3.5000000 73.50 73.50 5.01 0.0665 a 1 * b 1
Class.a1b2 1 -3.5000000 73.50 73.50 5.01 0.0665 a 1 * b 2
Class.a2b1 1 -2.5000000 37.50 37.50 2.56 0.1609 a 2 * b 1
Class.a2b2 1 2.5000000 37.50 37.50 2.56 0.1609 a 2 * b 2
Class.a3b1 1 -1.0000000 6.00 6.00 0.41 0.5461 a 3 * b 1
Class.a3b2 1 1.0000000 6.00 6.00 0.41 0.5461 a 3 * b 2

The sum of the regression table DF's, minus one for the intercept, will be greater than the model df when there are ZERO=SUM constraints.

Figure 65.44: Less-Than-Full-Rank Model

The parameter estimates are

\hat{\mu} & = & \overline{y} = 13.33333 \\hat{\alpha}_{1} & = & (\overline{y}_{1...
 ...ine{y} + \hat{\alpha}_{3} + \hat{\beta}_{2}) =
19 - (13.33333 + 1.66667 + 3) = 1

The constraints are

\alpha_1 + \alpha_2 + \alpha_3 \equiv \beta_1 + \beta_2 \equiv 0
\gamma_{11} + \gamma_{12} \equiv
\gamma_{21} + \gamma_{22} \equiv
\gamma_{31} + ...
 ...gamma_{21} + \gamma_{31} \equiv
\gamma_{12} + \gamma_{22} + \gamma_{32} \equiv 0

Two-way ANOVA Models
Less Than Full Rank Model

Obs _TYPE_ _NAME_ y Intercept a 1 a 2 a 3 b 1 b 2 a 1 *
b 1
a 1 *
b 2
a 2 *
b 1
a 2 *
b 2
a 3 *
b 1
a 3 *
b 2
a b
1 SCORE ROW1 16 1 1 0 0 1 0 1 0 0 0 0 0 1 1
2 SCORE ROW2 14 1 1 0 0 1 0 1 0 0 0 0 0 1 1
3 SCORE ROW3 15 1 1 0 0 0 1 0 1 0 0 0 0 1 2
4 SCORE ROW4 13 1 1 0 0 0 1 0 1 0 0 0 0 1 2
5 SCORE ROW5 1 1 0 1 0 1 0 0 0 1 0 0 0 2 1
6 SCORE ROW6 9 1 0 1 0 1 0 0 0 1 0 0 0 2 1
7 SCORE ROW7 12 1 0 1 0 0 1 0 0 0 1 0 0 2 2
8 SCORE ROW8 20 1 0 1 0 0 1 0 0 0 1 0 0 2 2
9 SCORE ROW9 14 1 0 0 1 1 0 0 0 0 0 1 0 3 1
10 SCORE ROW10 8 1 0 0 1 1 0 0 0 0 0 1 0 3 1
11 SCORE ROW11 18 1 0 0 1 0 1 0 0 0 0 0 1 3 2
12 SCORE ROW12 20 1 0 0 1 0 1 0 0 0 0 0 1 3 2

Figure 65.45: Less-Than-Full-Rank Model, Design Matrix

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.