Appendix B
SAS/IML program for computing the power for the test of contrast effect
PROC IML;
*USER SPECIFICATION PORTION;
*DESIGNATED ALPHA;ALPHA=0.05;
*NUMBER OF GROUPS;G=3;
*NUMBER OF COVARIATES;P=2;
*GROUP SIZES;NVEC={22 22 22};
*ADJUSTED GROUP MEANS;MUVEC={8.2220 9.8148 6.1904};
*VARIANCE;SIGSQ=5.6589;
*CONTRAST COEFFICIENTS;CVEC={0.5 0.5 -1};
*TUKEY-KRAMER TEST: TK=1 FOR YES;TK=0;
*END OF USER SPECIFICATION PORTION;
PSI=CVEC*MUVEC`;
NT=SUM(NVEC);DF=NT-G-P;TCRIT=TINV(1-ALPHA/2,DF);
IF TK=1 THEN TCRIT=PROBMC('RANGE',.,1-ALPHA,DF,G)/SQRT(2);
A=SUM((CVEC##2)/NVEC);
DELTA=PSI/SQRT(SIGSQ);
NUMINT=2000;DD=1E-5;
COEVEC=({1}||REPEAT({4 2},1,NUMINT/2-1)||{4 1})`;
IF P=1 THEN DO;
DFT=DF+1;TL=QUANTILE('T',DD,DFT);TU=-TL;
INTL=(TU-TL)/NUMINT;TVEC=TL+(INTL#(0:NUMINT))`;
WTPDF=(INTL/3)#COEVEC#PDF('T',TVEC,DFT);
TBPOWER=WTPDF`*(CDF('T',-TCRIT,DF,PSI/SQRT(SIGSQ#A#(1+TVEC##2/DFT)))+SDF('T',TCRIT,DF,PSI/SQRT(SIGSQ#A#(1+TVEC##2/DFT))));
END;ELSE DO;
BL=DD;BU=1-DD;INTL=(BU-BL)/NUMINT;BVEC=BL+(INTL#(0:NUMINT))`;
DFB1=(DF+1)/2;DFB2=P/2;
WBPDF=(INTL/3)#COEVEC#PDF('BETA',BVEC,DFB1,DFB2);
TBPOWER=WBPDF`*(CDF('T',-TCRIT,DF,SQRT(BVEC)#PSI/SQRT(SIGSQ#A))+SDF('T',TCRIT,DF,SQRT(BVEC)#PSI/SQRT(SIGSQ#A)));
END;
PRINT G P NVEC DELTA;
PRINT TBPOWER[FORMAT=8.4];
QUIT;
Appendix C
SAS/IML program for computing the sample size for the test of contrast effect
PROC IML;
*USER SPECIFICATION PORTION;
*DESIGNATED ALPHA;ALPHA=0.05;
*NOMINAL POWER;POWER=0.8;
*NUMBER OF GROUPS;G=3;
*NUMBER OF COVARIATES;P=2;
*GROUP RATIOS;RVEC={1 1 1};
*ADJUSTED GROUP MEANS;MUVEC={8.2220 9.8148 6.1904};
*VARIANCE;SIGSQ=5.6589;
*CONTRAST COEFFICIENTS;CVEC={0.5 0.5 -1};
*TUKEY-KRAMER TEST: TK=1 FOR YES;TK=0;
*END OF SPECIFICATION;
PSI=CVEC*MUVEC`;
DELTA=PSI/SQRT(SIGSQ);
NUMINT=2000;DD=1E-5;
COEVEC=({1}||REPEAT({4 2},1,NUMINT/2-1)||{4 1})`;
START TBPOWERF;
IF P=1 THEN DO;
DFT=DF+1;TL=QUANTILE('T',DD,DFT);TU=-TL;
INTL=(TU-TL)/NUMINT;TVEC=TL+(INTL#(0:NUMINT))`;
WTPDF=(INTL/3)#COEVEC#PDF('T',TVEC,DFT);
TBPOWER=WTPDF`*(CDF('T',-TCRIT,DF,PSI/SQRT(SIGSQ#A#(1+TVEC##2/DFT)))+SDF('T',TCRIT,DF,PSI/SQRT(SIGSQ#A#(1+TVEC##2/DFT))));
END;ELSE DO;
BL=DD;BU=1-DD;INTL=(BU-BL)/NUMINT;
BVEC=BL+(INTL#(0:NUMINT))`;
DFB1=(DF+1)/2;DFB2=P/2;
WBPDF=(INTL/3)#COEVEC#PDF('BETA',BVEC,DFB1,DFB2);
TBPOWER=WBPDF`*(CDF('T',-TCRIT,DF,SQRT(BVEC)#PSI/SQRT(SIGSQ#A))+SDF('T',TCRIT,DF,SQRT(BVEC)#PSI/SQRT(SIGSQ#A)));
END;
FINISH;
N=5;
DO UNTIL (TBPOWER>POWER | N>1000);
N=N+1;NVEC=N#RVEC;NT=SUM(NVEC);
DF=NT-G-P;A=SUM(CVEC##2/NVEC);TCRIT=TINV(1-ALPHA/2,DF);
IF TK=1 THEN TCRIT=PROBMC('RANGE',.,1-ALPHA,DF,G)/SQRT(2);
RUN TBPOWERF;END;
PRINT G P POWER DELTA[FORMAT=8.4];
PRINT N NVEC NT TBPOWER[FORMAT=8.4];
QUIT;
Appendix D
R program for computing the power for the test of contrast effect
function () {
#USER SPECIFICATION PORTION
alpha<-0.05 #DESIGNATED ALPHA
g<-3 #NUMBER OF GROUPS
p<-2 #NUMBER OF COVARIATES
nvec<-c(22,22,22) #GROUP SIZES
muvec<-c(8.2220,9.8148,6.1904) #ADJUSTED GROUP MEANS
sigsq<-5.6589 #VARIANCE
cvec<-c(0.5,0.5,-1) #CONTRAST COEFFICIENTS
tk<-0 #TUKEY-KRAMER TEST: tk=1 FOR YES;
#END OF SPECIFICATION
psi<-sum(cvec*muvec)
nt<-sum(nvec)
df<-nt-g-p
tcrit<-qt(1-alpha/2,df)
if (tk==1) tcrit<-qtukey(1-alpha,g,df)/sqrt(2)
a<-sum((cvec^2)/nvec)
delta<-psi/sqrt(sigsq)
numint<-2000
dd<-1e-5
coevec<-c(1,rep(c(4,2),numint/2-1),4,1)
if (p==1) {
dft<-df+1
tl<-qt(dd,dft)
tu<--tl
intl<-(tu-tl)/numint
tvec<-tl+intl*(0:numint)
wtpdf<-(intl/3)*coevec*dt(tvec,dft)
tbpower<-sum(wtpdf*(pt(-tcrit,df,psi/sqrt(sigsq*a*(1+tvec^2/dft)))+
pt(tcrit,df,psi/sqrt(sigsq*a*(1+tvec^2/dft)),lower.tail=FALSE)))
}
else {
bl<-dd
bu<-1-dd
intl<-(bu-bl)/numint
bvec<-bl+intl*(0:numint)
dfb1<-(df+1)/2
dfb2<-p/2
wbpdf<-(intl/3)*coevec*dbeta(bvec,dfb1,dfb2)
tbpower<-sum(wbpdf*(pt(-tcrit,df,sqrt(bvec)*psi/sqrt(sigsq*a))+
pt(tcrit,df,sqrt(bvec)*psi/sqrt(sigsq*a),lower.tail=FALSE)))
}
print("g, p, group sizes, delta")
print(c(g,p,nvec,delta))
print("tbpower")
print(c(tbpower),digits=4)
}
Appendix E
R program for computing the sample size for the test of contrast effect
function () {
#USER SPECIFICATION PORTION
alpha<-0.05 #DESIGNATED ALPHA
power<-0.90 #NOMINAL POWER
g<-3 #NUMBER OF GROUPS
p<-2 #NUMBER OF COVARIATES
rvec<-c(1,1,1) #GROUP RATIOS
muvec<-c(8.2220,9.8148,6.1904) #ADJUSTED GROUP MEANS
sigsq<-5.6589 #VARIANCE
cvec<-c(0.5,0.5,-1) #CONTRAST COEFFICIENTS
tk<-0 #TUKEY-KRAMER TEST: tk=1 FOR YES;
#END OF SPECIFICATION
psi<-sum(cvec*muvec)
delta<-psi/sqrt(sigsq)
numint<-2000
dd<-1e-5
coevec<-c(1,rep(c(4,2),numint/2-1),4,1)
tbpowerf<-function () {
if (p==1) {
dft<-df+1
tl<-qt(dd,dft)
tu<--tl
intl<-(tu-tl)/numint
tvec<-tl+intl*(0:numint)
wtpdf<-(intl/3)*coevec*dt(tvec,dft)
tbpower<-sum(wtpdf*(pt(-tcrit,df,psi/sqrt(sigsq*a*(1+tvec^2/dft)))+
pt(tcrit,df,psi/sqrt(sigsq*a*(1+tvec^2/dft)),lower.tail=FALSE)))
}
else {
bl<-dd
bu<-1-dd
intl<-(bu-bl)/numint
bvec<-bl+intl*(0:numint)
dfb1<-(df+1)/2
dfb2<-p/2
wbpdf<-(intl/3)*coevec*dbeta(bvec,dfb1,dfb2)
tbpower<-sum(wbpdf*(pt(-tcrit,df,sqrt(bvec)*psi/sqrt(sigsq*a))+
pt(tcrit,df,sqrt(bvec)*psi/sqrt(sigsq*a),lower.tail=FALSE)))
}}
n<-5
tbpower<-0
while(tbpower<power & n<1000){
n<-n+1
nvec<-n*rvec
nt<-sum(nvec)
df<-nt-g-p
tcrit<-qt(1-alpha/2,df)
if (tk==1) tcrit<-qtukey(1-alpha,g,df)/sqrt(2)
a<-sum((cvec^2)/nvec)
tbpower<-tbpowerf()
}
print("g, p, power, delta")
print(c(g,p,power,delta))
print("n, group sizes, nt, tbpower")
print(c(n,nvec,nt,tbpower),digits=4)
}
1