### SAS Textbook Examples Applied Regression Analysis by John Fox Chapter 9: Statistical Theory for Linear Models

Linear contrasts on data file friendly on page 209. The option /E on the contrast statement gives the entire vector.
proc means data=friendly;
class cond;
var correct;
run;
proc glm data=friendly;
class cond;
model correct=cond;
contrast 'SRF vs. others' cond  -0.5 -0.5 1 /E;
contrast 'B vs. M'  cond  1 -1 0 /E;
run;
quit;

The MEANS Procedure

Analysis Variable : correct

N
cond        Obs     N            Mean         Std Dev         Minimum         Maximum
-------------------------------------------------------------------------------------
Before       10    10      36.6000000       5.3374984      24.0000000      40.0000000

Meshed       10    10      36.6000000       3.0258149      30.0000000      40.0000000

SFR          10    10      30.3000000       7.3340909      21.0000000      39.0000000
-------------------------------------------------------------------------------------

The GLM Procedure

Class Level Information

Class         Levels    Values

cond               3    Before Meshed SFR

Number of observations    30

The GLM Procedure

Coefficients for Contrast SRF vs. others

Row 1

Intercept                      0

cond      Before            -0.5
cond      Meshed            -0.5
cond      SFR                  1

The GLM Procedure

Coefficients for Contrast B vs. M

Row 1

Intercept                      0

cond      Before               1
cond      Meshed              -1
cond      SFR                  0

The GLM Procedure

Dependent Variable: correct

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

Model                        2      264.600000      132.300000       4.34    0.0232

Error                       27      822.900000       30.477778

Corrected Total             29     1087.500000

R-Square     Coeff Var      Root MSE    correct Mean

0.243310      16.00194      5.520668        34.50000

Source                      DF       Type I SS     Mean Square    F Value    Pr > F

cond                         2     264.6000000     132.3000000       4.34    0.0232

Source                      DF     Type III SS     Mean Square    F Value    Pr > F

cond                         2     264.6000000     132.3000000       4.34    0.0232

Contrast                    DF     Contrast SS     Mean Square    F Value    Pr > F

SRF vs. others               1     264.6000000     264.6000000       8.68    0.0065
B vs. M                      1       0.0000000       0.0000000       0.00    1.0000

Calculation on page 214 and calculation on page 222 using data file duncan.

data inpt;
set duncan;
incpt=1;
run;
proc iml;
use inpt;
x =  incpt || income || educ ;
b=INV(x*x)*x*prestige;
print b; /*regression coefficients*/

r=prestige-x*b;
v=(r*r)/42;
V2=v*INV(x*x);
d=diag(V2);
a=sqrt(d);
print a; /*estimated standard errors */
quit;

B

-6.064663
0.5987328
0.5458339

A

4.2719412         0         0
0 0.1196673         0
0         0 0.0982526

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.