File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -213,7 +213,17 @@ bmd.edfct <- function(object){
213213 expVal <- exp(parmVec [1 ]* (log(dose )- log(parmVec [4 ])))
214214 parmVec [5 ]* (1 + expVal * (1 - parmVec [1 ]))- (parmVec [3 ]- parmVec [2 ])* expVal * parmVec [1 ]/ dose
215215 }
216- maxAt <- uniroot(helpEqn , interval )$ root
216+ maxAt <- try(uniroot(helpEqn , interval )$ root , TRUE )
217+
218+ # solution if maxAt fails
219+ if (inherits(maxAt , " try-error" )){
220+ find_maxAt_tries <- 1
221+ while (inherits(maxAt , " try-error" ) & (find_maxAt_tries < 10 )){
222+ interval [1 ] <- interval [1 ]/ 1e2
223+ maxAt <- try(uniroot(helpEqn , interval )$ root , TRUE )
224+ find_maxAt_tries <- find_maxAt_tries + 1
225+ }
226+ }
217227
218228 eqn <- function (dose ) {tempVal * (1 + exp(parmVec [1 ]* (log(dose )- log(parmVec [4 ]))))- (1 + parmVec [5 ]* dose / (parmVec [3 ]- parmVec [2 ]))}
219229 EDp <- uniroot(eqn , lower = maxAt , upper = upper )$ root
Original file line number Diff line number Diff line change 5757# ' dose-response models), 2 SD for "hybridSD" background and 0.9 for
5858# ' "hybridpercentile"
5959# ' @param def character string specifying the definition of the benchmark dose
60- # ' to use in the calculations. "excess" , "additional" and "point" are for
61- # ' binomial response whereas "relative", "extra", "added", "hybridExc" (excess
60+ # ' to use in the calculations. "excess", "additional" and "point" are for
61+ # ' binomial response. "relative", "extra", "added", "hybridExc" (excess
6262# ' hybrid), "hybridAdd" (additional hybrid), and "point" are for continuous
63- # ' response
63+ # ' response. "relative", "extra", and "point" are for count response data.
6464# '
6565# ' "excess" - BMR is defined as: BMR = (f(BMD) - p0)/(1 - p0). Works for
6666# ' binomial response. BMR should be between 0 and 1.
You can’t perform that action at this time.
0 commit comments