We developed an app that does TOST sample size calculations. I can't send that out, but I can share the script I used to replicate power calculations for TOST in SAS using Owen's Q. It has the code for 1 and 2-sided scenarios with an example for each. Note, this will not handle small signal-to-noise scenarios well. In my experience with this so far, it only works until nu (sample size parameter) gets to be around 200-250 because Gamma( nu/2 ) runs into a numerical overflow issue and returns a missing value.
//Owen's Q
OwensQ = Function( {t, delta, a, b, nu},
c = Sqrt( 2 * Pi() ) / (Gamma( nu / 2 ) * Power( 2, (nu - 2) / 2 ));
integrand = Expr(
Normal Distribution( ((t * x / Sqrt( nu )) - delta) ) * Power( x, nu - 1 ) * Normal Density( x )
);
c * Integrate( integrand, x, a, b, <<Starting Value( Mean( a, b ) ) );
);
/******** 1-Sample TOST Power ****************/
One_TOST_power = expr(
nu = n - 1;
t1 = -t Quantile( conf, nu );
t2 = t Quantile( conf, nu );
delta1 = (mu - muu) / (sigma / Sqrt( n ));
delta2 = (mu - mul) / (sigma / Sqrt( n ));
b = (Sqrt( nu ) * (muu - mul)) / ((2 * sigma / Sqrt( n )) * t Quantile( conf, nu ));
//Power:
OwensQ( t1, delta1, 0, b, nu ) - OwensQ( t2, delta2, 0, b, nu );
);
//1-sample case:
n = 15;
conf = 0.95;
mu = 505;
muu = 510;
mul = 490;
sigma = 4;
One_TOST_power(); //should be 0.9983947 (second part is effectively 0)
/******** 2-Sample TOST Power ****************/
Two_TOST_power = expr(
nu = N - 2;
w1 = 1/(W+1);
w2 = W/(W+1);
t1 = -t Quantile( conf, nu );
t2 = t Quantile( conf, nu );
//For Unequal Sample Sizes
//Non-centrality parameters:
delta1 = (mudiff - mudiff_u) / (sigma / (Sqrt( N ) * Sqrt( w1 * w2 )));
delta2 = (mudiff - mudiff_l) / (sigma / (Sqrt( N ) * Sqrt( w1 * w2 )));
//Upper integration limit:
b = (Sqrt( nu ) * (mudiff_u - mudiff_l)) / ((2 * sigma / (Sqrt( N ) * Sqrt( w1 * w2 ))) * t Quantile( conf, nu ));
Power = OwensQ( t1, delta1, 0, b, nu ) - OwensQ( t2, delta2, 0, b, nu );
);
//2-sample equal sizes:
N = 36;
W = 1;
conf = 0.95;
mudiff_l = -2;
mudiff_u = 2;
mudiff = 0;
sigma = 2;
Two_TOST_power(); //Should be just over 0.8
//2-sample unequal sizes:
N = 42;
W = 2; //unequal sample sizes:
conf = 0.95;
mudiff_l = -2;
mudiff_u = 2;
mudiff = 0;
sigma = 2;
Two_TOST_power(); //Should be just over 0.8
-- Cameron Willden