********************* Final Model For Simulated Data ************************ Simulated data: 10 controls, 10 treated >>> SAS program data Sim2; infile 'Sim.dat'; input id age sex rx time attrib; cos24=cos(2*3.14159/24*time); cos8=cos(2*3.14159/8*time); sin24=sin(2*3.14159/24*time); sin8=sin(2*3.14159/8*time); artime=int(time*100); /* remove decimals to get correct sort order */ run; proc mixed data=Sim2 info ic; class rx artime; model attrib = rx age cos24 sin24 cos8 sin8 rx*cos24 rx*sin24 /s; random rx cos24 sin24/type=UN(1) sub=id; repeated artime / type=ar(1) sub=id; run; >>> SAS Results Dimensions Covariance Parameters 12 Columns in Z Per Subject 4 Subjects 20 Max Obs Per Subject 97 Observations Used 1940 Convergence criteria met. Covariance Parameter Estimates Cov Parm Subject Estimate UN(1,1) id 2.5085 UN(2,2) id 44.7180 UN(3,3) id 2.0744 UN(4,4) id 2.9842 AR(1) id 0.4946 Residual 1.2820 Fit Statistics BIC (smaller is better) 5717.6 Solution for Fixed Effects Standard Effect rx Estimate Error DF t Value Pr > |t| Intercept 41.7667 2.5481 17 16.39 <.0001 rx 0 -6.9095 2.1865 17 -3.16 0.0057 age 0.2517 0.03881 1878 6.49 <.0001 cos24 2.0907 0.4635 18 4.51 0.0003 sin24 4.5592 0.5534 18 8.24 <.0001 cos8 5.0219 0.05910 1878 84.98 <.0001 sin8 4.9906 0.06063 1878 82.32 <.0001 cos24*rx 0 1.8828 0.6555 1878 2.87 0.0041 sin24*rx 0 -2.0252 0.7826 1878 -2.59 0.0097 >>> Comparison of True and Analyzed Models True biorhythm of simulated "attrib" Fundamental frequency=1/24 hours, harmonic=1/8 hours All subjects: Harmonic amplitude=7, harmonic phase shift= -1 hour, fundamental amplitude=5 +/- 1(sd), mean rises(falls) 3 per decade past(before) age 40 Controls: mean=45 +/- 2(sd), fundamental phase shift= 4 +/- 2(sd) Treated: mean=50 +/- 5(sd), fundamental phase shift= -2 +/- 2(sd) Autoregression coefficient=0.5 Residual variance=1.0 Analyzed biorhythm of simulated "attrib" Fundamental frequency=1/24 hours, harmonic=1/8 hours Rx group 0: cos24 slope=3.97, sin24 slope=2.53 Rx group 1: cos24 slope=2.09, sin24 slope=4.56 All subjects: cos8 slope=5.02, sin8 slope=4.99, cos24 slope~ +/- 0.96 (sd), sin24 slope~ +/-1.29 (sd), mean rises(falls) 2.5 per decade past(before) age 40 Controls: mean=34.8 +/- 1.3 (sd) Treated: mean=41.8 +/- 21.2 (sd) Autoregression coefficient=0.49 Residual variance=1.28 ??These 8 hour slopes correspond to amplitude=7.08, phase shift= +1.0 hours. ??At 24 hours, amplitude=4.67, phase shift= +3.3 hours. The match is quite good. Of course, even a perfect procedure would not give a perfect match, because the simulation is just a sample of patients from the true distribution. All of the major features are accounted for in the analysis: use of fundamental frequency plus a single harmonic, a random intercept which has a different variance for controls vs. treated subjects, and an autoregressive error structure. There is difference between the true means and their estimates. The variation in the mean of the treated subjects is larger than the true value. And a single phase shift for 24 hours of +3.3 was found instead of separate shifts of +4 and -2. One way to compare the random phase and amplitude used in the simulation to the random slopes on cos24 and sin24 is to generate data with the simulated values, convert each to the sin/cos form, and calculate the covariance of the resulting data. This is done in the Splus program SimConvert.q. The results are: Control: SinFundCoef CosFundCoef Sd SinFundCoef 3.6278450 -0.5368537 1.905 CosFundCoef -0.5368537 4.0444480 2.011 Rx: SinFundCoef CosFundCoef Sd SinFundCoef 4.0565635 -0.2382878 2.014 CosFundCoef -0.2382878 3.6112120 1.900 50/50 Mix: SinFundCoef CosFundCoef Sd SinFundCoef 4.219634 -0.759194 2.054 CosFundCoef -0.759194 4.190348 2.047 These are somewhat larger than the estimates of 0.96 and 1.29. Note that the estimate of the correlation in model 8) is -0.652 which compares favorably with -0.759194.