A New View of Statistics

© 1997 Will G Hopkins

Go to: Previous · Contents · Search · Home


SIMULATION FOR MULTIPLE CROSS-OVERS

SAS program to generate confidence intervals for treatments in a cross-over with two experimental treatments and a control treatment.

Use your own data step with your own data, then copy the proc mixed part of this program to analyze them. Delete "by sim".

Main finding: for reliability=0.95, a sample size of 12 gives a confidence interval of about 0.38 effect-size units, which is an acceptable width for the smallest effects (see Sample Size On The Fly for further discussion about acceptable confidence intervals). The model using the trial effect has a slight advantage over the model with the group effect for a compound-symmetric covariance matrix, but the advantage is greater with an unstructured covariance matrix (CI of 0.40 vs 0.44).

WARNING: To those using trial and treat as within-subject measures (the recommended method)... If you use a covariance structure other than compound symmetry, you should specify whether you want trial or treat as the repeated measure that SAS uses to model the covariance structure. Do it in the repeated statement. In general choose treat, because if there is a problem with different variances (lack of sphericity), it will be because of individual differences in the response to the treatments. But it is possible that subjects are more variable in their response to different trials (first, second, third...) rather than different treatments, if, for example, the outcome measure is the response to a difficult test that some subjects master quicker than others. I guess you should try both and examine the covariances. You might need sophisticated help here.

If you don't specify a repeated effect, SAS seems to decide which one to use on the basis of the sort order and completeness of the data set, not on the basis of the order of the terms in the class or model statements.

options linesize=75;
options pagesize=30;
 
%macro simdata;
data dat1;
do sim=1 to 100;
group="C-Ta-Tb";
do id=1 to &n;
  true=rannor(0)+&gpCTaTb;
  treat="control"; trial=1;
  depvar=sqrt(&r)*(true+&learn1+&control)+sqrt(1-&r)*rannor(0);
  output;
  treat="treata"; trial=2;
  depvar=sqrt(&r)*(true+&learn2+&treata)+sqrt(1-&r)*rannor(0);
  output;
  treat="treatb"; trial=3;
  depvar=sqrt(&r)*(true+&learn3+&treatb)+sqrt(1-&r)*rannor(0);
  output;
  end;
group="Ta-Tb-C";
do id=&n+1 to 2*&n;
  true=rannor(0)+&gpTaTbC;
  treat="control"; trial=3;
  depvar=sqrt(&r)*(true+&learn3+&control)+sqrt(1-&r)*rannor(0);
  output;
  treat="treata"; trial=1;
  depvar=sqrt(&r)*(true+&learn1+&treata)+sqrt(1-&r)*rannor(0);
  output;
  treat="treatb"; trial=2;
  depvar=sqrt(&r)*(true+&learn2+&treatb)+sqrt(1-&r)*rannor(0);
  output;
  end;
group="Tb-C-Ta";
do id=2*&n+1 to 3*&n;
  true=rannor(0)+&gpTbCTa;
  treat="control"; trial=2;
  depvar=sqrt(&r)*(true+&learn2+&control)+sqrt(1-&r)*rannor(0);
  output;
  treat="treata"; trial=3;
  depvar=sqrt(&r)*(true+&learn3+&treata)+sqrt(1-&r)*rannor(0);
  output;
  treat="treatb"; trial=1;
  depvar=sqrt(&r)*(true+&learn1+&treatb)+sqrt(1-&r)*rannor(0);
  output;
  end;
group="C-Tb-Ta";
do id=3*&n+1 to 4*&n;
  true=rannor(0)+&gpCTbTa;
  treat="control"; trial=1;
  depvar=sqrt(&r)*(true+&learn1+&control)+sqrt(1-&r)*rannor(0);
  output;
  treat="treata"; trial=3;
  depvar=sqrt(&r)*(true+&learn3+&treata)+sqrt(1-&r)*rannor(0);
  output;
  treat="treatb"; trial=2;
  depvar=sqrt(&r)*(true+&learn2+&treatb)+sqrt(1-&r)*rannor(0);
  output;
  end;
