Section 13.4: Power Analysis for Logistic Regression in 2x2 tables How many Subjects for a Logistic Regression Analysis? This example shows how to compute power for a logistic regression analysis with a two-level classification variable which represents the treatment and the control groups. Construct a 2x2 table as shown below to structure the group and response variable, where response=1 represents the level of the dichotomous response variable which is of greater interest: --------------------- | | response | | |-----------| | | 1 | 0 | odds=PROB(response=1|group)/PROB(response=0|group) |-------+-----+-----| |Group | | | |Trt | ? | 1-? | odds1= ? / (1-?) |-------+-----+-----| |Ref | .25 | .75 | odds2= 0.25 / 0.75 = 0.333 --------------------- The odds ratio is then computed as: Odds Ratio = odds1 / 0.333 =???? First, specify how the control group responds to the dichotomous variable based on your knowledge of the subject matter. That is, you need to fill in the cell for PROB(response=1|group) for the reference group, which in this example, implies you already know or can assume that PROB(response=1|Ref) = 0.25. To solve for the number of subjects, two options are possible here: * specify the desired treatment response (?) and solve for the odds ratio * specify the odds ratio and solve for the desired treatment response (?) The first approach is to specify the ? for the PROB(response=1|treatment) that you would like to observe or that would interest you for the "at risk" or treatment group. Then it is simple to solve for the odds ratio. Find the coefficients for logit model --------------------- | | response | | |-----------| | | 1 | 0 | odds |-------+-----+-----| |Group | | | |Trt | .45 | .55 | odds1= .45/.55 = .818 |-------+-----+-----| |Ref | 25 | .75 | odds2= .25/.75 = .333 --------------------- That is, specify PROB(response=1|trt)= 0.45 as now entered in this table which represents a 0.2 increase as the minimum change from the control group you want to be able to detect. This means the odds ratio is: Odds Ratio = 0.818 / 0.333 = 2.454 To find the logistic regression equation, the intercept is the logit for bottom row or reference category: LOG(odds1) = LOG(.25/(1-.25)) = -1.0986 The value for the group coefficient can be solved from table entries LOG(OR) = LOG(odds1/odds2) = LOG(0.818/0.333) = LOG(2.454) = 0.8978 If think in terms of a desired odds ratio you want to observe, you can work backwards for these equations to compute the coefficient. Or, enter these known values into the following PROC MODEL statements to solve for the logistic regression coefficients given that you know p(Response=1|Ref)=0.25 and your desired odds ratio of 2.4545; %LET prb=0.25; * reference category probability; %LET oddsrt= 2.4545; * desired odds ratio ; * starting values; DATA onn; b_0 =-.2; b_1=.1; RUN; PROC MODEL data=onn; EXP(b_1) - &oddsrt. = 0; LOG(&prb./(1-&prb.)) - b_0 =0; SOLVE b_0 b_1 / OUT=roots(drop=_: ) ; RUN; QUIT; PROC PRINT DATA=roots NOobs; VAR b_0 b_1; FORMAT b_0 b_1 7.4; RUN; bp_0 bp_1 -1.0986 0.8979 Now that you have the logistic regression equation in logit form, construct an exemplary 2x2 table of counts of any "arbitrary size" DATA exmp; TotNExmp = 500; * Total N of exemplary dataset (your choice); DO grp = 0 to 1; * two groups: 0=reference, 1=treatment ; logit = -1.09861 + .89794 * grp; Pr_1 = exp(logit)/(1 + exp(logit)); *Prob of Response=1 for each group; probX = .5 ; * Randomization Rate for the control group (specifies equal sample sizes in each group); DO success = 0 to 1; * 1 = success; IF success = 0 then probY = (1-Pr_1); ELSE probY = Pr_1; * Exemplary count; ExmpCnt = ROUND(TotNExmp*probX*probY,1); OUTPUT; END; END; RUN; Sort file in descending order on both variables PROC SORT DATA=exmp; BY descending grp descending success; RUN * verify the row percents and odds ratio; PROC FREQ DATA=exmp order=data; TABLE grp*success / NOcol NOpercent cmh; WEIGHT exmpcnt; RUN; grp success Frequency| Row Pct | 1| 0| Total ---------+--------+--------+ 1 | 113 | 137 | 250 | 45.20 | 54.80 | ---------+--------+--------+ 0 | 63 | 187 | 250 | 25.20 | 74.80 | ---------+--------+--------+ Total 176 324 500 Estimates of the Common Relative Risk (Row1/Row2) Type of Study Method Value ------------------------------------------- Case-Control Mantel-Haenszel 2.4483 (Odds Ratio) Logit 2.4483 Odds ratio is very close to desired PROC GENMOD DATA=exmp descending; CLASS grp; MODEL success=grp / dist=binomial link=logit type3; FREQ ExmpCnt; run; LR Statistics For Type 3 Analysis Chi- Source DF Square Pr > ChiSq grp 1 22.15 0.000003 ^^^^^ Enter the treatment chi-square value underlined here in the input data directly below to compute power: %INCLUDE "c:\sas\unifypow\UnifyPow020817a.sas"; TITLE1 "Logistic Regression Example"; datalines4; Exemplary chi**2 Nexemplary 500 alpha .01 .05 power .80 .90 ForceN 2 . Forces Ntotal to be multiple of 2 effects "TREATMENT vs. CONTROL" 1 22.15 ;;;; NOTE: You can obtain this macro to run power analysis for logistic regression from: http://www.bio.ri.ccf.org/power.html Scenario: Exemplary chi**2 -------------------------------------------------------- | | alpha | | |---------------------------| | | 0.010 | 0.050 | | |-------------+-------------| | |Minimum Power|Minimum Power| | |-------------+-------------| | |0.800 |0.900 |0.800 |0.900 | | |------+------+------+------| | |Total |Total |Total |Total | | | N | N | N | N | |--------------------------+------+------+------+------| |Effect |Statistic | | | | | |------------+-------------| | | | | |TREATMENT |2-sided | 264| 338| 178| 238| |vs. CONTROL |-------------+------+------+------+------| | |1-sided | 228| 294| 140| 194| -------------------------------------------------------- PROC POWER also has capabilities to compute power for specified number of subjects. Notice how easy it is to enter either the desired odds ratio (example 1) or the two group proportions (example 2) for the same data as described above: Example 1: Enter odds ratio and reference group proportion; PROC POWER; TWOSAMPLEFREQ TEST=lrchi OR = 2.4545 SIDES = 2 ALPHA = .05 .01 GROUPWEIGHTS = (1 1) REFPROPORTION = .25 Ntotal = 150 to 350 by 10 power= . ; RUN; Edited Results from PROC POWER Actual Nominal N Index Alpha N Total Total Power 6 0.05 175 174 0.794 7 0.05 180 180 0.807 <- matches results above 8 0.05 185 184 0.816 18 0.05 235 234 0.897 19 0.05 240 240 0.904 64 0.01 260 260 0.795 65 0.01 265 264 0.802 66 0.01 270 270 0.813 79 0.01 335 334 0.899 80 0.01 340 340 0.905 81 0.01 345 344 0.909 Example 2: Enter the treatment and reference group proportions; PROC POWER; TWOSAMPLEFREQ TEST = lrchi SIDES = 2 ALPHA = .05 GROUPPROPORTIONS = (.45 .25) NTotal = . POWER = .80 ; RUN; Likelihood Ratio Chi-square Test for Two Proportions Fixed Scenario Elements Distribution Asymptotic normal Method Normal approximation Number of Sides 2 Alpha 0.05 Group 1 Proportion 0.45 Group 2 Proportion 0.25 Nominal Power 0.8 Group 1 Weight 1 Group 2 Weight 1 Computed N Total Actual N Power Total 0.803 178 <--- matches results from above