The TRANSREG Procedure

Main-Effects ANOVA

(View the complete code for this example.)

This example shows how to use PROC TRANSREG to code and fit a main-effects ANOVA model. PROC TRANSREG has very extensive and versatile options for coding or creating so-called dummy variables. PROC TRANSREG is commonly used to code classification variables before they are used for analysis in other procedures. See the sections Using the DESIGN Output Option and Discrete Choice Experiments: DESIGN, NORESTORE, NOZERO. In this example, the input data set contains the dependent variables y, factors x1 and x2, and 12 observations. PROC TRANSREG can be useful for coding even before running procedures with a CLASS statement because of its detailed options that enable you to control how the coded variable names and labels are constructed. The following statements perform a main-effects ANOVA and display the results in Figure 119.12 and Figure 119.13:

title 'Introductory Main-Effects ANOVA Example';

data a;
   input y x1 $ x2 $;
   datalines;
8 a a
7 a a
4 a b
3 a b
5 b a
4 b a
2 b b
1 b b
8 c a
7 c a
5 c b
2 c b
;
* Fit a main-effects ANOVA model with 1, 0, -1 coding;
proc transreg ss2;
   model identity(y) = class(x1 x2 / effects);
   output coefficients replace;
run;

* Display TRANSREG output data set;
proc print label;
   format intercept -- x2a 5.2;
run;

The SS2 a-option requests results based on Type II sums of squares. The simple ANOVA model is fit by designating y as an IDENTITY variable, which specifies no transformation. The independent variables are specified with a CLASS expansion, which replaces them with coded variables. There are coded variables created by the CLASS specification, since the two CLASS variables have 3 and 2 different values or levels. In this case, the EFFECTS t-option is specified. This option requests an effects coding (displayed in Figure 119.13), which is also called a deviations from means or 0, 1, –1 coding. The OUTPUT statement requests an output data set with the data and coded variables. The COEFFICIENTS output option, or o-option, adds the parameter estimates and marginal means to the data set. The REPLACE o-option specifies that the transformed variables should replace the original variables in the output data set. The output data set variable names are the same as the original variable name. In an example like this, there are no nonlinear transformations; the transformed variables are the same as the original variables. The REPLACE o-option is used to eliminate unnecessary and redundant transformed variables from the output data set. The results of the PROC TRANSREG step are shown in Figure 119.12.

Figure 119.12: ANOVA Example Output from PROC TRANSREG

Introductory Main-Effects ANOVA Example

The TRANSREG Procedure


Dependent Variable Identity(y)

Class Level Information
ClassLevelsValues
x13a b c
x22a b

Number of Observations Read12
Number of Observations Used12


The TRANSREG Procedure Hypothesis Tests for Identity(y)

Univariate ANOVA Table Based on the Usual Degrees of Freedom
SourceDFSum of SquaresMean SquareF ValuePr > F
Model357.0000019.0000019.830.0005
Error87.666670.95833  
Corrected Total1164.66667   

Root MSE0.97895R-Square0.8814
Dependent Mean4.66667Adj R-Sq0.8370
Coeff Var20.97739  

Univariate Regression Table Based on the Usual Degrees of Freedom
VariableDFCoefficientType II
Sum of
Squares
Mean SquareF ValuePr > FLabel
Intercept14.6666667261.333261.333272.70<.0001Intercept
Class.x1a10.83333334.1674.1674.350.0705x1 a
Class.x1b1-1.666666716.66716.66717.390.0031x1 b
Class.x2a11.833333340.33340.33342.090.0002x2 a


Figure 119.12 shows the ANOVA results, fit statistics, and regression tables. The output data set, with the coded design, parameter estimates and means, is shown in Figure 119.13. For more information about PROC TRANSREG for ANOVA and other codings, see the section ANOVA Codings.

Figure 119.13: Output Data Set from PROC TRANSREG

Introductory Main-Effects ANOVA Example

Obs_TYPE__NAME_yInterceptx1 ax1 bx2 ax1x2
1SCOREROW181.001.000.001.00aa
2SCOREROW271.001.000.001.00aa
3SCOREROW341.001.000.00-1.00ab
4SCOREROW431.001.000.00-1.00ab
5SCOREROW551.000.001.001.00ba
6SCOREROW641.000.001.001.00ba
7SCOREROW721.000.001.00-1.00bb
8SCOREROW811.000.001.00-1.00bb
9SCOREROW981.00-1.00-1.001.00ca
10SCOREROW1071.00-1.00-1.001.00ca
11SCOREROW1151.00-1.00-1.00-1.00cb
12SCOREROW1221.00-1.00-1.00-1.00cb
13M COEFFIy.4.670.83-1.671.83  
14MEANy..5.503.006.50  


The output data set has three kinds of observations, identified by values of _TYPE_ as follows:

  • When _TYPE_=’SCORE’, the observation contains the following information about the dependent and independent variables:

    • y is the original dependent variable.

    • x1 and x2 are the independent classification variables, and the Intercept through x2 a columns contain the main-effects design matrix that PROC TRANSREG creates. The variable names are Intercept, x1a, x1b, and x2a. Their labels are shown in the listing.

  • When _TYPE_=’M COEFFI’, the observation contains coefficients of the final linear model (parameter estimates).

  • When _TYPE_=’MEAN’, the observation contains the marginal means.

The observations with _TYPE_=’SCORE’ form the score or data partition of the output data set, and the observations with _TYPE_=’M COEFFI’ and _TYPE_=’MEAN’ form the output statistics partition of the output data set.