Skip to content

Commit

Permalink
Merge pull request #418 from imbs-hl/catch_rInfJack_calibration_error
Browse files Browse the repository at this point in the history
Catch rinfJack calibration errors
  • Loading branch information
mnwright committed Aug 12, 2019
2 parents 62d8230 + 6e0eede commit ce20f7a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions R/infinitesimalJackknife.R
Expand Up @@ -98,8 +98,18 @@ rInfJack = function(pred, inbag, calibrate = TRUE, used.trees = NULL) {
sigma2 = (delta^2 + (1 - delta)^2) / (2 * (1 - delta)^2) * sigma2.ss

# Use Monte Carlo noise scale estimate for empirical Bayes calibration
vars.calibrated = calibrateEB(vars, sigma2)
results$var.hat = vars.calibrated
results = tryCatch(
expr = {
vars.calibrated = calibrateEB(vars, sigma2)
results$var.hat = vars.calibrated
results
},
error = function(e) {
warning(sprintf("Calibration failed with error:\n%sFalling back to non-calibrated variance estimates.", e))
results = rInfJack(pred, inbag, calibrate = FALSE, used.trees = used.trees)
return(results)
}
)
}

return(results)
Expand Down

0 comments on commit ce20f7a

Please sign in to comment.