######################################################################### # # This R Program is for the implmentation of the Non-parametric # optimal design of O'Quigley, Paoletti, and Maccario (2002)* in # dose finding studies. The function 'npoptimal' returns a the # distribution of the MTD recommendation according to a number of # simulations, based on the target, the true toxicity probalities, # and the sample size. # # *O’Quigley, J. , Paoletti, X. and Maccario, J. (2002) Non- # parametric optimal design in dose finding studies. Biostatistics, # 3(1): 51-56. # ######################################################################### npoptimal<-function(r,theta,n,B){ count<-rep(0,length(r)) for(i in 1:B){ v<<-rep(NA,n) tox<<-matrix(nrow=n,ncol=length(r)) for(j in 1:n){ ### Generates a toxicity threshold for the given patient v[j]<<-runif(1) ### Assigns the complete information to the given patient based on ### the threshold generated above for(l in 1:(length(r)-1)){ if(v[j]<=r[1]) {tox[j,]<<-rep(1,length(r))} if(v[j]<=r[l+1] & v[j]>r[l]) {tox[j,]<<-c(rep(0,l),rep(1,length(r)-l))} if(v[j]>=r[length(r)]) {tox[j,]<<-rep(0,length(r))} } } ### Calculates the estimates of the toxicity probabilities rhat<-colMeans(tox) distance<-abs(rhat-theta) library("nnet") ### Determines the MTD, randomly breaks ties if they arise next.lev<-which.is.max(-distance) ### Outputs the estimated toxicity probabilities and the MTD out<-list(ptox.est=round(rhat,2),MTD=next.lev) count[out$MTD]<-count[out$MTD]+1 } ### Output the recommended dose allocation out2<-list(MTD.rec=round(count/B,2),p.tox=r,Target=theta,Sample.size=n) } ### Function npoptimal ends here ### Target DLT rate theta<-0.25 ### sample size n<-16 ### True toxicity probabilities r<-c(0.01,0.05,0.10,0.15,0.45,0.60) ### Number of simulations B=5000 fit<-npoptimal(r,theta,n,B) ### fit gives: ### 1) Dose allocation based on B simulations ### 2) True toxicity probabilites ### 3) Target toxicity rate ### 4) The sample size fit