/******************************************************************* CHAPTER 10, EXAMPLE 2 Illustration of fitting a linear mixed effects model derived from a random coefficient model, where the mean slope in each group depends on a continuous covariate. The model for each man is assumed to be a straight line. The intercepts are taken to depend on baseline covariates. The slopes are taken to depend on baseline covariates, differentially by group (diet or not). We take D to be common for both groups and take Ri to be common to both groups of the form Ri = sigma^2 I. *******************************************************************/ options ls=80 ps=59 nodate; run; /****************************************************************** Read in the data set *******************************************************************/ data pdat; infile "press.dat.txt"; input id time press weight age prev diet; run; /******************************************************************* Use PROC MIXED to fit linear mixed effects model (i); we use normal ML rather than REML to get likelihood ratio tests *******************************************************************/ title 'MODEL (i)'; proc mixed method=ml data=pdat; class id; model press = time time*diet / solution; random intercept time / type=un subject=id; estimate "slp w/diet" time 1 time*diet 1; run; /******************************************************************* ******************************************************************** MODEL (i) 1 The Mixed Procedure Model Information Data Set WORK.PDAT Dependent Variable press Covariance Structure Unstructured Subject Effect id Estimation Method ML Residual Variance Method Profile Fixed Effects SE Method Model-Based Degrees of Freedom Method Containment Class Level Information Class Levels Values id 100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 Dimensions Covariance Parameters 4 Columns in X 3 Columns in Z Per Subject 2 Subjects 100 Max Obs Per Subject 12 Number of Observations Number of Observations Read 839 Number of Observations Used 839 Number of Observations Not Used 0 Iteration History Iteration Evaluations -2 Log Like Criterion 0 1 7787.64461022 1 2 5564.11759892 0.03057689 2 1 5483.82830125 0.01602275 3 1 5443.30531416 0.00679897 4 1 5426.68613900 0.00212555 5 1 5421.70939610 0.00036790 Covariance Parameter Estimates Cov Parm Subject Estimate UN(1,1) id 164.79 UN(2,1) id 0.6063 UN(2,2) id 0.01228 Residual 13.7306 Fit Statistics -2 Log Likelihood 5420.9 AIC (smaller is better) 5434.9 AICC (smaller is better) 5435.0 BIC (smaller is better) 5453.1 Null Model Likelihood Ratio Test DF Chi-Square Pr > ChiSq 3 2366.77 <.0001 Solution for Fixed Effects Standard Effect Estimate Error DF t Value Pr > |t| Intercept 163.89 1.3056 99 125.53 <.0001 time 0.2020 0.01523 98 13.27 <.0001 time*diet 0.1665 0.02060 639 8.08 <.0001 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F time 1 98 175.97 <.0001 time*diet 1 639 65.35 <.0001 ******************************************************************* ********************************************************************/ /******************************************************************* Model (ii) that includes "adjustments" for normal ML rather than REML to get likelihood ratio tests *******************************************************************/ title 'MODEL (ii)'; proc mixed method=ml data=pdat; class id; model press = weight prev age time time*diet / solution; random intercept time / type=un subject=id; estimate "slp w/diet" time 1 time*diet 1; run; /******************************************************************* ******************************************************************** Covariance Parameters 4 Columns in X 6 Columns in Z Per Subject 2 Subjects 100 Max Obs Per Subject 12 Covariance Parameter Estimates Cov Parm Subject Estimate UN(1,1) id 104.54 UN(2,1) id 0.1806 UN(2,2) id 0.01227 Residual 13.7285 Fit Statistics -2 Log Likelihood 5392.2 AIC (smaller is better) 5412.2 AICC (smaller is better) 5412.5 BIC (smaller is better) 5438.3 Null Model Likelihood Ratio Test DF Chi-Square Pr > ChiSq 3 1985.69 <.0001 Solution for Fixed Effects Standard Effect Estimate Error DF t Value Pr > |t| Intercept 130.86 12.3075 96 10.63 <.0001 weight 0.06093 0.04260 639 1.43 0.1531 prev 15.0642 2.3490 639 6.41 <.0001 age 0.8181 0.3876 639 2.11 0.0352 time 0.2014 0.01578 98 12.76 <.0001 time*diet 0.1674 0.02221 639 7.54 <.0001 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F weight 1 639 2.05 0.1531 prev 1 639 41.13 <.0001 ******************************************************************* ********************************************************************/ /******************************************************************* Model (iii) includes this adjustment plus the possibility that rate of change depends on both diet and previous experience. We include estimate statements to estimate each slope and contrast statements to make some comparisons. *******************************************************************/ title 'MODEL (iii)'; proc mixed method=ml data=pdat; class id; model press = weight prev age time time*diet time*prev time*diet*prev / solution; random intercept time / type=un subject=id; estimate "slp, diet, no prev" time 1 time*diet 1; estimate "slp, no diet, prev" time 1 time*prev 1; estimate "slp, diet, prev" time 1 time*prev 1 time*diet 1 time*diet*prev 1; contrast "overall slp diff" time*prev 1, time*diet 1, time*diet*prev 1 / chisq; contrast "prev effect" time*prev 1, time*diet*prev 1 / chisq; contrast "diet effect" time*diet 1, time*diet*prev 1 /chisq; run; /******************************************************************* ******************************************************************** Dimensions Covariance Parameters 4 Columns in X 8 Columns in Z Per Subject 2 Subjects 100 Max Obs Per Subject 12 Covariance Parameter Estimates Cov Parm Subject Estimate UN(1,1) id 103.90 UN(2,1) id 0.1075 UN(2,2) id 0.007303 Residual 13.7266 Fit Statistics -2 Log Likelihood 5342.0 AIC (smaller is better) 5366.0 AICC (smaller is better) 5366.4 BIC (smaller is better) 5397.3 Null Model Likelihood Ratio Test DF Chi-Square Pr > ChiSq 3 1928.02 <.0001 Solution for Fixed Effects Standard Effect Estimate Error DF t Value Pr > |t| Intercept 130.83 12.3290 96 10.61 <.0001 weight 0.06032 0.04267 639 1.41 0.1580 prev 16.8923 2.3608 639 7.16 <.0001 age 0.8011 0.3883 639 2.06 0.0395 time 0.1715 0.01428 96 12.00 <.0001 time*diet 0.1444 0.02027 639 7.12 <.0001 prev*time 0.1154 0.02805 639 4.11 <.0001 prev*time*diet 0.07575 0.03915 639 1.93 0.0534 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F weight 1 639 2.00 0.1580 prev 1 639 51.20 <.0001 age 1 639 4.26 0.0395 time 1 96 144.11 <.0001 time*diet 1 639 50.76 <.0001 prev*time 1 639 16.92 <.0001 prev*time*diet 1 639 3.74 0.0534 ******************************************************************* ********************************************************************/ /******************************************************************* Model (iv) -- "reduced" model with no diet or previous weightlifting effect *******************************************************************/ title 'MODEL (iv)'; proc mixed method=ml data=pdat; class id; model press = weight prev age time / solution; random intercept time / type=un subject=id; run; /******************************************************************* ******************************************************************** Dimensions Covariance Parameters 4 Columns in X 5 Columns in Z Per Subject 2 Subjects 100 Max Obs Per Subject 12 Cov Parm Subject Estimate UN(1,1) id 104.01 UN(2,1) id 0.1711 UN(2,2) id 0.01930 Residual 13.7321 Fit Statistics -2 Log Likelihood 5437.2 AIC (smaller is better) 5455.2 AICC (smaller is better) 5455.4 BIC (smaller is better) 5478.6 Null Model Likelihood Ratio Test DF Chi-Square Pr > ChiSq 3 2244.39 <.0001 Solution for Fixed Effects Standard Effect Estimate Error DF t Value Pr > |t| Intercept 130.96 12.3232 96 10.63 <.0001 weight 0.06097 0.04265 639 1.43 0.1533 prev 15.7659 2.3516 639 6.70 <.0001 age 0.8044 0.3881 639 2.07 0.0386 time 0.2851 0.01399 99 20.39 <.0001 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F weight 1 639 2.04 0.1533 prev 1 639 44.95 <.0001 age 1 639 4.29 0.0386 ******************************************************************* ********************************************************************/