UCLA Academic Technology Services HomeServicesClassesContactJobs
Help the Stat Consulting Group by giving a gift             
Loading

SAS Textbook Examples
Modeling Longitudinal Data by Robert Weiss
Chapter 9: Random Effects Models

The data files can be downloaded from http://rem.ph.ucla.edu/~rob/mld/data.html .

Table 9.1, page 314.

data bsi;
 set bsitotal;
 knot18 = (true_month - 18)*(true_month >= 18);
 knot36 = (true_month - 36)*(true_month >= 36);
 spring = (season = "spring (3-6)");
 summer = (season = "summer (7-10)");
 l2bsi_gsi = log(bsi_gsi + 1/53)/log(2);
run;

proc mixed data = bsi method = reml noitprint noclprint covtest;
 class pid rounded3_true_month gender drug_status;
 model l2bsi_gsi = true_month knot18 knot36 spring summer gender parent_alcohol parent_marijuana drug_status/
  notest;
 repeated rounded3_true_month / subject = pid type = arma(1,1);
run;

The Mixed Procedure

                  Model Information
Data Set                     WORK.BSI
Dependent Variable           l2bsi_gsi
Covariance Structure         Autoregressive
                             Moving Average
Subject Effect               pid
Estimation Method            REML
Residual Variance Method     Profile
Fixed Effects SE Method      Model-Based
Degrees of Freedom Method    Between-Within

            Dimensions
Covariance Parameters             3
Columns in X                     13
Columns in Z                      0
Subjects                        329
Max Obs Per Subject              13

          Number of Observations
Number of Observations Read            4857
Number of Observations Used            1907
Number of Observations Not Used        2950

                   Covariance Parameter Estimates
                                    Standard         Z
Cov Parm     Subject    Estimate       Error     Value        Pr Z
Rho          pid          0.9415     0.01068     88.19      <.0001
Gamma        pid          0.5855     0.02435     24.05      <.0001
Residual                  4.0431      0.1954     20.69      <.0001

           Fit Statistics
-2 Res Log Likelihood          7367.7
AIC (smaller is better)        7373.7
AICC (smaller is better)       7373.7
BIC (smaller is better)        7385.1

  Null Model Likelihood Ratio Test
    DF    Chi-Square      Pr > ChiSq
     2        761.23          <.0001
     
proc mixed data = bsi method = reml noitprint noclprint covtest;
 class pid rounded3_true_month gender drug_status parent;
 model l2bsi_gsi = true_month knot18 knot36 spring summer gender parent_alcohol parent_marijuana drug_status/
  notest;
 repeated rounded3_true_month / subject = pid(parent) type = arma(1,1);
 random intercept / subject = parent type = un;
run;     

The Mixed Procedure

                  Model Information

Data Set                     WORK.BSI
Dependent Variable           l2bsi_gsi
Covariance Structures        Unstructured,
                             Autoregressive
                             Moving Average
Subject Effects              parent, pid(parent)
Estimation Method            REML
Residual Variance Method     Profile
Fixed Effects SE Method      Model-Based
Degrees of Freedom Method    Containment

            Dimensions
Covariance Parameters             4
Columns in X                     13
Columns in Z Per Subject          1
Subjects                        220
Max Obs Per Subject              44

          Number of Observations
Number of Observations Read            4857
Number of Observations Used            1907
Number of Observations Not Used        2950

                    Covariance Parameter Estimates
                                        Standard         Z
Cov Parm     Subject        Estimate       Error     Value        Pr Z

UN(1,1)      parent           0.7199      0.2348      3.07      0.0011
Rho          pid(parent)      0.9047     0.02247     40.25      <.0001
Gamma        pid(parent)      0.5036     0.03542     14.22      <.0001
Residual                      3.3345      0.2248     14.83      <.0001

           Fit Statistics
-2 Res Log Likelihood          7357.2
AIC (smaller is better)        7365.2
AICC (smaller is better)       7365.2
BIC (smaller is better)        7378.8

  Null Model Likelihood Ratio Test
    DF    Chi-Square      Pr > ChiSq
     3        771.70          <.0001
Table 9.2, page 315.
data weight2_1;
 set weight2;
 d1 = day;
 d2 = day*day/100;
run;

*Model 1;
proc mixed data = weight2_1 method = reml noitprint noclprint;
 class id ;
 model weight = d1 d2 / solution notest;
 random intercept d1 / subject = id type = un;
run;

The Mixed Procedure

                  Model Information
Data Set                     WORK.WEIGHT2
Dependent Variable           weight
Covariance Structure         Unstructured
Subject Effect               id
Estimation Method            REML
Residual Variance Method     Profile
Fixed Effects SE Method      Model-Based
Degrees of Freedom Method    Containment

            Dimensions
Covariance Parameters             4
Columns in X                      3
Columns in Z Per Subject          2
Subjects                         38
Max Obs Per Subject               8

          Number of Observations
Number of Observations Read             304
Number of Observations Used             265
Number of Observations Not Used          39

 Covariance Parameter Estimates
Cov Parm     Subject    Estimate
UN(1,1)      id           666.30
UN(2,1)      id          -0.6606
UN(2,2)      id          0.01148
Residual                  4.5231

           Fit Statistics
-2 Res Log Likelihood          1474.1
AIC (smaller is better)        1482.1
AICC (smaller is better)       1482.3
BIC (smaller is better)        1488.7

  Null Model Likelihood Ratio Test
    DF    Chi-Square      Pr > ChiSq
     3        986.16          <.0001

                   Solution for Fixed Effects
                         Standard
