UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SAS Textbook Examples
Introduction to Multilevel Modeling by Kreft and de Leeuw
Chapter 3: Varying and Random Coefficient Models

Showing proc contents for the data file.
proc contents data="c:\imm\imm10" pos;
run;
And here are the results.
 # Variable Type Len Pos Label
-----------------------------------------------------------------------------------------------
15 cstr     Num    8 112
 5 homework Num    8  32 Time spent on math homework each week
11 math     Num    8  80 Math score
 4 meanses  Num    8  24 Mean SES for the school
 7 parented Num    8  48 Parents highest education level
10 percmin  Num    8  72 Percent minority in school
 8 public   Num    8  56 Public school: 1=public, 0=non-public
13 race     Num    8  96 race of student, 1=asian, 2=Hispanic, 3=Black, 4=White, 5=Native American
 9 ratio    Num    8  64 Student-Teacher ratio
18 region   Num    8 136
 1 schid    Num    8   0 School ID
19 schnum   Num    8 144 group(schid)
16 scsize   Num    8 120
14 sctype   Num    8 104 Type of school, 1=public, 2=catholic, 3=Private
                         other religious, 4=Private non-r
 3 ses      Num    8  16 Socioecnonomic Status
12 sex      Num    8  88 Sex: 1=male, 2=female
 2 stuid    Num    8   8 Student ID
17 urban    Num    8 128
 6 white    Num    8  40 Race: 1=white, 0=non-white
Page 48, Table 3.3
proc mixed data="c:\imm\imm10" covtest;
  class schid;
  model math = homework / solution ;
  random intercept homework / subject=schid type=un;
run;
Results for the model.
                  Covariance Parameter Estimates

                                    Standard         Z
Cov Parm     Subject    Estimate       Error     Value        Pr Z
UN(1,1)      schid       69.2445     34.9698      1.98      0.0238
UN(2,1)      schid      -31.7240     18.1410     -1.75      0.0803
UN(2,2)      schid       22.4289     11.4868      1.95      0.0254
Residual                 43.0726      3.9300     10.96      <.0001

           Fit Statistics
-2 Res Log Likelihood          1764.0
AIC (smaller is better)        1772.0
AICC (smaller is better)       1772.1
BIC (smaller is better)        1773.2

                   Solution for Fixed Effects

                         Standard
Effect       Estimate       Error      DF    t Value    Pr > |t|
Intercept     44.7706      2.7426       9      16.32      <.0001
homework       2.0405      1.5535       9       1.31      0.2215
Page 50, table 3.4 equations.
proc mixed data="c:\imm\imm10" covtest;
  class schid;
  model math = homework public / solution ;
  random intercept homework / subject=schid type=un;
run;
Results for the model
                  Covariance Parameter Estimates

                                    Standard         Z
Cov Parm     Subject    Estimate       Error     Value        Pr Z
UN(1,1)      schid       45.8197     24.1776      1.90      0.0290
UN(2,1)      schid      -32.2341     16.8097     -1.92      0.0552
UN(2,2)      schid       23.9519     12.1825      1.97      0.0246
Residual                 42.9617      3.9109     10.99      <.0001

           Fit Statistics
-2 Res Log Likelihood          1744.0
AIC (smaller is better)        1752.0
AICC (smaller is better)       1752.1
BIC (smaller is better)        1753.2

                   Solution for Fixed Effects

                         Standard
Effect       Estimate       Error      DF    t Value    Pr > |t|
Intercept     58.0407      2.9427       8      19.72      <.0001
homework       1.9524      1.5986       9       1.22      0.2530
public       -14.6608      2.1073     240      -6.96      <.0001
Page 51, table 3.5 equations.
proc mixed data="c:\imm\imm10" covtest;
  class schid;
  model math = homework public homework*public / solution ;
  random intercept homework / subject=schid type=un;
run;
Results shown below.  Note the interaction is positive but the bottom of page 50 shows the interaction is negative.  We think this may be a typographical error.
                  Covariance Parameter Estimates

                                    Standard         Z
Cov Parm     Subject    Estimate       Error     Value        Pr Z
UN(1,1)      schid       51.8115     28.6438      1.81      0.0352
UN(2,1)      schid      -36.7004     20.0693     -1.83      0.0674
UN(2,2)      schid       27.2633     14.5892      1.87      0.0308
Residual                 42.9600      3.9106     10.99      <.0001

           Fit Statistics
-2 Res Log Likelihood          1738.7
AIC (smaller is better)        1746.7
AICC (smaller is better)       1746.9
BIC (smaller is better)        1747.9

                      Solution for Fixed Effects

                               Standard
Effect             Estimate       Error      DF    t Value    Pr > |t|
Intercept           59.2102      7.4052       8       8.00      <.0001
homework             1.0946      5.2424       8       0.21      0.8398
public             -15.9656      7.8270     240      -2.04      0.0425
homework*public      0.9511      5.5415     240       0.17      0.8639

           Type 3 Tests of Fixed Effects

                    Num     Den
Effect               DF      DF    F Value    Pr > F
homework              1       8       0.04    0.8398
public                1     240       4.16    0.0425
homework*public       1     240       0.03    0.8639
Page 52, Table 3.6 .
proc mixed data="c:\imm\imm10" method=ml;
 class schid;
 model math = homework / solution;
 random intercept homework / subject=schid type=un g solution;
 ODS OUTPUT SOLUTIONR=randest;
run; 

( output omitted )

                  Solution for Fixed Effects

                        Standard
Effect       Estimate       Error      DF    t Value    Pr > |t|

Intercept     44.7726      2.6031       9      17.20      <.0001
homework       2.0487      1.4722       9       1.39      0.1975

( more output omitted )

DATA randest2;
 set randest;
 if effect="Intercept" then  eb = 44.772 + estimate;
 if effect="homework" then   eb = 2.048 + estimate;
run;

proc print data=randest2;
 var effect schid eb;
run;

Obs     Effect      schid       eb

 1    Intercept     7472     50.2702
 2    homework      7472     -3.1441
 3    Intercept     7829     48.8855
 4    homework      7829     -2.7547
 5    Intercept     7930     39.1947
 6    homework      7930      7.5656
 7    Intercept    24725     35.1560
 8    homework     24725      5.3934
 9    Intercept    25456     53.0804
10    homework     25456     -3.7389
11    Intercept    25642     48.5853
12    homework     25642     -1.7659
13    Intercept    62821     58.0548
14    homework     62821      1.3345
15    Intercept    68448     37.1518
16    homework     68448      6.0593
17    Intercept    68493     39.1691
18    homework     68493      5.4297
19    Intercept    72292     38.1722
20    homework     72292      6.1010

Page 53, Figure 3.8 (skipped).

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