Simulations [Power / Sample Size]

posted by Helmut Homepage – Vienna, Austria, 2017-12-26 16:51 (2391 d 00:15 ago) – Posting: # 18088
Views: 34,943

Hi kms,

❝ I mean to say always it is coming in the interval 95 to 99 and some times 100 ofcourse one time only, some times we are getting less power on 80s but very less times.

It might be in the actual study that the CV is lower and/or the GMR closer to 1 than assumed. Power is especially sensitive to the GMR. We can also simulate studies and assess the outcome. The GMR follows the log­normal distribution and the variance the χ² distribution with n–2 degrees of freedom in a 2×2×2 crossover. Try this R-code (the library PowerTOST will be installed if not available):

### housekeeping ###
packages <- c("PowerTOST", "MASS")
inst     <- packages %in% installed.packages()
if (length(packages[!inst]) > 0) install.packages(package[!inst])
invisible(lapply(packages, require, character.only=TRUE))
### give the relevant data below ###
CV      <- 0.20 # assumed CV
theta0  <- 0.95 # assumed T/R-ratio
target  <- 0.90 # target (desired) power
nsims   <- 1e4  # number of simulated studies
### change below this line only if you know what you are doing ###
plan    <- sampleN.TOST(CV=CV, theta0=theta0, targetpower=target, print=FALSE)
n       <- plan[["Sample size"]]
sim.pwr <- power.TOST.sim(CV=CV, theta0=theta0, n=n, nsims=nsims)
cat(paste0("Assumed CV = ", CV, ", GMR = ", theta0, "; target power = ", target,
    ";\nestimated sample size = ", n, " (power = ", signif(plan[["Achieved power"]], 4),
    ").\nAverage power in ", nsims, " simulated studies: ", signif(sim.pwr, 4), "\n"))

Assumed CV = 0.2, GMR = 0.95; target power = 0.9;
estimated sample size = 26 (power = 0.9176).
Average power in 10000 simulated studies: 0.9208

If you are interested in distributions of the GMR, CVs, and powers in the simulated studies, continue:

df  <- n-2
se  <- CV2se(CV)*sqrt(0.5/n) # Cave: simple formula for balanced sequences
mse <- CV2mse(CV)
res <- data.frame(GMR=rep(NA, nsims), CV=NA, power=NA)
names(res)[3] <- "post hoc power"
res$GMR <- exp(rnorm(n=nsims, mean=log(theta0), sd=sqrt(0.5/n)*sqrt(mse)))
res$CV  <- mse2CV(mse*rchisq(n=nsims, df=df)/df)
for (j in 1:nsims) {
  res[j, 3] <- power.TOST(CV=res$CV[j], theta0=res$GMR[j], n=n)
cat("Results of", nsims, "simulated studies:\n"); summary(res)

Results of 10000 simulated studies:
      GMR               CV          post hoc power
 Min.   :0.8454   Min.   :0.09836   Min.   :0.2635
 1st Qu.:0.9326   1st Qu.:0.17808   1st Qu.:0.8374
 Median :0.9505   Median :0.19758   Median :0.9189
 Mean   :0.9508   Mean   :0.19850   Mean   :0.8887
 3rd Qu.:0.9679   3rd Qu.:0.21801   3rd Qu.:0.9683
 Max.   :1.0493   Max.   :0.31336   Max.   :1.0000

Explore also boxplots and a histograms:

col <- "bisque"
boxplot(res, col=col, boxwex=0.65, las=1)
ylab <- "relative frequency density"
op <- par(no.readonly=TRUE)
np <- c(4.5, 4.5, 1, 0.3) + 0.1
split.screen(c(1, 3))
truehist(res[, 1], col=col, lty=0, xlab="GMR", las=1, bty="o", ylab=ylab, log="x")
truehist(res[, 2], col=col, lty=0, xlab="CV", las=1, bty="o", ylab=ylab)
truehist(res[, 3], col=col, lty=0, xlab="post hoc power", las=1, bty="o", ylab=ylab)
abline(v=plan[["Achieved power"]], col="blue")

Especially the histogram is telling.

Even if the study was planned for 90% power (like in the example) I strongly doubt that you will always get a post hoc power of 95–99%:

cat("Simulated studies with post hoc power [0.95, 0.99]:", sprintf("%.2f%%",
    100*length(res[, 3][res[, 3] >= 0.95 & res[, 3] <=0.99])/nsims), "\n")

Simulated studies with post hoc power [0.95, 0.99]: 25.28%

If the study was planned for 80% power it will be even less likely:

Simulated studies with post hoc power [0.95, 0.99]: 12.63%

As ElMaestro suggested: Can you give us one example? We need the CV, the GMR, the number of eligible subjects, and your “power”. If the study was imbalanced, please give the number of subjects in each sequence.

Dif-tor heh smusma 🖖🏼 Довге життя Україна! [image]
Helmut Schütz

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes

Complete thread:

UA Flag
 Admin contact
23,099 posts in 4,857 threads, 1,646 registered users;
78 visitors (0 registered, 78 guests [including 12 identified bots]).
Forum time: 18:06 CEST (Europe/Vienna)

Imagine if every Thursday your shoes exploded
if you tied them the usual way.
This happens to us all the time with computers,
and nobody thinks of complaining.    Jef Raskin

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz