/* (Programmed by Phil Chapman; revised 9-7-95; send comments or corrections to: pchapman@lamar.colostate.edu) This program calculates power for one-sided t-tests in simple linear regression problems. The power is calculated as if the values of the independent (X) variable are known (or at least fixed). For a given slope, power is estimated for a variety of sample sizes specified by the user. User input values: 1. alpha: the type I error probability. Most researchers use 0.05. 2. sigma: the standard deviation of the errors (the vertical distances between the regression line and the individual responses) 3. sx: the sample standard deviation of the independent (X) values. The X values are taken as fixed, and are often controlled by the researcher. (This will be calculated with an n-1 in the denominator.) 4. beta0 the null hypothesis slope, often taken to be zero. 5. beta1 the alternative hypothesis slope, the slope that the researcher wishes to detect by the test. (Assumed greater than beta0) 6. n1,n2,n3 the sample size minimum, maximum and increment to be considered. For example 3,20,2 would calculate power for all even sample sizes from 3 to 20. n1 must be at least three for the test for slope to exist. 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 any of 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 powerreg; * BEGIN USER INPUTS; alpha=0.05; sigma=1.0; sx=5.0; beta0=0.0; beta1=0.2; n1=4; *n1 must be at least 3; n2=20; n3=2; * END USER INPUTS; do n=n1 to n2 by n3; tcrit=tinv(1-alpha,n-2); lambda=((beta1-beta0)*(sx*sqrt(n-1)/sigma)); power=1-probt(tcrit,n-2,lambda); output; end; proc print; var sigma beta1 n power; proc plot; plot power*n; run;