Advanced example for 2X2X2 [🇷 for BE/BA]

posted by mittyri  – Russia, 2015-08-14 21:40 (3598 d 03:37 ago) – Posting: # 15271
Views: 12,737

Dear Helmut, Detlew and BE-proff!

Helmut, THX a lot for this great code!
I think the version for 2X2X2 would be also useful (your code a little bit changed):
library(PowerTOST)
f1       <- function(x) power.TOST(CV=CV.Cmax, theta0=x, n=n1.AUC, des=des)-pwr
f2       <- function(x) power.TOST(CV=CV.AUC, theta0=x, n=n1.Cmax, des=des)-pwr
CV.Cmax  <- 0.29    # 2X2X2 even for HVD/HVDPs
CV.AUC   <- 0.25    # as well!
TR.Cmax  <- 0.95    # May change to a nicer value if CV <0.3
TR.AUC   <- 0.94    # same!
pwr      <- 0.8     # target
des      <- "2x2x2" # RT|TR
res      <- matrix(nrow=2, ncol=7, byrow=T, dimnames=list(NULL,
              c("Method", "metric", "GMR", "CV", "n",
                "power", "GMRlo")))
res.Cmax <- sampleN.TOST(CV=CV.Cmax, theta0=TR.Cmax, targetpower=pwr,
              des=des, details=F, print=F)
n1.Cmax  <- res.Cmax[["Sample size"]]
pwr.Cmax <- res.Cmax[["Achieved power"]]
res.AUC  <- sampleN.TOST(CV=CV.AUC, theta0=TR.AUC, targetpower=pwr,
              des=des, print=F)            # ABE
n1.AUC   <- res.AUC[["Sample size"]]
pwr.AUC  <- res.AUC[["Achieved power"]]
if(n1.Cmax >= n1.AUC) {
  pwr.AUC <- power.TOST(CV=CV.AUC, theta0=TR.AUC, n=n1.Cmax, des=des)
  TR.AUC.min  <- uniroot(f2, interval=c(0, 1), tol=1e-6)$root
  cat(paste0("PK metric driving the sample size: Cmax\n",
  "Sample size: ", n1.Cmax, " (ABE, power: ", sprintf("%.4f", pwr.Cmax), ")\n",
  "Power of AUC (ABE): ", sprintf("%.4f", pwr.AUC), "\n",
  "Lowest T/R-ratio of AUC which will give ", pwr, " power: ",
  sprintf("%.4f", TR.AUC.min), "\n"))
  res[1, ] <- c("ABE", "Cmax", sprintf("%.2f", TR.Cmax),
                sprintf("%.2f", CV.Cmax), n1.Cmax,
                sprintf("%.4f", pwr.Cmax), NA)
  res[2, ] <- c("ABE", "AUC", sprintf("%.2f", TR.AUC),
                 sprintf("%.2f", CV.AUC), n1.Cmax, sprintf("%.4f", pwr.AUC),  sprintf("%.4f", TR.AUC.min))

} else {
  pwr.Cmax <- power.TOST (CV=CV.Cmax, theta0=TR.Cmax, n=n1.AUC, des=des)
  TR.Cmax.min <- uniroot(f1, interval=c(0, 1), tol=1e-6)$root
  cat(paste0("PK metric driving the sample size: AUC\n",
  "Sample size: ", n1.AUC, " (ABE, power: ", sprintf("%.4f", pwr.AUC), ")\n",
  "Power of Cmax (ABE): ", sprintf("%.4f", pwr.Cmax), "\n",
  "Lowest T/R-ratio of Cmax which will give ", pwr, " power: ",
  sprintf("%.4f", TR.Cmax.min), "\n"))
  res[1, ] <- c("ABE", "AUC", sprintf("%.2f", TR.AUC),
                sprintf("%.2f", CV.AUC), n1.AUC, sprintf("%.4f", pwr.AUC), NA)
  res[2, ] <- c("ABE", "Cmax", sprintf("%.2f", TR.Cmax),
                sprintf("%.2f", CV.Cmax), n1.AUC, sprintf("%.4f", pwr.Cmax),
                sprintf("%.4f", TR.Cmax.min))
}
res <- data.frame(res)
print(res, row.names=F)


Detlew, what about implementation in PowerTOST both branches?:-D

PS: Helmut&Detlew, it seems sometimes that you're thinking on R :lol2:

Kind regards,
Mittyri

Complete thread:

UA Flag
Activity
 Admin contact
23,424 posts in 4,927 threads, 1,672 registered users;
26 visitors (0 registered, 26 guests [including 7 identified bots]).
Forum time: 01:18 CEST (Europe/Vienna)

Complex, statistically improbable things are by their nature
more difficult to explain than
simple, statistically probable things.    Richard Dawkins

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