UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SAS Textbook Examples
Applied Regression Analysis by John Fox
Chapter 7: Dummy-Variable Regression

Calculation from page 142 to page 143 based on data file duncan.
proc reg data=duncan;
  model prestige=income educ;
run;
quit;
proc means data=duncan;
  class occtype;
  var prestige;
  output out=totals mean(prestige)=mean ;
  /*dummy code the categorical variable occtype*/
data duncanDummy;
  set duncan;
  if occtype='bc' then do d1=0; d2=0; end;
  if occtype='prof' then do d1=1; d2=0; end;
  if occtype='wc' then do d1=0; d2=1; end;
run;
proc reg data=duncanDummy;
  model prestige=income educ d1 d2;
run;
  occupationeffect: test d1 , d2 ;
quit;

The REG Procedure
Model: MODEL1
Dependent Variable: prestige

                             Analysis of Variance

                                    Sum of           Mean
Source                   DF        Squares         Square    F Value    Pr > F

Model                     2          36181          18090     101.22    <.0001
Error                    42     7506.69865      178.73092
Corrected Total          44          43688


Root MSE             13.36903    R-Square     0.8282
Dependent Mean       47.68889    Adj R-Sq     0.8200
Coeff Var            28.03384

                        Parameter Estimates

                     Parameter       Standard
Variable     DF       Estimate          Error    t Value    Pr > |t|

Intercept     1       -6.06466        4.27194      -1.42      0.1631
income        1        0.59873        0.11967       5.00      <.0001
educ          1        0.54583        0.09825       5.56      <.0001

The MEANS Procedure

                           Analysis Variable : prestige

             N
occtype    Obs     N            Mean         Std Dev         Minimum         Maximum
------------------------------------------------------------------------------------
bc          21    21      22.7619048      18.0552063       3.0000000      67.0000000

prof        18    18      80.4444444      14.1055776      45.0000000      97.0000000

wc           6     6      36.6666667      11.7926531      16.0000000      52.0000000
------------------------------------------------------------------------------------

The REG Procedure
Model: MODEL1
Dependent Variable: prestige

                             Analysis of Variance

                                    Sum of           Mean
Source                   DF        Squares         Square    F Value    Pr > F

Model                     4          39890     9972.42242     105.03    <.0001
Error                    40     3797.95474       94.94887
Corrected Total          44          43688


Root MSE              9.74417    R-Square     0.9131
Dependent Mean       47.68889    Adj R-Sq     0.9044
Coeff Var            20.43279

                        Parameter Estimates

                     Parameter       Standard
Variable     DF       Estimate          Error    t Value    Pr > |t|

Intercept     1       -0.18503        3.71377      -0.05      0.9605
income        1        0.59755        0.08936       6.69      <.0001
educ          1        0.34532        0.11361       3.04      0.0042
d1            1       16.65751        6.99301       2.38      0.0221
d2            1      -14.66113        6.10877      -2.40      0.0211

The REG Procedure
Model: MODEL1

            Test OCCUPATIONEFFECT Results for
               Dependent Variable prestige

                                Mean
Source             DF         Square    F Value    Pr > F

Numerator           2     1854.37195      19.53    <.0001
Denominator        40       94.94887

Calculation on page 150, Table 7.1 and Table 7.2 on page 151  based on data file duncan. In Table 7.2, the column of Sum of Squares come from the difference between the sum of squares of the models contrasted. The results from SAS  for F-values in Table 7.2 is different from the book since the degree of freedom for residuals used in calculating the F-values is always 36 in the book whereas in SAS it depends on different models.   

data duncanDummy;
  set duncan;
  if occtype='bc' then do d1=0; d2=0; end;
  if occtype='prof' then do d1=1; d2=0; end;
  if occtype='wc' then do d1=0; d2=1; end;
  incd1=income*d1;
  incd2=income*d2;
  educd1=educ*d1;
  educd2=educ*d2;
run;
proc reg data=duncanDummy;/*model 1*/
  model prestige=income educ d1 d2 incd1 incd2 educd1 educd2;
run;
  incTypeEffect: test incd1, incd2 ; /*compared with model 2 */
  eduTypeEffect: test educd1, educd2;
quit;
proc reg; /*model 2*/
 model prestige=income educ d1 d2 educd1 educd2;
run;
  incomeEffect: test income; /*compared with model 6 */
quit;
proc reg ; /*model 3 */
  model prestige=income educ d1 d2 incd1 incd2;
run;
  educEffect: test educ; /*compared with model 7 */
quit;
proc reg; /*model 4*/
  model prestige=income educ d1 d2;
run;
  typeEffect: test d1, d2; /*compared with model 5*/
quit;
proc reg; /*model 5 */
  model prestige=income educ;
run;
proc reg; /*model 6 */
  model prestige=educ d1 d2 educd1 educd2;
run;
proc reg; /*model 7 */
  model prestige=income d1 d2 incd1 incd2;
run;
quit;

