/* (Programmed by Phil Chapman; revised 9-16-96; send comments or corrections to pchapman@lamar.colostate.edu) This program calculates power for one sample (two-sided) t-tests. The null hypothesis that mu is equal to mu0 is tested versus the alternative that mu is not equal to mu0. User input values: 1. alpha: the type I error probability. 2. sigma: the standard deviation of the responses. 3. mu0 the hypothesized mean. 4. mu1 the true alternative mean. 5. n1,n2,n3 the sample size minimum, maximum and increment. For example 2,20,2 would calculate power for even sample sizes from 2 to 20. n1 must be at least 2. To run the program change the values below to the desired values and run the program like any other SAS program. Be sure that you do not type over the semi-colons. The output of the program is a plot and a table, both reporting the same results. The program often gives error messages when the power is very close to 1.0; */ data powert; * BEGIN USER INPUTS; alpha=0.05; sigma=4.0; mu0=12; mu1=16; n1=4; *n1 must be at least 2; n2=20; n3=2; * END USER INPUTS; do n=n1 to n2 by n3; tcrit=tinv(1-alpha/2,n-1); lambda=abs(mu1-mu0)/(sigma/sqrt(n)); power=probt(-tcrit,n-1,lambda)+(1-probt(tcrit,n-1,lambda)); output; end; proc print; var tcrit sigma mu0 mu1 n power; proc plot; plot power*n; run;