Effect       Estimate       Error      DF    t Value    Pr > |t|
Intercept      193.72      4.1976      37      46.15      <.0001
d1            -0.2653     0.03428      37      -7.74      <.0001
d2             0.2079     0.06208     188       3.35      0.0010

*Model 2;
proc mixed data = weight2_1 method = reml noitprint noclprint;
 class id;
 model weight = d1 d2 visit/ solution notest;
 random intercept d1 / subject = id type = un;
run;

The Mixed Procedure

                  Model Information
Data Set                     WORK.WEIGHT2
Dependent Variable           weight
Covariance Structure         Unstructured
Subject Effect               id
Estimation Method            REML
Residual Variance Method     Profile
Fixed Effects SE Method      Model-Based
Degrees of Freedom Method    Containment

            Dimensions
Covariance Parameters             4
Columns in X                      4
Columns in Z Per Subject          2
Subjects                         38
Max Obs Per Subject               8

          Number of Observations
Number of Observations Read             304
Number of Observations Used             265
Number of Observations Not Used          39

 Covariance Parameter Estimates
Cov Parm     Subject    Estimate
UN(1,1)      id           666.06
UN(2,1)      id          -0.6833
UN(2,2)      id          0.01179
Residual                  3.4397

           Fit Statistics
-2 Res Log Likelihood          1420.7
AIC (smaller is better)        1428.7
AICC (smaller is better)       1428.9
BIC (smaller is better)        1435.3

  Null Model Likelihood Ratio Test
    DF    Chi-Square      Pr > ChiSq
     3       1034.39          <.0001

                   Solution for Fixed Effects
                         Standard
Effect       Estimate       Error      DF    t Value    Pr > |t|
Intercept      193.46      4.1945      37      46.12      <.0001
d1            -0.1732     0.03337      37      -5.19      <.0001
d2             0.1104     0.05577     187       1.98      0.0492
visit         -2.3782      0.3025     187      -7.86      <.0001

*Model 3;
proc mixed data = weight2_1 method = reml noitprint noclprint;
 class id;
 model weight = d1 d2 visit/ solution notest;
 random intercept d1 / subject = id type = un;
 random visit /subject = id type = un;
run;

The Mixed Procedure

                  Model Information
Data Set                     WORK.WEIGHT2
Dependent Variable           weight
Covariance Structure         Unstructured
Subject Effects              id, id
Estimation Method            REML
Residual Variance Method     Profile
Fixed Effects SE Method      Model-Based
Degrees of Freedom Method    Containment

            Dimensions
Covariance Parameters             5
Columns in X                      4
Columns in Z Per Subject          3
Subjects                         38
Max Obs Per Subject               8

          Number of Observations
Number of Observations Read             304
Number of Observations Used             265
Number of Observations Not Used          39

 Covariance Parameter Estimates
Cov Parm     Subject    Estimate
UN(1,1)      id           667.10
UN(2,1)      id          -0.5547
UN(2,2)      id          0.01195
UN(1,1)      id           4.0915
Residual                  2.5165

           Fit Statistics
-2 Res Log Likelihood          1399.4
AIC (smaller is better)        1409.4
AICC (smaller is better)       1409.6
BIC (smaller is better)        1417.6

  Null Model Likelihood Ratio Test
    DF    Chi-Square      Pr > ChiSq
     4       1055.75          <.0001

                   Solution for Fixed Effects
                         Standard
Effect       Estimate       Error      DF    t Value    Pr > |t|
Intercept      193.45      4.1957      37      46.11      <.0001
d1            -0.1715     0.03021      37      -5.68      <.0001
d2             0.1081     0.04824     150       2.24      0.0266
visit         -2.3786      0.4219      37      -5.64      <.0001

*Model 4;
proc mixed data = weight2_1 method = reml noitprint noclprint;
 class id ;
 model weight = d1 d2 visit/ solution notest;
 random intercept d1 visit / subject = id type = un;
run;

The Mixed Procedure

                  Model Information
Data Set                     WORK.WEIGHT2
Dependent Variable           weight
Covariance Structure         Unstructured
Subject Effect               id
Estimation Method            REML
Residual Variance Method     Profile
Fixed Effects SE Method      Model-Based
Degrees of Freedom Method    Containment

            Dimensions
Covariance Parameters             7
Columns in X                      4
Columns in Z Per Subject          3
Subjects                         38
Max Obs Per Subject               8

          Number of Observations
Number of Observations Read             304
Number of Observations Used             265
Number of Observations Not Used          39

 Covariance Parameter Estimates
Cov Parm     Subject    Estimate
UN(1,1)      id           667.00
UN(2,1)      id          -0.4385
UN(2,2)      id          0.01223
UN(3,1)      id         -13.5255
UN(3,2)      id         -0.02733
UN(3,3)      id           4.3062
Residual                  2.5039

           Fit Statistics
-2 Res Log Likelihood          1397.3
AIC (smaller is better)        1411.3
AICC (smaller is better)       1411.7
BIC (smaller is better)        1422.7

  Null Model Likelihood Ratio Test
    DF    Chi-Square      Pr > ChiSq
     6       1057.86          <.0001

                   Solution for Fixed Effects
                         Standard
Effect       Estimate       Error      DF    t Value    Pr > |t|
Intercept      193.45      4.1954      37      46.11      <.0001
d1            -0.1721     0.03028      37      -5.69      <.0001
d2             0.1091     0.04810     150       2.27      0.0248
visit         -2.3724      0.4285      37      -5.54      <.0001

How to cite this page

Report an error on this page or leave a comment

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.