The REG Procedure
Model: MODEL1
Dependent Variable: prestige

                             Analysis of Variance

                                    Sum of           Mean
Source                   DF        Squares         Square    F Value    Pr > F
Model                     8          40337     5042.12491      54.17    <.0001
Error                    36     3350.64519       93.07348
Corrected Total          44          43688

Root MSE              9.64746    R-Square     0.9233
Dependent Mean       47.68889    Adj R-Sq     0.9063
Coeff Var            20.22999

                        Parameter Estimates: Omitted.

The REG Procedure
Model: MODEL1

             Test INCTYPEEFFECT Results for
               Dependent Variable prestige

                                Mean
Source             DF         Square    F Value    Pr > F
Numerator           2      186.08646       2.00    0.1502
Denominator        36       93.07348

The REG Procedure
Model: MODEL1

             Test EDUTYPEEFFECT Results for
               Dependent Variable prestige

                                Mean
Source             DF         Square    F Value    Pr > F
Numerator           2        5.77997       0.06    0.9399
Denominator        36       93.07348

The REG Procedure
Model: MODEL1
Dependent Variable: prestige

                             Analysis of Variance

                                    Sum of           Mean
Source                   DF        Squares         Square    F Value    Pr > F
Model                     6          39965     6660.80439      67.99    <.0001
Error                    38     3722.81811       97.96890
Corrected Total          44          43688

Root MSE              9.89792    R-Square     0.9148
Dependent Mean       47.68889    Adj R-Sq     0.9013
Coeff Var            20.75520

                        Parameter Estimates: Omitted.

The REG Procedure
Model: MODEL1

Test INCOMEEFFECT Results for Dependent Variable prestige

                                Mean
Source             DF         Square    F Value    Pr > F
Numerator           1     3953.83635      40.36    <.0001
Denominator        38       97.96890
The REG Procedure
Model: MODEL1
Dependent Variable: prestige

                             Analysis of Variance

                                    Sum of           Mean
Source                   DF        Squares         Square    F Value    Pr > F
Model                     6          40325     6720.90655      75.96    <.0001
Error                    38     3362.20513       88.47908
Corrected Total          44          43688

Root MSE              9.40633    R-Square     0.9230
Dependent Mean       47.68889    Adj R-Sq     0.9109
Coeff Var            19.72437

                        Parameter Estimates: Omitted.

The REG Procedure
Model: MODEL1

 Test EDUCEFFECT Results for Dependent Variable prestige

                                Mean
Source             DF         Square    F Value    Pr > F
Numerator           1      891.30475      10.07    0.0030
Denominator        38       88.47908

The REG Procedure
Model: MODEL1
Dependent Variable: prestige

                             Analysis of Variance

                                    Sum of           Mean
Source                   DF        Squares         Square    F Value    Pr > F
Model                     4          39890     9972.42242     105.03    <.0001
Error                    40     3797.95474       94.94887
Corrected Total          44          43688

Root MSE              9.74417    R-Square     0.9131
Dependent Mean       47.68889    Adj R-Sq     0.9044
Coeff Var            20.43279

                        Parameter Estimates: Omitted.
                        
The REG Procedure
Model: MODEL1

 Test TYPEEFFECT Results for Dependent Variable prestige

                                Mean
Source             DF         Square    F Value    Pr > F
Numerator           2     1854.37195      19.53    <.0001
Denominator        40       94.94887

The REG Procedure
Model: MODEL1
Dependent Variable: prestige

                             Analysis of Variance

                                    Sum of           Mean
Source                   DF        Squares         Square    F Value    Pr > F
Model                     2          36181          18090     101.22    <.0001
Error                    42     7506.69865      178.73092
Corrected Total          44          43688

Root MSE             13.36903    R-Square     0.8282
Dependent Mean       47.68889    Adj R-Sq     0.8200
Coeff Var            28.03384

                        Parameter Estimates: Omitted.

The REG Procedure
Model: MODEL1
Dependent Variable: prestige

                             Analysis of Variance

                                    Sum of           Mean
Source                   DF        Squares         Square    F Value    Pr > F
Model                     5          36011     7202.19800      36.59    <.0001
Error                    39     7676.65446      196.83729
Corrected Total          44          43688

Root MSE             14.02987    R-Square     0.8243
Dependent Mean       47.68889    Adj R-Sq     0.8018
Coeff Var            29.41958

                       Parameter Estimates: Omitted.
                       
The REG Procedure
Model: MODEL1
Dependent Variable: prestige

                             Analysis of Variance

                                    Sum of           Mean
Source                   DF        Squares         Square    F Value    Pr > F
Model                     5          39434     7886.82691      72.31    <.0001
Error                    39     4253.50988      109.06436
Corrected Total          44          43688

Root MSE             10.44339    R-Square     0.9026
Dependent Mean       47.68889    Adj R-Sq     0.8902
Coeff Var            21.89900

                        Parameter Estimates: Omitted.

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


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.