R-Code for Power in 2×2 Cross-over [🇷 for BE/BA]

posted by ElMaestro  – Denmark, 2021-12-02 15:15 (204 d 23:36 ago) – Posting: # 22684
Views: 1,899

Hello Brus,

» I am not an expert in R, and I am trying to adapt your example of power calculation with plot replesentation, but for the calculation of the sample size. My objetive is to plot a graphicala representation with ratio in X axis and sample size in Y axis and setting the CV and power as a fixed value.

Here's something basic to get you started. I assume you already have the PowerTOST package on your system.

Try.this=function(CV=0.2, tpow=0.8)
{
 library(PowerTOST)
 x=c(85:120)/100
 y=rep(NA, length(x))
 for (i in 1:length(x))
  y[i]= sampleN.TOST(CV=CV, targetpower=tpow, theta0=x[i])[1,7]
 plot(x,y, col="red", xlab ="GMR", ylab="Sample size")

 lines(x,y, col="red")
 return(0)
}

Try.this(CV=0.3, tpow=0.9)


Can be refined with designs and multipanel options and what not. :-)
PS: Correct, I am not entirely comfy with the tapply, sapply, apply family of functions.

Pass or fail!
ElMaestro

Complete thread:

UA Flag
Activity
 Admin contact
22,166 posts in 4,645 threads, 1,572 registered users;
online 5 (0 registered, 5 guests [including 1 identified bots]).
Forum time: Saturday 15:51 CEST (Europe/Vienna)

Absolute certainty is a privilege of uneducated minds  and fanatics.
It is, for scientific folk, an unattainable ideal.    Cassius J. Keyser

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