|
A New View of Statistics | |
Once again I will assume known population SD.
See previous program (longitudinal study
with no control group) for preamble.
options linesize=75;
options pagesize=40;
%macro data;
data dat1;
do trial=1 to &trialn;
do id=1 to &startn/2;
true=rannor(0);
con1=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
con2=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
true=rannor(0);
exp1=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
exp2=sqrt(&r)*true+sqrt(1-&r)*rannor(0)+&es;
ydiff=exp2-exp1-(con2-con1);
output;
end;
end;
keep trial ydiff;
%mend;
%let trialn=1000; *no. of trials;
%let r=0.9; *reliability;
%let es=0.4; *effect size;
%let startn=20; *initial size (=startn/2 in each group);
%let nmax1=40; *total size limit for 1st interation;
%let nmax2=80; *total size limit for 2nd interation;
%data;
data dat0;
set;
dataset="initial";
proc means noprint data=dat1;
var ydiff;
output out=dat n=n mean= std=stdydiff;
by trial;
data dat2;
set;
iter=1;
samplees=ydiff; *denom=1;
confint=2*1.96*stdydiff/sqrt(n);
cipred = 3.575348E-3*samplees**4 + 1.565327E-1*samplees**2 + 4.015905E-1;
if cipred<confint then do;
nnew=round(n*(confint/cipred)**2)-n;
if nnew then do;
if nnew+n>&nmax1/2 then nnew=&nmax1/2-n;
do id=n+1 to nnew+n;
true=rannor(0);
con1=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
con2=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
true=rannor(0);
exp1=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
exp2=sqrt(&r)*true+sqrt(1-&r)*rannor(0)+&es;
ydiff=exp2-exp1-(con2-con1);
output;
end;
end;
end;
keep trial ydiff id nnew iter;
*proc print;
*run;
/*
*checks formulae;
proc univariate noprint;
var samplees;
output mean=mean pctlpre=Q pctlpts=2.5 50 97.5;
title "Sampling distn for es in x-over, r=&r es=&es n=&startn";
title2 "for sample effect size";
proc print;
proc means mean std min max maxdec=2 data=dat2;
var samplees crrctes confint cipred;
title "Stats for es in x-over, r=&r es=&es n=&startn";
title2 "for Becker-derived es and its confidence interval";
run;
*/
*2nd iteration;
data dat1;
set dat1 dat2;
proc sort;
by trial;
*proc print;
*run;
proc means noprint data=dat1;
var ydiff;
output out=dat n=n mean= std=stdydiff;
by trial;
data dat2;
set;
iter=2;
samplees=ydiff; *denom=1;
confint=2*1.96*stdydiff/sqrt(n);
cipred = 3.575348E-3*samplees**4 + 1.565327E-1*samplees**2 + 4.015905E-1;
if cipred<confint then do;
nnew=round(n*(confint/cipred)**2)-n;
if nnew then do;
if nnew+n>&nmax2/2 then nnew=&nmax2/2-n;
do id=n+1 to nnew+n;
true=rannor(0);
con1=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
con2=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
true=rannor(0);
exp1=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
exp2=sqrt(&r)*true+sqrt(1-&r)*rannor(0)+&es;
ydiff=exp2-exp1-(con2-con1);
output;
end;
end;
end;
keep trial ydiff id nnew iter;
*3nd iteration;
data dat1;
set dat1 dat2;
proc sort;
by trial;
proc means noprint data=dat1;
var ydiff;
output out=dat n=n mean= std=stdydiff;
by trial;
data dat2;
set;
iter=3;
samplees=ydiff; *denom=1;
confint=2*1.96*stdydiff/sqrt(n);
cipred = 3.575348E-3*samplees**4 + 1.565327E-1*samplees**2 + 4.015905E-1;
if cipred<confint then do;
nnew=round(n*(confint/cipred)**2)-n;
if nnew then do;
do id=n+1 to nnew+n;
* if nnew+n>&nmax2/2 then nnew=&nmax2/2-n;
true=rannor(0);
con1=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
con2=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
true=rannor(0);
exp1=sqrt(&r)*true+sqrt(1-&r)*rannor(0);
exp2=sqrt(&r)*true+sqrt(1-&r)*rannor(0)+&es;
ydiff=exp2-exp1-(con2-con1);
output;
end;
end;
end;
keep trial ydiff id nnew iter;
*output results;
data dat1;
set dat1 dat2;
dataset="final";
data datboth;
set dat0 dat1;
proc sort;
by dataset trial;
proc means noprint data=datboth;
var ydiff;
output out=dat n=n mean= std=stdydiff;
by dataset trial;
data dat2;
set;
samplees=ydiff; *denom=1;
confint=2*1.96*stdydiff/sqrt(n);
confliml=samplees-confint/2;
conflimu=samplees+confint/2;
proc means noprint;
var n samplees confint confliml conflimu;
by dataset;
output mean=;
proc print noobs;
var dataset n samplees confint confliml conflimu;
format _numeric_ 5.2 n 4.;
title "ES stats rely=&r es=&es startn=&startn trials=&trialn nmax1=&nmax1 nmax2=&nmax2";
title2 "N is the final number in EACH group";
title3 "for controlled longitudinal study";
data datfinal;
set dat2;
if dataset="final";
proc univariate noprint;
var samplees ;
output mean=mean pctlpre=Q pctlpts=2.5 50 97.5;
proc print noobs;
format _numeric_ 5.2;
title "Sampling distn for es, r=&r es=&es n=&startn";
title2 "for final sample effect size";
proc means mean std min max maxdec=0 data=datfinal;
var n;
title "Stats for final sample size r=&r es=&es n=&startn nmax1=&nmax1 nmax2=&nmax2";
title2 "N is the final number in EACH group";
proc sort data=dat1;
by trial iter;
proc means noprint;
var nnew;
output mean=;
by trial iter;
proc sort;
by iter;
proc means noprint;
var nnew;
by iter;
output n=n mean= std=std min=min max=max;
data;
set;
if iter;
proc print noobs;
var iter n nnew std min max;
format _numeric_ 5.0;
title "Number of extra observations at each iteration in EACH group";
title2 "for rely=&r es=&es startn=&startn";
run;
Go to: Previous · Contents · Search
· Home
resources=AT=sportsci.org · webmaster=AT=sportsci.org · Sportsci Homepage · Copyright
©1997
Last updated 31 May 97