<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: proc power for multiple groups in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273884#M14424</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/20182"&gt;@momi﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Contrary to my initial perception, the features of the LOGISTIC statement of PROC POWER do not seem to exactly match your requirements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I think you can obtain the desired sample size using options 1 and 2 of my earlier post. Please find SAS code below for both options:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, I determine the required sample size per group for a likelihood-ratio chi-square test to compare k=5 independent proportions with given reference proportion (0.4), odds ratios (3, 2.5, 1.8, 1.5), alpha (0.05) and power (0.90), using the formula mentioned in my earlier post. Then I perform a simulation (with 100,000 iterations) to determine the actual power of the test, given that sample size (run time: about 30 s on my workstation).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the example, the result is n=87 per group and the estimated actual power is 0.9096 with an exact 95% CI of (0.9078, 0.9113). You can easily compute the power for other values of n by setting, say,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;%let n=85;&lt;/FONT&gt; and then re-running the simulation (i.e. fine-tune the sample size). As it turns out in this example, even with only n=85 per group the lower 95% confidence limit of the power estimate is 0.9000.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let k=5;         /* number of groups */
%let alpha=0.05;
%let power=0.90;
%let p0=0.4;      /* reference proportion (in group 0) */
%let oddsr=3 2.5 1.8 1.5; /* list of odds ratios (group 1 vs. group 0, group 2 vs. group 0, ...) */
%let nsim=100000; /* number of iterations in simulation */

%let q=%sysfunc(quantile(chisq,%sysevalf(1-&amp;amp;alpha),&amp;amp;k-1));
%Bisect(cdf('chisq',&amp;amp;q,&amp;amp;k-1,x)=%sysevalf(1-&amp;amp;power),0,1E5,1E-12); /* macro source code from 
                                                   http://analytics.ncsu.edu/sesug/2007/PO21.pdf */

/* Sample size estimation based on formula from
   Chow, S.C., Shao, J., and Wang, H. (2008): Sample Size Calculations in Clinical Research, 2nd ed.,
   Chapman &amp;amp; Hall/CRC Press/Taylor &amp;amp; Francis Group, New York, p. 149 */

data _null_;
array r[0:%eval(&amp;amp;k-1)] _temporary_ (1 &amp;amp;oddsr);
array p[0:1,0:%eval(&amp;amp;k-1)] _temporary_;
do j=0 to &amp;amp;k-1;
  p[1,j]=1/(1+(1/&amp;amp;p0-1)/r[j]);
  P[0,j]=1-p[1,j];
end;
do j=0 to &amp;amp;k-1;
  p0_+p[0,j];
  p1_+p[1,j];
end;
do j=0 to &amp;amp;k-1;
  s+(p[0,j]-p0_/&amp;amp;k)**2/p0_+(p[1,j]-p1_/&amp;amp;k)**2/p1_;
end;
n=ceil(&amp;amp;root/s/&amp;amp;k);
call symputx('n',n);
put 'n = ' n 'per group';
run;


/* Simulation to determine the actual power, given the sample size determined above */

data sim;
call streaminit(314159);
array r[0:%eval(&amp;amp;k-1)] _temporary_ (1 &amp;amp;oddsr);
array p[0:%eval(&amp;amp;k-1)] _temporary_;
do j=0 to &amp;amp;k-1;
  p[j]=1/(1+(1/&amp;amp;p0-1)/r[j]);
end;

do m=1 to &amp;amp;nsim;
  do g=0 to &amp;amp;k-1;
    y=1; f=rand('binom', p[g], &amp;amp;n); output;
    y=0; f=&amp;amp;n-f; output;
  end;
end;
run;

ods listing close;
ods output ChiSq=stats(keep=statistic prob where=(statistic=:'L'));
proc freq data=sim;
by m;
weight f;
tables y*g / chisq;
run;
ods listing;

data lrchi;
set stats(keep=prob);
sig=(prob&amp;lt;&amp;amp;alpha);
run;

ods exclude BinomialTest;
proc freq data=lrchi;
tables sig / binomial(level='1');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 May 2016 10:35:24 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-05-30T10:35:24Z</dc:date>
    <item>
      <title>proc power for multiple groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273595#M14401</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a question about PROC POWER.&amp;nbsp; For two groups, I can use the code below.&amp;nbsp; However, for more than two groups (ex.&lt;/P&gt;
