/*SAMPLE SIZE AND POWER calculators for HAZARD RATIO (cohort studies and clinical trials)*/ /*Caclulates sample size for fixed power or power for fixed sample size*/ /*Calculates sample size and power for a range of hazard ratio values*/ /*Assumes two comparison groups: one "treated" group (treated, exposed, intervention, etc.) and one "control" group (placebo, unexposed, comparison treatment, etc.)*/ /*Assumes time-to-event outcome data*/ /*Null hypothesis: hazard ratio between the two comparison groups is equal to 1.0*/ /*Assumes two-tailed test at .05 significance*/ /*Author: Kristin Cobb, March 2005*/ /*SAMPLE SIZE CALCULATOR: sample size from power: under different assumptions for the hazard ratio*/ /*User enters: pcontrol = proportion of control group who you expect to have the outcome by the end of the study (*entered as a decimal, e.g. .50) power = how much statistical power you want (entered as a decimal, e.g. 0.80) r = ratio of the control group to the treatment group (e.g., 2:1 control:treatment) HR= Expected hazard ratio for the treated group compared with the control group (e.g. ratio of risk for treatment: control) ltf= expected percentage of the whole sample that will be lost to follow-up (entered as a decimal, e.g. .15) */ %macro samplesize(pcontrol, power, r, HR, ltf); data samplesize; if &HR.>1 then do; do i=1.1 to &HR.+1 by .10; HR=i; pt=1-(1-&pcontrol.)**HR; Zbeta=probit(&power.); num=(1.96+Zbeta)**2; den=(log(HR))**2; ntreat=ceil(((1/(&r.*&pcontrol.)+1/pt)*num/den)/(1-<f.)); ncontrol=ceil((&r.*ntreat)); output; end; end; if &HR.<=1 then do; do i=.1 to .90 by .10; HR=i; pt=1-(1-&pcontrol.)**HR; Zbeta=probit(&power.); num=(1.96+Zbeta)**2; den=(log(HR))**2; ntreat=ceil(((1/(&r.*&pcontrol.)+1/pt)*num/den)/(1-<f.)); ncontrol=ceil((&r.*ntreat)); output; end; end; run; proc print data=samplesize noobs; var HR ntreat ncontrol; run; %mend samplesize; /*example usage of sample size macro:*/ %samplesize(pcontrol=.50, power=.80, r=1.5, HR=.75, ltf=.15); /*POWER CALCULATOR: power from sample size: under different assumptions for the hazard ratio*/ /*User enters: pcontrol = proportion of control group who you expect to have the outcome by the end of the study (*entered as a decimal, e.g. .50) ncontrol = number of people in the control group ntreat = number of people in the treatment group HR= Expected hazard ratio for the treated group compared with the control group (e.g. ratio of risk for treatment: control) ltf= expected percentage of the whole sample that will be lost to follow-up (entered as a decimal, e.g. .15) */ %macro power(pcontrol, ntreat, ncontrol, HR, ltf); data power; if &HR.>1 then do; do i=1.1 to &HR.+1 by .10; HR=i; pt=1-(1-&pcontrol.)**HR; den=(log(HR))**2; r=&ncontrol./&ntreat.; num=&ntreat.*(1-<f.)*den/(1/(r*&pcontrol.)+1/pt); Zbeta=sqrt(num)-1.96; power=cdf('normal',Zbeta); output; end; end; if &HR.<=1 then do; do i=.1 to .90 by .1; HR=i; pt=1-(1-&pcontrol.)**HR; den=(log(HR))**2; r=&ncontrol./&ntreat.; num=&ntreat.*(1-<f.)*den/(1/(r*&pcontrol.)+1/pt); Zbeta=sqrt(num)-1.96; power=cdf('normal',Zbeta); output; end; end; run; proc print data=power noobs; var HR power; run; %mend power; /*example usage of power macro:*/ %power(pcontrol=.50, ncontrol=675, ntreat=410, HR=.75, ltf=.15);