group="Ta-C-Tb";
do id=4*&n+1 to 5*&n;
  true=rannor(0)+&gpTaCTb;
  treat="control"; trial=2;
  depvar=sqrt(&r)*(true+&learn2+&control)+sqrt(1-&r)*rannor(0);
  output;
  treat="treata"; trial=1;
  depvar=sqrt(&r)*(true+&learn1+&treata)+sqrt(1-&r)*rannor(0);
  output;
  treat="treatb"; trial=3;
  depvar=sqrt(&r)*(true+&learn3+&treatb)+sqrt(1-&r)*rannor(0);
  output;
  end;
group="Tb-Ta-C";
do id=5*&n+1 to 6*&n;
  true=rannor(0)+&gpTbTaC;
  treat="control"; trial=3;
  depvar=sqrt(&r)*(true+&learn3+&control)+sqrt(1-&r)*rannor(0);
  output;
  treat="treata"; trial=2;
  depvar=sqrt(&r)*(true+&learn2+&treata)+sqrt(1-&r)*rannor(0);
  output;
  treat="treatb"; trial=1;
  depvar=sqrt(&r)*(true+&learn1+&treatb)+sqrt(1-&r)*rannor(0);
  output;
  end;
end;
%mend;
 
%let n=2; *number of subjects in each group;
%let r=0.95; *test-retest reliability (intraclass correlation);
%let control=0;
%let treata=0.3; *treatment effect a;
%let treatb=0.5; *treatment effect b;
%let learn1=0;
%let learn2=0.7; *learning effect trial 2;
%let learn3=0.8; *learning effect trial 3;
%let gpCTaTb=0; *effect of nonrandomization to groups;
%let gpTaTbC=1; 
%let gpTbCTa=2;
%let gpCTbTa=3; 
%let gpTaCTb=4; 
%let gpTbTaC=5;
*note: all effects except nonrandomization are attenuated by the reliability;
 
%simdata;
 
/*
*check sequences balanced;
proc freq;
tables group*trial*treat;
run;
*/
 
 
%global _print_;
%let _print_ = off;
 
*Using between-subject group effect;
 
proc mixed covtest cl data=dat1;
class id treat group;
model depvar=treat group treat*group;
repeated treat/subject=id r rcorr type=un;
*repeated /subject=id r rcorr type=cs;
lsmeans treat; *for plotting least-squares means;
estimate 'treata-cont' treat -1 1 0/cl;
estimate 'treatb-cont' treat -1 0 1/cl;
estimate 'treatb-a' treat 0 -1 1/cl;
*estimate 'grp CTbTa-CTaTb' group -1 1 0 0 0 0/cl; *who cares?;
make 'estimate' out=est;
by sim;
title 'Using between-subject group effect';
run;
 
%let _print_ = on;
 
data dat;
set est;
if parm='treata-cont';
confint=upper-lower;
 
proc means n mean maxdec=2;
var est lower upper confint;
 
run;
 
%global _print_;
%let _print_ = off;
 
proc sort;
by id treat trial;
 
*Using within-subject trial effect rather than group effect;
 
proc mixed covtest cl data=dat1;
class id treat trial;
model depvar=treat trial treat*trial;
repeated treat/subject=id r rcorr type=un;
*repeated /subject=id r rcorr type=cs;
lsmeans treat; *for plotting least-squares means;
estimate 'treata-cont' treat -1 1 0/cl;
estimate 'treatb-cont' treat -1 0 1/cl;
estimate 'treatb-a' treat 0 -1 1/cl;
estimate 'learn2-1' trial -1 1 0/cl;
estimate 'learn3-2' trial 0 -1 1/cl;
title 'Using within-subject trial effect';
make 'covparms' out=cp;
make 'estimate' out=est;
by sim;
run;
 
%let _print_ = on;
 
data dat;
set est;
if parm='treata-cont';
confint=upper-lower;
 
proc means n mean maxdec=2;
var est lower upper confint;
 
run;


Go to: Previous · Contents · Search · Home
resources=AT=sportsci.org · webmaster=AT=sportsci.org · Sportsci Homepage · Copyright ©1997
Last updated 19 Feb 97