Skip to content

Commit

Permalink
suppress warnings in numerical diff for scale transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
mjskay committed Feb 15, 2024
1 parent 0526589 commit 873512c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions R/distributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,14 @@ inverse_deriv_at_y = function(trans, y) {
}, error = function(e) {
# if analytical approach fails, use numerical approach.
# we use this (slightly less quick) approach instead of numDeriv::grad()
# because numDeriv::grad() errors out if any data point fails while this
# will return `NA` for those points
vapply(y, numDeriv::jacobian, func = trans$inverse, numeric(1))
# on the whole vector because numDeriv::grad() errors out if any data
# point fails while this will return `NA` for those points
vapply(y, FUN.VALUE = numeric(1), function(y_i) {
tryCatch(
suppressWarnings(numDeriv::grad(func = trans$inverse, y_i)),
error = function(e) NA_real_
)
})
})
}
}
Expand Down

0 comments on commit 873512c

Please sign in to comment.