&lt;P&gt;five groups), I am not sure what the option I need to add to it. Does anyone know?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV class="" style="font-family: arial,'Arial Unicode MS',geneva,'Lucida Grande',sans-serif; color: #000000; font-size: 13.44px;"&gt;
&lt;DIV class=""&gt;
&lt;PRE style="font-size: 10.92px; margin-top: 0px; margin-bottom: 0px; padding: 1.4em 0px 0px 12px; border: 0px; line-height: 1.25em; color: #333333;"&gt;   proc power;
      twosamplefreq test=lrchi
         oddsratio = 2
         refproportion = 0.4
         npergroup = .
         power = 0.9;
   run;
&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 27 May 2016 16:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273595#M14401</guid>
      <dc:creator>momi</dc:creator>
      <dc:date>2016-05-27T16:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc power for multiple groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273629#M14403</link>
      <description>&lt;P&gt;Generally the options support multiple values and then proc power will calculated for combinations of the parameters provided.&lt;/P&gt;
&lt;P&gt;See:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc power;
      twosamplefreq test=lrchi
         oddsratio = 2 2.5
         refproportion = 0.4 0.5
         npergroup = .
         power = 0.9 0.95;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;provides 8 N per group results, 2 (oddsratio parameter values)*2(refproportion values)*2(power parameters).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can provide different numbers of parameters for each&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 15:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273629#M14403</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-27T15:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: proc power for multiple groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273715#M14405</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/20182"&gt;@momi﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to me that there is no such option available in PROC POWER (as of SAS/STAT version 14.1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I see two possibilities to calculate the sample size for more than two groups in SAS:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You do a simulation: see &lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_intropss_sect019.htm" target="_blank"&gt;Empirical Power Simulation&lt;/A&gt; for one example (there are probably more&amp;nbsp;elsewhere, maybe in &lt;A href="http://blogs.sas.com/content/iml/" target="_blank"&gt;Rick Wicklin's blog&lt;/A&gt;&amp;nbsp;or in his book on simulation).&lt;/LI&gt;
&lt;LI&gt;You implement a sample size formula found in the literature.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;With option 1 you have maximum flexibility, but option 2 requires less programming effort. The sample size formula I found in &lt;A href="https://www.crcpress.com/Sample-Size-Calculations-in-Clinical-Research-Second-Edition/Chow-Wang-Shao/p/book/9781584889823" target="_blank"&gt;Sample Size Calculations in Clinical Research, Second Edition&lt;/A&gt;,&amp;nbsp;p. 149, looks promising: I applied it to your two-group example (using macro Bisect found in &lt;A href="http://analytics.ncsu.edu/sesug/2007/PO21.pdf" target="_blank"&gt;this paper&lt;/A&gt;&amp;nbsp;to solve&amp;nbsp;for the non-centrality parameter involved) and obtained a result of 178.6..., i.e. n=179, while PROC POWER gave n=178.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Obviously, with five groups you have more degrees of freedom, so you would have to specify more input parameters (e.g. odds ratios) than in the two-group case.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 20:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273715#M14405</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-27T20:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: proc power for multiple groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273726#M14406</link>
      <description>&lt;P&gt;It may be that the LOGISTIC section of Proc Power may work to some extant but that's guess without more details.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 21:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273726#M14406</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-27T21:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc power for multiple groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273735#M14407</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/20182"&gt;@momi﻿&lt;/a&gt;: Brilliant idea from ballardw (as usual)! Yes, I think you should definitely look into the &lt;A href="http://support.sas.com/documentation/cdl/en/syntaxidx/68719/HTML/default/index.htm#/documentation/cdl//en/statug/68162/HTML/default/statug_power_syntax08.htm#statug.power.a0000000066" target="_blank"&gt;LOGISTIC statement&lt;/A&gt; of PROC POWER. This might be&amp;nbsp;the easiest way to obtain that sample size.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 22:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273735#M14407</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-27T22:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: proc power for multiple groups</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273884#M14424</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/20182"&gt;@momi﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Contrary to my initial perception, the features of the LOGISTIC statement of PROC POWER do not seem to exactly match your requirements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I think you can obtain the desired sample size using options 1 and 2 of my earlier post. Please find SAS code below for both options:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, I determine the required sample size per group for a likelihood-ratio chi-square test to compare k=5 independent proportions with given reference proportion (0.4), odds ratios (3, 2.5, 1.8, 1.5), alpha (0.05) and power (0.90), using the formula mentioned in my earlier post. Then I perform a simulation (with 100,000 iterations) to determine the actual power of the test, given that sample size (run time: about 30 s on my workstation).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the example, the result is n=87 per group and the estimated actual power is 0.9096 with an exact 95% CI of (0.9078, 0.9113). You can easily compute the power for other values of n by setting, say,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;%let n=85;&lt;/FONT&gt; and then re-running the simulation (i.e. fine-tune the sample size). As it turns out in this example, even with only n=85 per group the lower 95% confidence limit of the power estimate is 0.9000.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let k=5;         /* number of groups */
