<?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: Sample size for (average) bioequivalence in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966504#M48569</link>
    <description>&lt;P&gt;As promised, here is the SAS code I developed during my investigation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Simulation of 500,000 clinical trials with 2x2 crossover design to establish average bioequivalence between 
   two treatments using log-transformed data (cf. the example on p. 262 f. of
     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
   and the derivation of the sample size estimate in this book) */

%let n=18;      /* sample size per group */
%let mu=1;      /* overall mean in the statistical model (10.2.1) used in the book, arbitrarily selected */
%let d=0.05;    /* fixed treatment effect ("delta" in the book) */

%let rho=0.5;   /* Between-subject std. deviations (sBT, sBR) and within-subject std. dev. (sWT, sWR),            */
%let sBT=0.35;  /* denoted "sigma_BT" etc. in the book, as well as the correlation rho of each subject's random   */
%let sBR=0.25;  /* effect between test (T) and reference (R) treatment have been arbitrarily selected, but        */
%let sWT=0.2;   /* aiming at the value 0.4 for the derived standard deviation parameter s11 (see below) used in   */
%let sWR=0.15;  /* the book example.                                                                              */

%let P1=0.07;   /* fixed effect of the first treatment period */
%let Q1=0.03;   /* fixed effect of the first sequence of treatments (T, R) */

/* Alternative set of parameters:

%let n=18;
%let mu=1;
%let d=0.05;
%let rho=0.15;
%let sBT=0.10;
%let sBR=0.05;
%let sWT=0.37;
%let sWR=0.11;
%let P1=0.12;
%let Q1=0.13;

*/

%let s11=%sysfunc(sqrt(&amp;amp;sBT**2+&amp;amp;sBR**2-2*&amp;amp;rho*&amp;amp;sBT*&amp;amp;sBR+&amp;amp;sWT**2+&amp;amp;sWR**2)); /* in the book: "sigma_1,1", described */
%put &amp;amp;=s11; /* =0.4 */                                    /* as "standard deviation for intra-subject comparison" */

data sim(drop=FT--sWR);
call streaminit('MT64',27182818);
retain sim k i j l S e y;
array F[*] FT FR (%sysevalf(&amp;amp;d/2) -%sysevalf(&amp;amp;d/2));
array P[2] (&amp;amp;P1 -&amp;amp;P1);
array Q[2] (&amp;amp;Q1 -&amp;amp;Q1);
array S_[*] ST SR;
array sW[*] sWT sWR (&amp;amp;sWT &amp;amp;sWR);
do sim=1 to 500000; /* Reduce this number for shorter run times. */
  do k=1 to 2; /* treatment sequence k=1: T, R; sequence k=2: R, T */
    do i=1 to &amp;amp;n;
      ST=rand('normal',0,&amp;amp;sBT); /* i-th subject's random effect; its bivariate normal distribution is simulated ... */
      SR=rand('normal',%sysevalf(&amp;amp;rho*&amp;amp;sBR/&amp;amp;sBT)*ST,%sysevalf(&amp;amp;sBR*%sysfunc(sqrt(%sysevalf(1-&amp;amp;rho**2)))));
             /* ... using the conditional distribution of SR given ST; alternatively, PROC SIMNORMAL could be used. */
      do j=1 to 2; /* first and second treatment period */
        l=2-(j=k); /* Values l=1, 2 correspond to treatments T and R, respectively. */
        S=S_[l];
        e=rand('normal',0,sW[l]); /* random errors */
        y=&amp;amp;mu+F[l]+P[j]+Q[k]+S+e; /* see equation (10.2.1) in the book */
        output;
      end;
    end;
  end;
end;
run;

/* Compute mean values of the (log-transformed) measurements per period-sequence combination */

proc summary data=sim nway;
by sim k;
class j;
var y;
output out=stats(drop=_:) mean=;
run;

/* Estimate the treatment effect ("delta hat" in the book) */

data delta(keep=sim d_hat);
set stats;
by sim;
if first.sim then d_hat=0;
d_hat+((-1)**(j~=k)*y);
if last.sim;
d_hat=d_hat/2;
run; 

/* Optional: Check the (normal) distribution of "delta hat" (formula (10.2.3) in the book)

proc univariate data=delta;
var d_hat;
histogram / normal;
run;
*/

/* Prepare estimation of "sigma_1,1 hat" squared */

proc transpose data=stats out=stats2(drop=_:) prefix=y;
by sim k;
id j;
var y;
run;

/* Estimate "sigma_1,1 hat" squared using formula (10.2.5) of the book */

data s112(keep=sim s112);
merge sim(keep=sim k i j y) stats2;
by sim k;
if first.sim then s112=0;
lag_y=lag(y);
if j=2 then s112+(lag_y-y-y1+y2)**2;
if last.sim;
s112=s112/(2*&amp;amp;n-2);
run;

