A New View of Statistics

© 1998 Will G Hopkins

Go to: Previous · Contents · Search · Home


REPEATED MEASURES WITH PROC MIXED:
ONE WITHIN- AND ONE BETWEEN-SUBJECT FACTOR

/*
Simple repeated measures, one within-subject effect (test), 
with four levels; plus one between effect (grp) to represent 
treatment and control groups.
*/
 
options linesize=78;
options pagesize=32;
 
/*
Generates data for 20 athletes in each group:
   true means=60, 62; between SDs=8 (excluding within SD); within SDs=3.
The mean increases by 0.4 at each retest in each group, to simulate a 
learning effect.
An experimental effect of 4.0 is added in the third test for the 
drug group.
Try 200 athletes in each group if you want to see these effects clearly.
*/
 
data dat1;
grp="drug";
do athlete=1 to 20;
  true=60+8*rannor(0);
  dist1=true+3*rannor(0);
  dist2=true+0.4+3*rannor(0);
  dist3=true+0.8+3*rannor(0)+4;
  dist4=true+1.2+3*rannor(0);
  output;
end;
grp="cont";
do athlete=21 to 40;
  true=62+8*rannor(0);
  dist1=true+3*rannor(0);
  dist2=true+0.4+3*rannor(0);
  dist3=true+0.8+3*rannor(0);
  dist4=true+1.2+3*rannor(0);
  output;
end;
run;
 
*checks means and SDs of data;
proc sort;
by grp;
 
proc means n mean std maxdec=1;
var true dist1-dist4;
by grp;
run;
 
*Converts data to the form proc mixed uses;
data;
set dat1;
distance=dist1; test=1; output;
distance=dist2; test=2; output;
distance=dist3; test=3; output;
distance=dist4; test=4; output;
drop true dist1-dist4;
 
*first time through;
proc mixed;
class athlete grp test;
model distance=grp test grp*test;
repeated test/subject=athlete r rcorr type=un;
title "First pass, with unstructured covariance matrix";
run;
 
*second time through;
proc mixed covtest cl;
class athlete grp test;
model distance=grp test grp*test;
repeated test/subject=athlete r rcorr type=cs;
lsmeans grp*test;
estimate 'drug-cont 2-1' grp*test -1  1  0  0   1 -1  0  0 /cl;
estimate 'drug-cont 3-2' grp*test  0 -1  1  0   0  1 -1  0 /cl;
estimate 'drug-cont 4-3' grp*test  0 -1  0  1   0  1  0 -1 /cl;
estimate 'drug-cont 3-2&4' grp*test 0 0.5 -1 0.5  0 -0.5 1 -0.5 /cl;
title "Second pass, with compound symmetry";
run;


Go to: Previous · Contents · Search · Home
resources=AT=sportsci.org · webmaster=AT=sportsci.org · Sportsci Homepage · Copyright ©1997
Last updated 13 May 98