UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SAS Textbook Examples
Modeling Longitudinal Data by Robert Weiss
Chapter 6: Tools and Concepts

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

Table 6.1, page 149.

data small;
 set smallmice;
 cont_day = day;
 cont_day2 = day**2;
run;

*Unstructured Covariance Matrix;
proc mixed data = small method = reml noitprint noclprint;
 class id day;
 model weight = cont_day cont_day2/ notest;
 repeated day/ subject=id type = unstructured;
run;

The Mixed Procedure

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

            Dimensions
Covariance Parameters            28
Columns in X                      3
Columns in Z                      0
Subjects                         14
Max Obs Per Subject               7

          Number of Observations
Number of Observations Read              98
Number of Observations Used              98
Number of Observations Not Used           0

Covariance Parameter Estimates
Cov Parm    Subject    Estimate
UN(1,1)     id           909.07
UN(2,1)     id          1313.72
UN(2,2)     id          2248.87
UN(3,1)     id           889.13
UN(3,2)     id          2062.34
UN(3,3)     id          3532.66
UN(4,1)     id           941.45
UN(4,2)     id          2470.39
UN(4,3)     id          5346.10
UN(4,4)     id            10600
UN(5,1)     id           721.71
UN(5,2)     id          2674.65
UN(5,3)     id          6486.86
UN(5,4)     id            12884
UN(5,5)     id            17993
UN(6,1)     id           943.31
UN(6,2)     id          2662.18
UN(6,3)     id          5989.36
UN(6,4)     id            12463
UN(6,5)     id            16892
UN(6,6)     id            18053
UN(7,1)     id          1266.36
UN(7,2)     id          3030.37
UN(7,3)     id          5799.41
UN(7,4)     id            10739
UN(7,5)     id            14324
UN(7,6)     id            14866
UN(7,7)     id            14492

           Fit Statistics
-2 Res Log Likelihood           964.7
AIC (smaller is better)        1020.7
AICC (smaller is better)       1045.3
BIC (smaller is better)        1038.6

  Null Model Likelihood Ratio Test
    DF    Chi-Square      Pr > ChiSq
    27        198.41          <.0001

*AR(1) Covariance Matrix;
proc mixed data = small method = reml noitprint noclprint;
 class id day;
 model weight = cont_day cont_day2/ notest;
 repeated day/ subject=id type = ar(1);
run;

The Mixed Procedure

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

            Dimensions
Covariance Parameters             2
Columns in X                      3
Columns in Z                      0
Subjects                         14
Max Obs Per Subject               7

          Number of Observations
Number of Observations Read              98
Number of Observations Used              98
Number of Observations Not Used           0

 Covariance Parameter Estimates
Cov Parm     Subject    Estimate
AR(1)        id           0.8737
Residual                 8796.77

           Fit Statistics
-2 Res Log Likelihood          1035.3
AIC (smaller is better)        1039.3
AICC (smaller is better)       1039.4
BIC (smaller is better)        1040.5

  Null Model Likelihood Ratio Test
    DF    Chi-Square      Pr > ChiSq
     1        127.83          <.0001

*RIAS Covariance Matrix;
proc mixed data = small method = reml noitprint noclprint;
 class id day;
 model weight = cont_day cont_day2/ notest;
 random intercept cont_day/ subject=id type = un;
run;

The Mixed Procedure

                  Model Information
Data Set                     WORK.SMALL
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                         14
Max Obs Per Subject               7

          Number of Observations
Number of Observations Read              98
Number of Observations Used              98
Number of Observations Not Used           0

 Covariance Parameter Estimates
Cov Parm     Subject    Estimate
UN(1,1)      id           744.35
UN(2,1)      id         -49.8237
UN(2,2)      id          55.5479
Residual                 1399.56

           Fit Statistics
-2 Res Log Likelihood          1038.6
AIC (smaller is better)        1046.6
AICC (smaller is better)       1047.0
BIC (smaller is better)        1049.2

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

*CS Covariance Matrix;
proc mixed data = small method = reml noitprint noclprint;
 class id day;
 model weight = cont_day cont_day2/ notest;
 random intercept/ subject=id;
run;

The Mixed Procedure

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

            Dimensions
Covariance Parameters             2
Columns in X                      3
Columns in Z Per Subject          1
Subjects                         14
Max Obs Per Subject               7

          Number of Observations
