/******************************************************************* CHAPTER 8, EXAMPLE 1 Analysis of the dental study data by fitting a general linear regression model in time and gender structures using PROC MIXED. - the repeated measurement factor is age (time) - there is one "treatment" factor, gender For each gender, the "full" mean model is a straight line in time. We use the REPEATED statement of PROC MIXED with the TYPE= options to fit the model assuming several different covariance structures. *******************************************************************/ options ls=80 ps=59 nodate; run; /****************************************************************** Read in the data set (See Example 1 of Chapter 4) *******************************************************************/ data dent1; infile "dental.txt"; input obsno child age distance gender; ag = age*gender; run; /******************************************************************* Sort the data so we can do gender-by-gender fits. *******************************************************************/ proc sort data=dent1; by gender; run; proc print data=dent1; run; /******************************************************************* ******************************************************************** PROC REG ******************************************************************** ******************************************************************* /******************************************************************* First the straight line model separately for each gender and simultaneously for both genders assuming that the covariance structure of a data vector is diagonal with constant variance; that is, use ordinary least squares for each gender separately and then together. *******************************************************************/ title "ORDINARY LEAST SQUARES FITS BY GENDER"; proc reg data=dent1; by gender; model distance = age; run; /******************************************************************* PARTIAL OUTPUT ******************************************************************* ***************************************************************** Model: (girls) Y_ij = betaG0 + betaG1 t_ij + eps_ij ; eps ~ iid N(0, sigma^2) ---------------------------------- gender=0 ----------------------------------- The REG Procedure Model: MODEL1 Dependent Variable: distance Number of Observations Read 44 Number of Observations Used 44 Analysis of Variance Sum of Mean Source DF Squares Square F Value Pr > F Model 1 50.59205 50.59205 10.80 0.0021 Error 42 196.69773 4.68328 Corrected Total 43 247.28977 Root MSE 2.16409 R-Square 0.2046 Dependent Mean 22.64773 Adj R-Sq 0.1856 Coeff Var 9.55543 Parameter Estimates Parameter Standard Variable DF Estimate Error t Value Pr > |t| Intercept (betaG0) 1 17.37273 1.63776 10.61 <.0001 age (betaG1) 1 0.47955 0.14590 3.29 0.0021 *******************************************************************/ title "ORDINARY LEAST SQUARES FIT WITH BOTH GENDERS"; proc reg data=dent1; model distance = gender age ag; run; /******************************************************************* PARTIAL OUTPUT ******************************************************************* ***************************************************************** Model: Y_ij = betaB0 + beta_GB0 1(subj_i is BOY )+ betaB1 t_ij + betaGB1 (subj_i is BOY) t_ij + eps_ij ; eps ~ iid N(0, sigma^2) ORDINARY LEAST SQUARES FIT WITH BOTH GENDERS 8 The REG Procedure Model: MODEL1 Dependent Variable: distance Number of Observations Read 108 Number of Observations Used 108 Analysis of Variance Sum of Mean Source DF Squares Square F Value Pr > F Model 3 387.93503 129.31168 25.39 <.0001 Error 104 529.75710 5.09382 Corrected Total 107 917.69213 Root MSE 2.25695 R-Square 0.4227 Dependent Mean 24.02315 Adj R-Sq 0.4061 Coeff Var 9.39489 Parameter Estimates Parameter Standard Variable DF Estimate Error t Value Pr > |t| Intercept (betaB0) 1 17.37273 1.70803 10.17 <.0001 gender (beta_GB0) 1 -1.03210 2.21880 -0.47 0.6428 age (beta_B1) 1 0.47955 0.15216 3.15 0.0021 ag (beta_GB1) 1 0.30483 0.19767 1.54 0.1261 *******************************************************************/ /******************************************************************* Now use PROC MIXED to fit the more general regression model with assumptions about the covariance matrix of a data vector. For all of the fits, we use usual normal maximum likelihood (ML) rather than restricted maximum likelihood (REML), which is the default. We do this for each gender separately first using the unstructured assumption. The main goal is to get insight into whether it might be the case that the covariance matrix is different for each gender (e.g. variation is different for each). The SOLUTION option in the MODEL statement requests that the estimates of the regression parameters be printed. The R option in the REPEATED statement as used here requests that the covariance matrix estimate be printed in matrix form. The RCORR option requests that the corresponding correlation matrix be printed. *******************************************************************/ * unstructured covariance matrix; title "FIT WITH UNSTRUCTURED COVARIANCE FOR EACH GENDER"; proc mixed method=ml data=dent1; by gender; class child; model distance = age / solution; repeated / type = un subject=child r rcorr; run; /******************************************************************* PARTIAL OUTPUT ******************************************************************* The Mixed Procedure Solution for Fixed Effects Standard Effect Estimate Error DF t Value Pr > |t| Intercept 15.8282 1.1179 15 14.16 <.0001 age 0.8340 0.09274 15 8.99 <.0001 Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F age 1 15 80.86 <.0001 *******************************************************************/