/* Optional: "sigma_1,1 hat" squared and "delta hat" are independent; check uncorrelatedness and distribution
             of "sigma_1,1 hat" (cf. p. 261 of the book)

data chk;
merge delta s112;
by sim;
run;

proc corr data=chk;
var d_hat s112;
run;

data s112n;
set s112;
s112n=s112*(2*&amp;amp;n-2)/&amp;amp;s11**2; * This quantity should have a chi-square distribution with 2*n-2 degrees of freedom.;
run;

proc univariate data=s112n;
var s112n;
histogram / gamma(alpha=%eval(&amp;amp;n-1) sigma=2); * chi-square(df) distribution equals gamma(df/2, 2) distribution;
run;
*/

/* Compute 90% confidence interval for delta and perform the equivalence test ("two one-sided tests procedure")
   using delta_U=log(1.25)=0.223... and delta_L=log(0.8)=-delta_U (bioequivalence limits as per 2001 FDA guidance
   "Statistical Approaches to Establishing Bioequivalence" [https://www.fda.gov/media/70958/download]) */

data confd;
merge delta s112;
by sim;
hw=quantile('T',0.95,2*&amp;amp;n-2)*sqrt(s112)/2*sqrt(2/&amp;amp;n); /* half-with of the CI according to book p. 261 */
c=(abs(&amp;amp;d-d_hat)&amp;lt;=hw); /* =1 in case of coverage of the true parameter, 0 otherwise */
rej=(d_hat-hw&amp;gt;log(0.8) &amp;amp; d_hat+hw&amp;lt;log(1.25)); /* =1 if null hypotheses H_01 and H_02 are rejected */
run;                                          /* at the 5% significance level                     */

/* Check coverage of the 90% CI for delta and estimate the power of the equivalence test */

proc freq data=confd;
tables c rej / binomial(level='1');
run; /* proportion c=1: 0.8994 (95%-CI: [0.8985, 0.9002])
        prop.    rej=1: 0.8074 (95%-CI: [0.8063, 0.8085]) */

/* with &amp;amp;n=17: */
     /* proportion c=1: 0.8995 (95%-CI: [0.8987, 0.9003])
        prop.    rej=1: 0.7837 (95%-CI: [0.7825, 0.7848]) */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above estimates of the test's power indicate that &lt;EM&gt;n&lt;/EM&gt; = 18 is the minimum sample size required for 80% power, given the assumed values of parameters &lt;FONT face="symbol"&gt;d&lt;/FONT&gt; and &lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt;. Very similar results are obtained with the "alternative set of parameters" (see that comment in the code).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Suggested better approximation of the power than the book's 2Phi(...)-1 formula (p. 261) */

data _null_;
do n=17, 18;
  pow= cdf('normal', log(1.25)-quantile('T',0.95,2*n-2)*sqrt(&amp;amp;s11**2/(2*n)),&amp;amp;d,sqrt(&amp;amp;s11**2/(2*n)))
      -cdf('normal',-log(1.25)+quantile('T',0.95,2*n-2)*sqrt(&amp;amp;s11**2/(2*n)),&amp;amp;d,sqrt(&amp;amp;s11**2/(2*n)));
  put n= "--&amp;gt; approx. power=" pow 6.4;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above approximation yields 0.8095 for &lt;EM&gt;n&lt;/EM&gt; = 18 and 0.7857 for&amp;nbsp;&lt;EM&gt;n&lt;/EM&gt; = 17, suggesting the same minimum sample size as the simulation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned in my previous post, the equivalence test can also be implemented with PROC TTEST rather than &lt;BR /&gt;in several steps as above:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Restructure simulated data for application of PROC TTEST */

proc transpose data=sim out=simt(drop=_:) prefix=y;
by sim k i;
id j;
var y;
run;

data simtt;
set simt;
trt1=k;
trt2=3-k;
run;

/* Perform the equivalence test with PROC TTEST */

options nonotes;
ods select none;
ods noresults;

ods output EquivLimits=eqlim(where=(period=' ' &amp;amp; method='Pooled'));
proc ttest data=simtt tost(%sysfunc(log(0.8)), %sysfunc(log(1.25)));
by sim;
var y1 y2 / crossover=(trt1 trt2);
run;

options notes;
ods select all;
ods results;

proc freq data=eqlim;
tables assessment / binomial;
run;

/* Compare previous results to those from PROC TTEST */

data cmptt;
merge confd(keep=sim rej)
      eqlim(keep=sim assessment);
by sim;
run;

