Description Usage Arguments Value See Also Examples
Calculates the sample size required for a TOST test, given a sample size through exact statistics or simulation
1 2 3 | tost_power(mu_A, mu_B, sd_A, sd_B, delta = 0.3, kappa = 1,
alpha = 0.05, power = 0.8, method = "equivalence",
n_iterations = 1000, paired = F, sample_var = 0)
|
mu_A |
mean of group A |
mu_B |
mean of group B |
sd_A |
SD of group A |
sd_B |
SD of group B |
delta |
maximum tolerated difference (i.e., abs(mu_A - mu_B)) |
kappa |
sample size of group A / sample size of group B (nA / nB) |
alpha |
significance threshold (0.05 default) |
power |
Desired power level (0.8 default) |
method |
Whether to use the exact statistics or simulation. "Exact" - exact statistics, "equivalence" - simulate using equivalence package tost function, "TOSTER" - simulate using TOSTER functions |
n_iterations |
Number of simulation iterations |
paired |
If the TOST is paired (kappa should be 1) |
paired_var |
Sample variance for paired TOST |
For exact statistics, returns a list of two values: minimum sample size to achieve desired power and the power at that sample size. For simulation, returns a series of sample sizes and achieved power up to the desired power.
http://powerandsamplesize.com/Calculators/Compare-2-Means/2-Sample-Equality Chow S, Shao J, Wang H. 2008. Sample Size Calculations in Clinical Research. 2nd Ed. Chapman & Hall/CRC Biostatistics Series. page 58.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | res_equivalence <- tost_power(mu_A=1, mu_B=1, sd_A=0.2, sd_B=0.2, delta=0.2, method="equivalence")
res_toster <- tost_power(mu_A=1, mu_B=1, sd_A=0.2, sd_B=0.2, delta=0.2, method="TOSTER")
res_exact <- tost_power(mu_A=1, mu_B=1, sd_A=0.2, sd_B=0.2, delta=0.2, method="exact")
plot(res_equivalence$nB, res_equivalence$Power, xlim=c(1,20), ylim=c(0,1), type="s", main="TOST power analysis")
lines(res_toster$nB, res_toster$Power, col="green", type="s")
abline(h=0.8, col="blue", lty=2)
points(res_exact$nB, res_exact$Power, col="red", pch=18, cex=2)
legend("topleft", legend=c("equivalence", "TOSTER", "exact"), col=c("black", "green", "red"), pch=1)
res_equivalence <- tost_power(mu_A=1, mu_B=1, sd_A=0.2, sd_B=0.2, delta=0.1, method="equivalence")
res_exact <- tost_power(mu_A=1, mu_B=1, sd_A=0.2, sd_B=0.2, delta=0.1, method="exact")
plot(res_equivalence$nB, res_equivalence$Power, xlim=c(1,80), ylim=c(0,1), type="s", main="TOST power analysis")
abline(h=0.8, col="blue", lty=2)
points(res_exact$nB, res_exact$Power, col="red", pch=18, cex=2)
legend("topleft", legend=c("equivalence", "exact"), col=c("black", "red"), pch=1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.