Number of Observations Read              98
Number of Observations Used              98
Number of Observations Not Used           0

 Covariance Parameter Estimates
Cov Parm      Subject    Estimate
Intercept     id          6052.49
Residual                  3618.76

           Fit Statistics
-2 Res Log Likelihood          1105.3
AIC (smaller is better)        1109.3
AICC (smaller is better)       1109.4
BIC (smaller is better)        1110.6

proc mixed data = small method = reml noitprint noclprint;
 class id day;
 model weight = cont_day cont_day2/ notest;
 repeated day / subject=id type = vc;
run;

The Mixed Procedure

                  Model Information
Data Set                     WORK.SMALL
Dependent Variable           weight
Covariance Structure         Variance Components
Subject Effect               id
Estimation Method            REML
Residual Variance Method     Parameter
Fixed Effects SE Method      Model-Based
Degrees of Freedom Method    Between-Within

            Dimensions
Covariance Parameters             1
Columns in X                      3
Columns in Z                      0
Subjects                         14
Max Obs Per Subject               7

          Number of Observations
Number of Observations Read              98
Number of Observations Used              98
Number of Observations Not Used           0

   Covariance Parameter
         Estimates
Cov
Parm    Subject    Estimate
day     id          9416.41

           Fit Statistics
-2 Res Log Likelihood          1163.1
AIC (smaller is better)        1165.1
AICC (smaller is better)       1165.1
BIC (smaller is better)        1165.7

  Null Model Likelihood Ratio Test
    DF    Chi-Square      Pr > ChiSq
     0          0.00          1.0000
Table 6.2, page 168.

Transformed estimates only.
data trans_pain;
 set pain;
 invsqrt = -paintol**(-.5);
run;

*Log2;
proc mixed data = trans_pain method= reml  noitprint noclprint noinfo;
 class id cs trial;
 model l2paintol = cs / solution notest;
 repeated trial/ subject = id type = unstructured;
run;

The Mixed Procedure

Covariance Parameter Estimates
Cov Parm    Subject    Estimate
UN(1,1)     id           1.0065
UN(2,1)     id           0.7482
UN(2,2)     id           1.1281
UN(3,1)     id           0.9522
UN(3,2)     id           0.8736
UN(3,3)     id           1.3423
UN(4,1)     id           0.6725
UN(4,2)     id           0.7908
UN(4,3)     id           1.0022
UN(4,4)     id           1.3071

           Fit Statistics
-2 Res Log Likelihood           568.4
AIC (smaller is better)         588.4
AICC (smaller is better)        589.4
BIC (smaller is better)         610.0

  Null Model Likelihood Ratio Test
    DF    Chi-Square      Pr > ChiSq
     9        170.12          <.0001

                          Solution for Fixed Effects
             coping                    Standard
Effect       style         Estimate       Error      DF    t Value    Pr > |t|
Intercept                    5.0770      0.1620      62      31.35      <.0001
cs           attender       -0.5054      0.2291      62      -2.21      0.0311
cs           distracter           0           .       .        .         .

*Negative inverse square root;
proc mixed data = trans_pain method= reml noitprint noclprint noinfo;
 class id cs trial;
 model invsqrt = cs / solution notest;
 repeated trial/ subject = id type = unstructured;
run;

The Mixed Procedure

Covariance Parameter Estimates
Cov Parm    Subject    Estimate
UN(1,1)     id         0.003276
UN(2,1)     id         0.002723
UN(2,2)     id         0.004548
UN(3,1)     id         0.003166
UN(3,2)     id         0.003089
UN(3,3)     id         0.004971
UN(4,1)     id         0.002611
UN(4,2)     id         0.003206
UN(4,3)     id         0.004182
UN(4,4)     id         0.005695

           Fit Statistics
-2 Res Log Likelihood          -778.7
AIC (smaller is better)        -758.7
AICC (smaller is better)       -757.8
BIC (smaller is better)        -737.1

  Null Model Likelihood Ratio Test
    DF    Chi-Square      Pr > ChiSq
     9        164.19          <.0001

                          Solution for Fixed Effects
             coping                    Standard
Effect       style         Estimate       Error      DF    t Value    Pr > |t|
Intercept                   -0.1831    0.009837      62     -18.62      <.0001
cs           attender      -0.02888     0.01389      62      -2.08      0.0418
cs           distracter           0           .       .        .         .

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