proc freq data=cmptt;
tables rej*assessment;
run; /* Results are identical: rej=1 &amp;lt;==&amp;gt; Assessment="Equivalent" */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My suggestion for an exact calculation of the power is to compute the integral of the joint probability density of "&lt;FONT face="symbol"&gt;d&lt;/FONT&gt; hat" and "&lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt;&amp;nbsp;hat" over the rejection region, i.e., the set of ("&lt;FONT face="symbol"&gt;d&lt;/FONT&gt; hat" and "&lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt;&amp;nbsp;hat") pairs satisfying the inequality |"&lt;FONT face="symbol"&gt;d&lt;/FONT&gt; hat"| &amp;lt; &lt;FONT face="symbol"&gt;d&lt;/FONT&gt;&lt;EM&gt;&lt;SUB&gt;U&lt;/SUB&gt;&lt;/EM&gt;&amp;nbsp;&lt;SPAN&gt;−&amp;nbsp;&lt;/SPAN&gt;t&lt;SUB&gt;&lt;FONT face="symbol"&gt;a&lt;/FONT&gt;,2&lt;EM&gt;n&lt;/EM&gt;&lt;SPAN&gt;−&lt;/SPAN&gt;2&lt;/SUB&gt; "&lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt; hat"/&lt;SPAN&gt;√(2&lt;/SPAN&gt;&lt;EM&gt;n&lt;/EM&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; where the two null hypotheses &lt;EM&gt;H&lt;/EM&gt;&lt;SUB&gt;01&lt;/SUB&gt; and &lt;EM&gt;H&lt;/EM&gt;&lt;SUB&gt;02&lt;/SUB&gt; are rejected. As those two random variables are independent (see book, p. 261), their joint pdf is just the product &lt;EM&gt;fg&lt;/EM&gt; of the pdfs of a normal distribution (&lt;EM&gt;f&amp;nbsp;&lt;/EM&gt;) and a scaled chi distribution (&lt;EM&gt;g&amp;nbsp;&lt;/EM&gt;). I found the pdf of a chi distribution in section 8.3 of Evans, M., Hastings, N. and Peacock, B. (2000), Statistical Distributions, 3rd ed., John Wiley &amp;amp; Sons, New York.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let n=18;
%let d=0.05;
%let s11=0.4;
%let s112=%sysevalf(&amp;amp;s11**2);
%let alpha=0.05;

/* Select a subset of points where the joint pdf does not almost vanish */

data intset;
do i=-5000 to 6000;
  x=i/10000;
  do j=1000 to 8000;
    y=j/10000;
    fg= sqrt(&amp;amp;n/constant('PI'))/&amp;amp;s11*exp(-&amp;amp;n/&amp;amp;s112*(x-&amp;amp;d)**2)
       *2*((&amp;amp;n-1)/&amp;amp;s112)**(&amp;amp;n-1)/fact(&amp;amp;n-2)*y**(2*&amp;amp;n-3)*exp(-(&amp;amp;n-1)/&amp;amp;s112*y**2);
    if fg&amp;gt;1e-10 then output;
  end;
end;
run; /* 52891353 obs. */

proc means data=intset min max;
var i j;
run; /* Min and max are well inside the ranges, so it's safe to limit the integration to this set. */

/* Compute the integral numerically */

proc means data=intset sum;
where abs(x)&amp;lt;log(1.25)-quantile('T',1-&amp;amp;alpha,2*&amp;amp;n-2)*y/sqrt(2*&amp;amp;n);
var fg;
run; /* --&amp;gt; Power = 80703401.67/1e8 = 0.80703... . */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This value matches the result of the simulation, 0.8074 (95%-CI: [0.8063, 0.8085]), quite well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will continue in a subsequent post to avoid that this one is getting too long.&lt;/P&gt;</description>
    <pubDate>Wed, 14 May 2025 16:59:44 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2025-05-14T16:59:44Z</dc:date>
    <item>
      <title>Sample size for (average) bioequivalence</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966054#M48503</link>
      <description>&lt;P&gt;Hi SAS Community!&lt;/P&gt;&lt;P&gt;The aim id to calculate the sample size for average bioequivalence trial.&lt;/P&gt;&lt;P&gt;I would like to replicate the below example from "Sample Size Calculations in Clinical Research" by Chow and Shao (3rd edition).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below you can see the formula that is used as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="A_Tomczyk_0-1746688670698.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/106800iDB5A2D5CA4850892/image-size/medium?v=v2&amp;amp;px=400" role="button" title="A_Tomczyk_0-1746688670698.png" alt="A_Tomczyk_0-1746688670698.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="A_Tomczyk_1-1746688703017.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/106801iF4F8C685BED60C24/image-size/medium?v=v2&amp;amp;px=400" role="button" title="A_Tomczyk_1-1746688703017.png" alt="A_Tomczyk_1-1746688703017.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, with the SD=0.4, delta = 0.05, limit = 0.223, alpha = 0.05 and 80% power I am using the below code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc power; &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;twosamplemeans test=equiv_diff &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;DIST=NORMAL&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;lower = -0.223&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;upper = 0.223&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;meandiff = 0.05&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;stddev = 0.4&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;npergroup = .&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;power = 0.8; &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am getting 69 subjects required, not 21 (as in the book, or 24 from the table approximation)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="A_Tomczyk_0-1746692672119.png" style="width: 231px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/106802iD05FD64FACAA7A60/image-dimensions/231x257?v=v2" width="231" height="257" role="button" title="A_Tomczyk_0-1746692672119.png" alt="A_Tomczyk_0-1746692672119.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a different formula SAS is using? Or should I use a different procedure?&lt;/P&gt;&lt;P&gt;Sorry if I am missing something, just trying to get my head around that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you Guys,&lt;/P&gt;&lt;P&gt;Agnieszka&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 May 2025 08:28:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966054#M48503</guid>
      <dc:creator>A_Tomczyk</dc:creator>
      <dc:date>2025-05-08T08:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sample size for (average) bioequivalence</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966116#M48518</link>
      <description>&lt;P&gt;But from the formula of sas doc, it was different with yours . Maybe the bioequivalence you are talking about is different with sas equivalence test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1746766711904.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/106822i797A2672353BD9DD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1746766711904.png" alt="Ksharp_0-1746766711904.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 May 2025 04:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966116#M48518</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-05-09T04:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Sample size for (average) bioequivalence</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966444#M48559</link>
      <description>&lt;P&gt;Hi, Agnieszka (&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/475207"&gt;@A_Tomczyk&lt;/a&gt;), and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for posting this interesting question. I have investigated the issue using the &lt;EM&gt;second&lt;/EM&gt; edition (2008) of your book (in which I found basically the same texts and formulas as shown in your photographs of the third edition, so I assume the preceding paragraphs of that section "10.2 Average Bioequivalence" are very similar as well).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Everything seemed relatively straightforward to me (note the typo −&lt;FONT face="symbol"&gt;d&lt;/FONT&gt;&lt;EM&gt;&lt;SUB&gt;L&lt;/SUB&gt;&lt;/EM&gt;, which should read&amp;nbsp;&lt;FONT face="symbol"&gt;d&lt;/FONT&gt;&lt;EM&gt;&lt;SUB&gt;L&lt;/SUB&gt;&lt;/EM&gt;), until I stumbled across the sentence "Under the alternative hypothesis that |&lt;FONT face="symbol"&gt;e&lt;/FONT&gt;| &amp;lt;&lt;FONT face="symbol"&gt; d&lt;/FONT&gt;, ..." ending with an approximative power formula of the form 2&lt;FONT face="symbol"&gt;F&lt;/FONT&gt;(...)−1. As it turned out, the authors &lt;EM&gt;switched the notation&lt;/EM&gt;&amp;nbsp;there: It would have been more consistent to write that alternative hypothesis like |&lt;FONT face="symbol"&gt;d&lt;/FONT&gt;| &amp;lt;&lt;FONT face="symbol"&gt; d&lt;/FONT&gt;&lt;EM&gt;&lt;SUB&gt;U&lt;/SUB&gt;&lt;/EM&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, the approximation&amp;nbsp;2&lt;FONT face="symbol"&gt;F&lt;/FONT&gt;(...)−1 seems unnecessarily coarse to me: I say "unnecessarily" because their equations "do not have an explicit solution" (quote from p. 261) anyway, so they could also have suggested a better approximation such as&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;EM&gt; F&lt;/EM&gt;(&lt;FONT face="symbol"&gt;d&lt;/FONT&gt;&lt;EM&gt;&lt;SUB&gt;U&lt;/SUB&gt;&lt;/EM&gt;&amp;nbsp;−&lt;EM&gt;t&lt;/EM&gt;&lt;SUB&gt;&lt;FONT face="symbol"&gt;a&lt;/FONT&gt;,2n-2&amp;nbsp;&lt;/SUB&gt;&lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt;/√(2&lt;EM&gt;n&lt;/EM&gt;))&amp;nbsp;−&lt;EM&gt;&amp;nbsp;F&lt;/EM&gt;(−&lt;FONT face="symbol"&gt;d&lt;/FONT&gt;&lt;EM&gt;&lt;SUB&gt;U&lt;/SUB&gt;&lt;/EM&gt;&amp;nbsp;+&lt;EM&gt;t&lt;/EM&gt;&lt;SUB&gt;&lt;FONT face="symbol"&gt;a&lt;/FONT&gt;,2n-2&amp;nbsp;&lt;/SUB&gt;&lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt;/√(2&lt;EM&gt;n&lt;/EM&gt;))&lt;/P&gt;
&lt;P&gt;with the cumulative distribution function &lt;EM&gt;F&lt;/EM&gt; of "&lt;FONT face="symbol"&gt;d&lt;/FONT&gt; hat", i.e., the cdf of a normal distribution (see formula 10.2.3 in the book if the numbering is the same in your edition). I use this in my code (which I will post separately). It is still an approximation because&amp;nbsp;&lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt; is used instead of its estimate "&lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt; hat", but unlike theirs it does not require&amp;nbsp;|&lt;FONT face="symbol"&gt;d&lt;/FONT&gt;| (i.e., their |&lt;FONT face="symbol"&gt;e&lt;/FONT&gt;|) to be very small. Using their approximation I sometimes got nonsensical &lt;EM&gt;negative&lt;/EM&gt; values for the estimated power.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For an &lt;EM&gt;exact&lt;/EM&gt; computation you can evaluate an integral of the joint probability density of&amp;nbsp;"&lt;FONT face="symbol"&gt;d&lt;/FONT&gt; hat" and&amp;nbsp;"&lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt; hat", which is not very difficult to do in a DATA step (also shown in my code) thanks to the independence of these two random variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the next step of their derivation, the authors of the book use the upper &lt;FONT face="symbol"&gt;b&lt;/FONT&gt;/2 quantile of the &lt;EM&gt;t&lt;/EM&gt; distribution with 2&lt;EM&gt;n&lt;/EM&gt;-2 degrees of freedom, although the corresponding &lt;EM&gt;normal&lt;/EM&gt; quantile &lt;EM&gt;z&lt;/EM&gt;&lt;SUB&gt;&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;/2&lt;/SUB&gt; would better fit the previous "2&lt;FONT face="symbol"&gt;F&lt;/FONT&gt;(...)−1" expression. But, as we know, those two quantiles don't differ much if &lt;EM&gt;n&lt;/EM&gt; is sufficiently large. (And they &lt;EM&gt;do&lt;/EM&gt; use&amp;nbsp;&lt;EM&gt;z&lt;/EM&gt;&lt;SUB&gt;&lt;FONT face="symbol"&gt;b&lt;/FONT&gt;/2&lt;/SUB&gt; in their "further simplified" sample size formula.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Surprisingly, they made &lt;EM&gt;two mistakes in their example calculation&lt;/EM&gt; (which you show in one of your photographs)&lt;FONT face="arial,helvetica,sans-serif"&gt;:&lt;/FONT&gt;&amp;nbsp;&lt;EM&gt;z&lt;/EM&gt;&lt;SUB&gt;0.05&lt;/SUB&gt;=1.64..., not 1.96, and&amp;nbsp;&lt;EM&gt;z&lt;/EM&gt;&lt;SUB&gt;0.10&lt;/SUB&gt;=1.28..., not 0.84. Using the correct quantiles, the result for the (approximate) estimated minimum sample size is &lt;STRONG&gt;23&lt;/STRONG&gt;, not 21. Interestingly, using the "better approximation" I've suggested further above, I obtain &lt;EM&gt;n&amp;nbsp;&lt;/EM&gt;=&amp;nbsp;&lt;STRONG&gt;18&lt;/STRONG&gt; -- and this is even confirmed by both the exact calculation (using the integral mentioned above) and the simulation of 500,000 cross-over studies (each for &lt;EM&gt;n&amp;nbsp;&lt;/EM&gt;= 17 and &lt;EM&gt;n&lt;/EM&gt; = 18) that I did in my code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The relevant hypothesis test can be implemented with PROC TTEST using the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_ttest_syntax01.htm#statug.ttest.tteproctost" target="_blank" rel="noopener"&gt;TOST option&lt;/A&gt; of the PROC TTEST statement &lt;EM&gt;in conjunction with&lt;/EM&gt; the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_ttest_syntax09.htm#statug.ttest.ttevarcrossover" target="_blank" rel="noopener"&gt;CROSSOVER= option&lt;/A&gt; of the VAR statement (also shown in my code).&amp;nbsp;However, it seems to me that the corresponding sample size calculation is beyond the capabilities of PROC POWER (at least in my SAS/STAT 14.3 version), which does support calculations corresponding to using &lt;EM&gt;either&lt;/EM&gt; TOST &lt;EM&gt;or&lt;/EM&gt; CROSSOVER= in PROC TTEST. Your PROC POWER code uses the "TOST only" variant.&amp;nbsp;In my code I show the corresponding PROC TTEST step as well as a simulation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The GLMPOWER procedure doesn't help either (I think) because in the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_glmpower_overview.htm" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt; it says: "&lt;SPAN&gt;Tests and contrasts that involve random effects are not supported." But the model used in Chow/Shao/Wang &lt;EM&gt;does&lt;/EM&gt; involve a random effect.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So, unless someone else has other ideas, you can use&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN&gt; one of the approximations from the Chow et al. book &lt;EM&gt;or&lt;/EM&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt; the "better" approximation mentioned above &lt;EM&gt;or&lt;/EM&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt; the exact integral calculation &lt;EM&gt;or&lt;/EM&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt; a simulation&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;to obtain power and sample size for the model in question with SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am so sorry that I have to leave the office now, but I will post my code tomorrow (CEST time zone).&lt;/P&gt;</description>
      <pubDate>Tue, 13 May 2025 18:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966444#M48559</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-05-13T18:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Sample size for (average) bioequivalence</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966454#M48563</link>
      <description>I think here your bioequivalence  is totally different with Equivalence Testing of proc power.&lt;BR /&gt;Therefore , they have different formula and you can not expect their have the same result.</description>
      <pubDate>Wed, 14 May 2025 01:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966454#M48563</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-05-14T01:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sample size for (average) bioequivalence</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966504#M48569</link>
      <description>&lt;P&gt;As promised, here is the SAS code I developed during my investigation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Simulation of 500,000 clinical trials with 2x2 crossover design to establish average bioequivalence between 
   two treatments using log-transformed data (cf. the example on p. 262 f. of
     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
   and the derivation of the sample size estimate in this book) */

%let n=18;      /* sample size per group */
%let mu=1;      /* overall mean in the statistical model (10.2.1) used in the book, arbitrarily selected */
%let d=0.05;    /* fixed treatment effect ("delta" in the book) */

%let rho=0.5;   /* Between-subject std. deviations (sBT, sBR) and within-subject std. dev. (sWT, sWR),            */
%let sBT=0.35;  /* denoted "sigma_BT" etc. in the book, as well as the correlation rho of each subject's random   */
%let sBR=0.25;  /* effect between test (T) and reference (R) treatment have been arbitrarily selected, but        */
%let sWT=0.2;   /* aiming at the value 0.4 for the derived standard deviation parameter s11 (see below) used in   */
%let sWR=0.15;  /* the book example.                                                                              */

%let P1=0.07;   /* fixed effect of the first treatment period */
%let Q1=0.03;   /* fixed effect of the first sequence of treatments (T, R) */

/* Alternative set of parameters:

%let n=18;
%let mu=1;
%let d=0.05;
%let rho=0.15;
%let sBT=0.10;
%let sBR=0.05;
%let sWT=0.37;
%let sWR=0.11;
%let P1=0.12;
%let Q1=0.13;

*/

%let s11=%sysfunc(sqrt(&amp;amp;sBT**2+&amp;amp;sBR**2-2*&amp;amp;rho*&amp;amp;sBT*&amp;amp;sBR+&amp;amp;sWT**2+&amp;amp;sWR**2)); /* in the book: "sigma_1,1", described */
%put &amp;amp;=s11; /* =0.4 */                                    /* as "standard deviation for intra-subject comparison" */

data sim(drop=FT--sWR);
call streaminit('MT64',27182818);
retain sim k i j l S e y;
array F[*] FT FR (%sysevalf(&amp;amp;d/2) -%sysevalf(&amp;amp;d/2));
array P[2] (&amp;amp;P1 -&amp;amp;P1);
array Q[2] (&amp;amp;Q1 -&amp;amp;Q1);
array S_[*] ST SR;
array sW[*] sWT sWR (&amp;amp;sWT &amp;amp;sWR);
do sim=1 to 500000; /* Reduce this number for shorter run times. */
  do k=1 to 2; /* treatment sequence k=1: T, R; sequence k=2: R, T */
    do i=1 to &amp;amp;n;
      ST=rand('normal',0,&amp;amp;sBT); /* i-th subject's random effect; its bivariate normal distribution is simulated ... */
      SR=rand('normal',%sysevalf(&amp;amp;rho*&amp;amp;sBR/&amp;amp;sBT)*ST,%sysevalf(&amp;amp;sBR*%sysfunc(sqrt(%sysevalf(1-&amp;amp;rho**2)))));
             /* ... using the conditional distribution of SR given ST; alternatively, PROC SIMNORMAL could be used. */
      do j=1 to 2; /* first and second treatment period */
        l=2-(j=k); /* Values l=1, 2 correspond to treatments T and R, respectively. */
        S=S_[l];
        e=rand('normal',0,sW[l]); /* random errors */
        y=&amp;amp;mu+F[l]+P[j]+Q[k]+S+e; /* see equation (10.2.1) in the book */
        output;
      end;
    end;
  end;
end;
run;

/* Compute mean values of the (log-transformed) measurements per period-sequence combination */

proc summary data=sim nway;
by sim k;
class j;
var y;
output out=stats(drop=_:) mean=;
run;

/* Estimate the treatment effect ("delta hat" in the book) */

data delta(keep=sim d_hat);
set stats;
by sim;
if first.sim then d_hat=0;
d_hat+((-1)**(j~=k)*y);
if last.sim;
d_hat=d_hat/2;
run; 

/* Optional: Check the (normal) distribution of "delta hat" (formula (10.2.3) in the book)

proc univariate data=delta;
var d_hat;
histogram / normal;
run;
*/

/* Prepare estimation of "sigma_1,1 hat" squared */

proc transpose data=stats out=stats2(drop=_:) prefix=y;
by sim k;
id j;
var y;
run;

/* Estimate "sigma_1,1 hat" squared using formula (10.2.5) of the book */

data s112(keep=sim s112);
merge sim(keep=sim k i j y) stats2;
by sim k;
if first.sim then s112=0;
lag_y=lag(y);
if j=2 then s112+(lag_y-y-y1+y2)**2;
if last.sim;
s112=s112/(2*&amp;amp;n-2);
run;

/* Optional: "sigma_1,1 hat" squared and "delta hat" are independent; check uncorrelatedness and distribution
             of "sigma_1,1 hat" (cf. p. 261 of the book)

data chk;
merge delta s112;
by sim;
run;

proc corr data=chk;
var d_hat s112;
run;

data s112n;
set s112;
s112n=s112*(2*&amp;amp;n-2)/&amp;amp;s11**2; * This quantity should have a chi-square distribution with 2*n-2 degrees of freedom.;
run;

proc univariate data=s112n;
var s112n;
histogram / gamma(alpha=%eval(&amp;amp;n-1) sigma=2); * chi-square(df) distribution equals gamma(df/2, 2) distribution;
run;
*/

/* Compute 90% confidence interval for delta and perform the equivalence test ("two one-sided tests procedure")
   using delta_U=log(1.25)=0.223... and delta_L=log(0.8)=-delta_U (bioequivalence limits as per 2001 FDA guidance
   "Statistical Approaches to Establishing Bioequivalence" [https://www.fda.gov/media/70958/download]) */

data confd;
merge delta s112;
by sim;
hw=quantile('T',0.95,2*&amp;amp;n-2)*sqrt(s112)/2*sqrt(2/&amp;amp;n); /* half-with of the CI according to book p. 261 */
c=(abs(&amp;amp;d-d_hat)&amp;lt;=hw); /* =1 in case of coverage of the true parameter, 0 otherwise */
rej=(d_hat-hw&amp;gt;log(0.8) &amp;amp; d_hat+hw&amp;lt;log(1.25)); /* =1 if null hypotheses H_01 and H_02 are rejected */
run;                                          /* at the 5% significance level                     */

/* Check coverage of the 90% CI for delta and estimate the power of the equivalence test */

proc freq data=confd;
tables c rej / binomial(level='1');
run; /* proportion c=1: 0.8994 (95%-CI: [0.8985, 0.9002])
        prop.    rej=1: 0.8074 (95%-CI: [0.8063, 0.8085]) */

/* with &amp;amp;n=17: */
     /* proportion c=1: 0.8995 (95%-CI: [0.8987, 0.9003])
        prop.    rej=1: 0.7837 (95%-CI: [0.7825, 0.7848]) */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above estimates of the test's power indicate that &lt;EM&gt;n&lt;/EM&gt; = 18 is the minimum sample size required for 80% power, given the assumed values of parameters &lt;FONT face="symbol"&gt;d&lt;/FONT&gt; and &lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt;. Very similar results are obtained with the "alternative set of parameters" (see that comment in the code).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Suggested better approximation of the power than the book's 2Phi(...)-1 formula (p. 261) */

data _null_;
do n=17, 18;
  pow= cdf('normal', log(1.25)-quantile('T',0.95,2*n-2)*sqrt(&amp;amp;s11**2/(2*n)),&amp;amp;d,sqrt(&amp;amp;s11**2/(2*n)))
      -cdf('normal',-log(1.25)+quantile('T',0.95,2*n-2)*sqrt(&amp;amp;s11**2/(2*n)),&amp;amp;d,sqrt(&amp;amp;s11**2/(2*n)));
  put n= "--&amp;gt; approx. power=" pow 6.4;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above approximation yields 0.8095 for &lt;EM&gt;n&lt;/EM&gt; = 18 and 0.7857 for&amp;nbsp;&lt;EM&gt;n&lt;/EM&gt; = 17, suggesting the same minimum sample size as the simulation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned in my previous post, the equivalence test can also be implemented with PROC TTEST rather than &lt;BR /&gt;in several steps as above:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Restructure simulated data for application of PROC TTEST */

proc transpose data=sim out=simt(drop=_:) prefix=y;
by sim k i;
id j;
var y;
run;

data simtt;
set simt;
trt1=k;
trt2=3-k;
run;

/* Perform the equivalence test with PROC TTEST */

options nonotes;
ods select none;
ods noresults;

ods output EquivLimits=eqlim(where=(period=' ' &amp;amp; method='Pooled'));
proc ttest data=simtt tost(%sysfunc(log(0.8)), %sysfunc(log(1.25)));
by sim;
var y1 y2 / crossover=(trt1 trt2);
run;

options notes;
ods select all;
ods results;

proc freq data=eqlim;
tables assessment / binomial;
run;

/* Compare previous results to those from PROC TTEST */

data cmptt;
merge confd(keep=sim rej)
      eqlim(keep=sim assessment);
by sim;
run;

proc freq data=cmptt;
tables rej*assessment;
run; /* Results are identical: rej=1 &amp;lt;==&amp;gt; Assessment="Equivalent" */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My suggestion for an exact calculation of the power is to compute the integral of the joint probability density of "&lt;FONT face="symbol"&gt;d&lt;/FONT&gt; hat" and "&lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt;&amp;nbsp;hat" over the rejection region, i.e., the set of ("&lt;FONT face="symbol"&gt;d&lt;/FONT&gt; hat" and "&lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt;&amp;nbsp;hat") pairs satisfying the inequality |"&lt;FONT face="symbol"&gt;d&lt;/FONT&gt; hat"| &amp;lt; &lt;FONT face="symbol"&gt;d&lt;/FONT&gt;&lt;EM&gt;&lt;SUB&gt;U&lt;/SUB&gt;&lt;/EM&gt;&amp;nbsp;&lt;SPAN&gt;−&amp;nbsp;&lt;/SPAN&gt;t&lt;SUB&gt;&lt;FONT face="symbol"&gt;a&lt;/FONT&gt;,2&lt;EM&gt;n&lt;/EM&gt;&lt;SPAN&gt;−&lt;/SPAN&gt;2&lt;/SUB&gt; "&lt;FONT face="symbol"&gt;s&lt;/FONT&gt;&lt;SUB&gt;1,1&lt;/SUB&gt; hat"/&lt;SPAN&gt;√(2&lt;/SPAN&gt;&lt;EM&gt;n&lt;/EM&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; where the two null hypotheses &lt;EM&gt;H&lt;/EM&gt;&lt;SUB&gt;01&lt;/SUB&gt; and &lt;EM&gt;H&lt;/EM&gt;&lt;SUB&gt;02&lt;/SUB&gt; are rejected. As those two random variables are independent (see book, p. 261), their joint pdf is just the product &lt;EM&gt;fg&lt;/EM&gt; of the pdfs of a normal distribution (&lt;EM&gt;f&amp;nbsp;&lt;/EM&gt;) and a scaled chi distribution (&lt;EM&gt;g&amp;nbsp;&lt;/EM&gt;). I found the pdf of a chi distribution in section 8.3 of Evans, M., Hastings, N. and Peacock, B. (2000), Statistical Distributions, 3rd ed., John Wiley &amp;amp; Sons, New York.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let n=18;
%let d=0.05;
%let s11=0.4;
%let s112=%sysevalf(&amp;amp;s11**2);
%let alpha=0.05;

/* Select a subset of points where the joint pdf does not almost vanish */

data intset;
do i=-5000 to 6000;
  x=i/10000;
  do j=1000 to 8000;
    y=j/10000;
    fg= sqrt(&amp;amp;n/constant('PI'))/&amp;amp;s11*exp(-&amp;amp;n/&amp;amp;s112*(x-&amp;amp;d)**2)
       *2*((&amp;amp;n-1)/&amp;amp;s112)**(&amp;amp;n-1)/fact(&amp;amp;n-2)*y**(2*&amp;amp;n-3)*exp(-(&amp;amp;n-1)/&amp;amp;s112*y**2);
    if fg&amp;gt;1e-10 then output;
  end;
end;
run; /* 52891353 obs. */

proc means data=intset min max;
var i j;
run; /* Min and max are well inside the ranges, so it's safe to limit the integration to this set. */

/* Compute the integral numerically */

proc means data=intset sum;
where abs(x)&amp;lt;log(1.25)-quantile('T',1-&amp;amp;alpha,2*&amp;amp;n-2)*y/sqrt(2*&amp;amp;n);
var fg;
run; /* --&amp;gt; Power = 80703401.67/1e8 = 0.80703... . */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This value matches the result of the simulation, 0.8074 (95%-CI: [0.8063, 0.8085]), quite well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will continue in a subsequent post to avoid that this one is getting too long.&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2025 16:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966504#M48569</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-05-14T16:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Sample size for (average) bioequivalence</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966505#M48570</link>
      <description>&lt;P&gt;[continuation of the previous post]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now let's turn to your PROC POWER step where you obtained a sample size of 69 subjects per group. The corresponding power estimate is even more suitable for comparisons:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output output=ppow;

proc power;
twosamplemeans test=equiv_diff
dist=normal
lower = -0.223
upper = 0.223
meandiff = 0.05
stddev = 0.4
npergroup = 69
power = .;
run;

proc print data=ppow;
format power best16.;
run; /*  0.80179614325271 */

/* The same result (up to 14 decimals!) can be obtained by using a formula from section 3.2.3 of the book (p. 62): */

data _null_;
a=0.05;   /* significance level alpha */
dU=0.223; /* bioequivalence limit (log(1.25)) */
d=0.05;   /* mean difference delta */
s=0.4;    /* common standard deviation in both groups */
n=69;     /* sample size per group */
power=1-cdf('T',quantile('T',1-a,2*n-2),2*n-2,(dU-d)/(s*sqrt(2/n)))
       -cdf('T',quantile('T',1-a,2*n-2),2*n-2,(dU+d)/(s*sqrt(2/n)));
put power= best16.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The power computed above is that of an equivalence test based on a much simpler model than model (10.2.1) in the book: Just two independent normal distributions (ideally) with equal variances (which are assumed to be unknown). No cross-over design, just overall mean plus fixed treatment effect plus normal random error ("two-sample parallel design").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Simulate data of 500,000 experiments in a two-sample parallel design */

%let n=69;      /* sample size per group */
%let mu=1;      /* overall mean, arbitrarily selected */
%let d=0.05;    /* fixed treatment effect */
%let s=0.4;     /* common standard deviation in both groups */

data sim2(drop=F:);
call streaminit('MT64',31415927);
retain sim k i y e;
array F[*] FT FR (%sysevalf(&amp;amp;d/2) -%sysevalf(&amp;amp;d/2));
do sim=1 to 500000;
  do k=1 to 2;
    do i=1 to &amp;amp;n;
      e=rand('normal',0,&amp;amp;s);
      y=&amp;amp;mu+F[k]+e;
      output;
    end;
  end;
end;
run;

/* Perform equivalence test */

options nonotes;
ods select none;
ods noresults;

ods output EquivLimits=eqlim2(where=(method='Pooled'));
proc ttest data=sim2 tost(-0.223, 0.223);
by sim;
class k;
var y;
run;

options notes;
ods select all;
ods results;

proc freq data=eqlim2;
tables assessment / binomial;
run; /* proportion assessment="Equivalent", i.e., estimated power: 0.8011 (95%-CI: [0.8000, 0.8022]) */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Again, the result of the simulation matches the computed power&amp;nbsp;0.8017... obtained before.&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2025 17:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sample-size-for-average-bioequivalence/m-p/966505#M48570</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-05-14T17:42:03Z</dc:date>
    </item>
  </channel>
</rss>

