options pagesize=65 linesize=65; data one; es=.50 ; *Effect size for largest and smallest mean; alpha=.05 ; *Type I error rate; j=6 ; *Number of levels for the the between-subjects factor for which es is define. j is limited to 6 or less; tpower=.70 ; *Target power; maxn= 2000 ; *Maximum sample size for calculations; prod=1 ; *product of number of levels of the other factors. Equals 1 for a single factor design and equals the number of level in the other factor for a two-factor design; rho=.50 ; *correlation between covariate and dependent variable. Equal to zero if there is no covriate; prob=1-alpha; df1=j-1; if j =3 then do; do i = 1 to 2; if i = 1 then do; config='minimum range and equally spaced '; mu1 = .00; mu2 = es/2; mu3 = es; gm=(mu1 + mu2 + mu3)/j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x1 cval power mu1 mu2 mu3; do over x1; x1=round(x1,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x2 cval power mu1 mu2 mu3; do over x2; x2=round(x2,.01); end; output; n=maxn; end; end; end; if i = 2 then do; config='maximum range, one extreme mean, and two extreme means'; mu1 = .00; mu2 = es; mu3 = es; gm=(mu1 + mu2 + mu3)/j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x3 cval power mu1 mu2 mu3; do over x3; x3=round(x3,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x4 cval power mu1 mu2 mu3; do over x4; x1=round(x4,.01); end; output; n=maxn; end; end; end; end; end; if j=4 then do; do i = 1 to 4; if i = 1 then do; config='minimum range '; mu1 = .00; mu2 = es/2; mu3 = es/2; mu4 = es; gm=(mu1 + mu2 + mu3 + mu4)/j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x5 cval power mu1 mu2 mu3 mu4; do over x5; x5=round(x5,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x6 cval power mu1 mu2 mu3 mu4; do over x6; x6=round(x6,.01); end; output; n=maxn; end; end; end; if i = 2 then do; config='maximum range and two extreme means '; mu1 = .00; mu2 = .00; mu3 = es; mu4 = es; gm=(mu1 + mu2 + mu3 + mu4)/j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x7 cval power mu1 mu2 mu3 mu4; do over x7; x7=round(x7,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x8 cval power mu1 mu2 mu3 mu4; do over x8; x8=round(x8,.01); end; output; n=maxn; end; end; end; if i = 3 then do; config='equally spaced '; mu1 = .00; mu2 = es/3; mu3 = 2*es/3; mu4 = es; gm=(mu1 + mu2 + mu3 + mu4)/j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x9 cval power mu1 mu2 mu3 mu4; do over x9; x9=round(x9,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x10 cval power mu1 mu2 mu3 mu4; do over x10; x10=round(x10,.01); end; output; n=maxn; end; end; end; if i = 4 then do; config='one extreme mean'; mu1=0; mu2=es; mu3=es; mu4=es; gm=(mu1 + mu2 + mu3 + mu4)/j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x11 cval power mu1 mu2 mu3 mu4; do over x11; x11=round(x11,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x12 cval power mu1 mu2 mu3 mu4; do over x12; x12=round(x12,.01); end; output; n=maxn; end; end; end; end; end; if j=5 then do; do i = 1 to 4; if i = 1 then do; config='minimum range '; mu1 = .00; mu2 = es/2; mu3 = es/2; mu4 = es/2; mu5 = es; gm=(mu1 + mu2 + mu3 + mu4 + mu5)/ j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2 + (mu5-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x13 cval power mu1 mu2 mu3 mu4 mu5; do over x13; x13=round(x13,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x14 cval power mu1 mu2 mu3 mu4 mu5; do over x14; x14=round(x14,.01); end; output; n=maxn; end; end; end; if i = 2 then do; config='maximum range and two extreme means'; mu1 = .00; mu2 = .00; mu3 = .00; mu4 = es; mu5 = es; gm=(mu1 + mu2 + mu3 + mu4 + mu5)/ j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2 + (mu5-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x15 cval power mu1 mu2 mu3 mu4 mu5; do over x15; x15=round(x15,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x16 cval power mu1 mu2 mu3 mu4 mu5; do over x16; x16=round(x16,.01); end; output; n=maxn; end; end; end; if i = 3 then do; config='equally spaced '; mu1 = .00; mu2 = es/4; mu3 = es/2; mu4 = 3*es/4; mu5 = es; gm=(mu1 + mu2 + mu3 + mu4 + mu5)/ j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2 + (mu5-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x17 cval power mu1 mu2 mu3 mu4 mu5; do over x17; x17=round(x17,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x18 cval power mu1 mu2 mu3 mu4 mu5; do over x18; x18=round(x18,.01); end; output; n=maxn; end; end; end; if i = 4 then do; config='one extreme mean '; mu1=0; mu2=es; mu3=es; mu4=es; mu5=es; gm=(mu1 + mu2 + mu3 + mu4 + mu5)/ j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2 + (mu5-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x19 cval power mu1 mu2 mu3 mu4 mu5; do over x19; x19=round(x19,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x20 cval power mu1 mu2 mu3 mu4 mu5; do over x20; x20=round(x20,.01); end; output; n=maxn; end; end; end; end; end; if j=6 then do; do i = 1 to 5; if i = 1 then do; config='minimum range '; mu1 = .00; mu2 = es/2; mu3 = es/2; mu4 = es/2; mu5 = es/2; mu6 = es; gm=(mu1 + mu2 + mu3 + mu4 + mu5 + mu6)/j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2 + (mu5-gm)**2 + (mu6-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x21 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x21; x21=round(x21,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x22 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x22; x22=round(x22,.01); end; output; n=maxn; end; end; end; if i = 2 then do; config='maximum range '; mu1 = .00; mu2 = .00; mu3 = .00; mu4 = es; mu5 = es; mu6 = es; gm=(mu1 + mu2 + mu3 + mu4 + mu5 + mu6)/ j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2 + (mu5-gm)**2 + (mu6-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x23 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x23; x23=round(x23,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x24 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x24; x24=round(x24,.01); end; output; n=maxn; end; end; end; if i = 3 then do; config='equally spaced '; mu1 = .00; mu2 = .2*es; mu3 = .4*es; mu4 = .6*es; mu5 = .8*es; mu6 = es; gm=(mu1 + mu2 + mu3 + mu4 + mu5 + mu6)/ j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2 + (mu5-gm)**2 + (mu6-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x25 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x25; x25=round(x25,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x26 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x26; x26=round(x26,.01); end; output; n=maxn; end; end; end; if i = 4 then do; config='one extreme mean '; mu1=-0; mu2=es; mu3=es; mu4=es; mu5=es; mu6=es; gm=(mu1 + mu2 + mu3 + mu4 + mu5 + mu6)/ j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2 + (mu5-gm)**2 + (mu6-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x27 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x27; x27=round(x27,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x28 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x28; x28=round(x28,.01); end; output; n=maxn; end; end; end; if i = 5 then do; config='two extreme means'; mu1= 0; mu2= 0; mu3= es; mu4= es; mu5= es; mu6= es; gm=(mu1 + mu2 + mu3 + mu4 + mu5 + mu6)/ j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2 + (mu5-gm)**2 + (mu6-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x29 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x29; x29=round(x29,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x30 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x30; x30=round(x30,.01); end; output; n=maxn; end; end; end; end; end; if j =2 then do; mu1 = .00; mu2 = es; gm=(mu1 + mu2)/j; delta = (mu1-gm)**2 + (mu2-gm)**2; do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*prod*(n-1);if rho ^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x31 cval power mu1 mu2 mu3; do over x31; x31=round(x31,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x32 cval power mu1 mu2 mu3; do over x32; x32=round(x32,.01); end; output; n=maxn; end; end; end; data two; set one; if j=2; cell_n=n; proc sort; by n; proc print noobs; title1 ' '; title2 ' '; var comment j prod es rho alpha tpower ; proc print noobs; title1 'origin is set so that smallest mean equals zero'; title2 'means are in standard deviation units'; var mu1 mu2 cell_n power ; data three; set one; if j=3; cell_n=n; proc sort; by n; data threea; set three; if _n_=1; proc print noobs; title1 ' '; title2 ' '; var comment j prod es rho alpha tpower ; proc print noobs data=three; title1 'origin is set so that smallest mean equals zero'; title2 'means are in standard deviation units'; var config mu1 mu2 mu3 cell_n power ; data four; set one; if j=4; cell_n=n; proc sort; by n; data foura; set four; if _n_=1; proc print noobs; title1 ' '; title2 ' '; var comment j prod es rho alpha tpower ; proc print noobs data=four; title1 'origin is set so that smallest mean equals zero'; title2 'means are in standard deviation units'; var config mu1 mu2 mu3 mu4 cell_n power ; data five; set one; if j=5; cell_n=n; proc sort; by n; data fivea; set five; if _n_=1; proc print noobs; title1 ' '; title2 ' '; var comment j prod es rho alpha tpower ; proc print noobs data=five; title1 'origin is set so that smallest mean equals zero'; title2 'means are in standard deviation units'; var config mu1 mu2 mu3 mu4 mu5 cell_n power ; data six; set one; if j=6; cell_n=n; proc sort; by n; data sixa; set six; if _n_=1; proc print noobs; title1 ' '; title2 ' '; var comment j prod es rho alpha tpower ; proc print noobs data=six; title1 'origin is set so that smallest mean equals zero'; title2 'means are in standard deviation units'; var config mu1 mu2 mu3 mu4 mu5 mu6 cell_n power ; proc datasets; delete one; quit; run;