Skip to content

Commit 9774531

Browse files
committed
- Fixed missing detail about def for count data in documentation for bmdMA
- Fixed bmd.edfct for BC model for cases where maximum is reached for very small dose values.
1 parent 80cc863 commit 9774531

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

R/bmd.edfct.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff 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

R/bmdMA.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@
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.

0 commit comments

Comments
 (0)