Chapter Contents 
Previous 
Next 
The REG Procedure 
At times it is desirable to have independent variables in the model that are qualitative rather than quantitative. This is easily handled in a regression framework. Regression uses qualitative variables to distinguish between populations. There are two main advantages of fitting both populations in one model. You gain the ability to test for different slopes or intercepts in the populations, and more degrees of freedom are available for the analysis.
Regression with qualitative variables is different from analysis of variance and analysis of covariance. Analysis of variance uses qualitative independent variables only. Analysis of covariance uses quantitative variables in addition to the qualitative variables in order to account for correlation in the data and reduce MSE; however, the quantitative variables are not of primary interest and merely improve the precision of the analysis.
Consider the case where Y_{i} is the dependent variable, X1_{i} is a quantitative variable, X2_{i} is a qualitative variable taking on values 0 or 1, and X1_{i}X2_{i} is the interaction. The variable X2_{i} is called a dummy, binary, or indicator variable. With values 0 or 1, it distinguishes between two populations. The model is of the form
for the observations i = 1,2, ... ,n. The parameters to be estimated are , , , and .The number of dummy variables used is one less than the number of qualitative levels. This yields a nonsingular X'X matrix. See Chapter 10 of Neter, Wasserman, and Kutner (1990) for more details.
An example from Neter, Wasserman, and Kutner (1990) follows. An economist is investigating the relationship between the size of an insurance firm and the speed at which they implement new insurance innovations. He believes that the type of firm may affect this relationship and suspects that there may be some interaction between the size and type of firm. The dummy variable in the model allows the two firms to have different intercepts. The interaction term allows the firms to have different slopes as well.
In this study, Y_{i} is the number of months from the time the first firm implemented the innovation to the time it was implemented by the ith firm. The variable X1_{i} is the size of the firm, measured in total assets of the firm. The variable X2_{i} denotes the firm type and is 0 if the firm is a mutual fund company and 1 if the firm is a stock company. The dummy variable allows each firm type to have a different intercept and slope.
The previous model can be broken down into a model for each firm type by plugging in the values for X2_{i}. If X2_{i}=0, the model is
This is the model for a mutual company. If X2_{i}=1, the model for a stock firm is
This model has intercept and slope .
The data^{*} follow. Note that the interaction term is created in the DATA step since polynomial effects such as size*type are not allowed in the MODEL statement in the REG procedure.
title 'Regression With Quantitative and Qualitative Variables'; data insurance; input time size type @@; sizetype=size*type; datalines; 17 151 0 26 92 0 21 175 0 30 31 0 22 104 0 0 277 0 12 210 0 19 120 0 4 290 0 16 238 0 28 164 1 15 272 1 11 295 1 38 68 1 31 85 1 21 224 1 20 166 1 13 305 1 30 124 1 14 246 1 ; run;The following statements begin the analysis:
proc reg data=insurance; model time = size type sizetype; run;The ANOVA table is displayed in Output 55.3.1. Output 55.3.1: ANOVA Table and Parameter Estimates
delete sizetype; print; run;The DELETE statement removes the interaction term (sizetype) from the model. The new ANOVA table is shown in Output 55.3.2. Output 55.3.2: ANOVA Table and Parameter Estimates

The fitted model is
The fitted model for a mutual fund company (X2_{i}=0) is
and the fitted model for a stock company (X2_{i}=1) is
So the two models have different intercepts but the same slope.
Now plot the residual versus predicted values using the firm type as the plot symbol (PLOT=TYPE); this can be useful in determining if the firm types have different residual patterns. PROC REG does not support the plot y*x=type syntax for highresolution graphics, so use PROC GPLOT to create Output 55.3.3. First, the OUTPUT statement saves the residuals and predicted values from the new model in the OUT= data set.
output out=out r=r p=p; run; symbol1 v='0' c=blue f=swissb; symbol2 v='1' c=yellow f=swissb; axis1 label=(angle=90); proc gplot data=out; plot r*p=type / nolegend vaxis=axis1 cframe=ligr; plot p*size=type / nolegend vaxis=axis1 cframe=ligr; run;Output 55.3.3: Plot of Residual vs. Predicted Values
A plot of the predicted values versus size appears in Output 55.3.4, where the firm type is again used as the plotting symbol.
Output 55.3.4: Plot of Predicted vs. Size
Chapter Contents 
Previous 
Next 
Top 
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.