%let alpha=0.05;
%let power=0.90;
%let p0=0.4;      /* reference proportion (in group 0) */
%let oddsr=3 2.5 1.8 1.5; /* list of odds ratios (group 1 vs. group 0, group 2 vs. group 0, ...) */
%let nsim=100000; /* number of iterations in simulation */

%let q=%sysfunc(quantile(chisq,%sysevalf(1-&amp;amp;alpha),&amp;amp;k-1));
%Bisect(cdf('chisq',&amp;amp;q,&amp;amp;k-1,x)=%sysevalf(1-&amp;amp;power),0,1E5,1E-12); /* macro source code from 
                                                   http://analytics.ncsu.edu/sesug/2007/PO21.pdf */

/* Sample size estimation based on formula from
   Chow, S.C., Shao, J., and Wang, H. (2008): Sample Size Calculations in Clinical Research, 2nd ed.,
   Chapman &amp;amp; Hall/CRC Press/Taylor &amp;amp; Francis Group, New York, p. 149 */

data _null_;
array r[0:%eval(&amp;amp;k-1)] _temporary_ (1 &amp;amp;oddsr);
array p[0:1,0:%eval(&amp;amp;k-1)] _temporary_;
do j=0 to &amp;amp;k-1;
  p[1,j]=1/(1+(1/&amp;amp;p0-1)/r[j]);
  P[0,j]=1-p[1,j];
end;
do j=0 to &amp;amp;k-1;
  p0_+p[0,j];
  p1_+p[1,j];
end;
do j=0 to &amp;amp;k-1;
  s+(p[0,j]-p0_/&amp;amp;k)**2/p0_+(p[1,j]-p1_/&amp;amp;k)**2/p1_;
end;
n=ceil(&amp;amp;root/s/&amp;amp;k);
call symputx('n',n);
put 'n = ' n 'per group';
run;


/* Simulation to determine the actual power, given the sample size determined above */

data sim;
call streaminit(314159);
array r[0:%eval(&amp;amp;k-1)] _temporary_ (1 &amp;amp;oddsr);
array p[0:%eval(&amp;amp;k-1)] _temporary_;
do j=0 to &amp;amp;k-1;
  p[j]=1/(1+(1/&amp;amp;p0-1)/r[j]);
end;

do m=1 to &amp;amp;nsim;
  do g=0 to &amp;amp;k-1;
    y=1; f=rand('binom', p[g], &amp;amp;n); output;
    y=0; f=&amp;amp;n-f; output;
  end;
end;
run;

ods listing close;
ods output ChiSq=stats(keep=statistic prob where=(statistic=:'L'));
proc freq data=sim;
by m;
weight f;
tables y*g / chisq;
run;
ods listing;

data lrchi;
set stats(keep=prob);
sig=(prob&amp;lt;&amp;amp;alpha);
run;

ods exclude BinomialTest;
proc freq data=lrchi;
tables sig / binomial(level='1');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2016 10:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/proc-power-for-multiple-groups/m-p/273884#M14424</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-30T10:35:24Z</dc:date>
    </item>
  </channel>
</rss>

