keaven / gsDesign

Group sequential design for clinical trials
https://keaven.github.io/gsDesign/
GNU General Public License v3.0
51 stars 14 forks source link

Better error message when enrollment rate vectors are longer than `T - minfup` #117

Open nanxstats opened 10 months ago

nanxstats commented 10 months ago

When the length of the enrollment rates vector gamma/R is accidentally set to be longer than T - minfup, for example:

library(gsDesign)

gsSurv(
  k = 2,
  test.type = 4,
  alpha = 0.025,
  beta = 0.1,
  astar = 0,
  timing = 0.75,
  sfu = sfLDOF,
  sfupar = c(0),
  sfl = sfHSD,
  sflpar = c(0),
  lambdaC = log(2)/20,
  hr = 0.65,
  hr0 = 1,
  eta = -log(1-0.02)/18,
  gamma = c(1, 6, 10, 20, 30),
  R = rep(1, 5),
  S = NULL,
  T = 12,
  minfup = 8,
  ratio = 1
)

This yields the cryptic error message:

Error in `rownames<-`(`*tmp*`, value = nameR) : 
  attempt to set 'rownames' on an object with no dimensions

Perhaps the reason is obvious (discrete time unit?), we should probably handle this exception in the logic explicitly.

nanxstats commented 10 months ago

This error becomes more prevalent since the breaking change on default values for T and minfup in gsDesign 3.6.0. I got another inquiry today about this error because some old code can't run - obviously, T and minfup were not explicitly specified before in the gsSurv() call, so they inherited the new defaults which cannot satisfy the constraint.