Advertisement
Spartrap

Compute the POS of a CT for any given true Treatment Effect

Aug 21st, 2019
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.52 KB | None | 0 0
  1. # An R script to compute the Probability of Success of a clinical trial
  2. # for any given true Treatment Effect
  3. #
  4. # (c) 2019 Germain Garand <germain.garand@laposte.net>
  5. #
  6. # This is for information purposes only. Any calculation performed herein could be
  7. # wrong and/or misrepresent reality. Use at your own risk.
  8. #
  9. # License: Creative Commons BY-NC 2.0
  10. #
  11. # Version 0.12
  12. #
  13.  
  14.  
  15. library(stats)
  16. library(methods)
  17. library(gsDesign, quietly=1)
  18.  
  19. # Proportions to test
  20. # -------------------
  21. # success rate in Comparator Arm
  22. p1 = 23/100
  23. # success rate in Treatment Arm
  24. p2 = 33/100
  25.  
  26. # Trial characteristics
  27. alpha = .05
  28. power = .9
  29. accrual = 400
  30.  
  31. a2 = alpha/2
  32. b = 1 - power
  33. n = nBinomial(p1=p1, p2=p2, alpha=a2, beta=b)
  34.  
  35. message("Trial design:")
  36. message("-------------")
  37. message(accrual, " patients ; Type-I error: ", alpha*100, "% ; Power: ", power*100, "%")
  38. message("-------------")
  39. message("Testing hypothesized true effect of ", p1*100, "% for Comparator arm vs. ", p2*100, "% for Treatment arm.")
  40. message("Required accrual for ", power*100, "% probability of success: ", floor(n))
  41. test = gsDesign(k=2, n.fix=n, alpha=a2, beta=b)
  42. theta = test$theta[2]
  43. message("We are looking for a theta value of: ", theta)
  44. orig = gsDesign(k=2, n.fix=accrual, alpha=a2, beta=b)
  45. #message("----------------------------------------")
  46. #show(orig)
  47. #message("----------------------------------------")
  48. p = gsProbability(theta=theta, d=orig)
  49. pos = sum(p$upper$prob)
  50. message("The Probability of Success of the trial is: ", floor(pos*100), "%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement