- if (estimator$method == "id") {
- mu <- convert_mu_units(dataset[, 2], estimator$mu_units, estimator$mu)
- estimate <- round(Rnaught::id(cases, mu), 2)
- } else if (estimator$method == "idea") {
- mu <- convert_mu_units(dataset[, 2], estimator$mu_units, estimator$mu)
- estimate <- round(Rnaught::idea(cases, mu), 2)
- } else if (estimator$method == "seq_bayes") {
- mu <- convert_mu_units(dataset[, 2], estimator$mu_units, estimator$mu)
- estimate <- round(Rnaught::seq_bayes(cases, mu, estimator$kappa), 2)
- } else if (estimator$method == "wp") {
- if (is.na(estimator$mu)) {
- estimate <- Rnaught::wp(cases, serial = TRUE,
- grid_length = estimator$grid_length,
- max_shape = estimator$max_shape, max_scale = estimator$max_scale
- )
- estimated_mu <- round(sum(estimate$supp * estimate$pmf), 2)
- estimate <- paste0(round(estimate$r0, 2), " (SI = ", estimated_mu,
- " ", tolower(dataset[, 2]), ")"
+ tryCatch(
+ {
+ if (estimator$method == "id") {
+ mu <- convert_mu_units(dataset[, 2], estimator$mu_units, estimator$mu)
+ estimate <- round(Rnaught::id(cases, mu), 2)
+ } else if (estimator$method == "idea") {
+ mu <- convert_mu_units(dataset[, 2], estimator$mu_units, estimator$mu)
+ estimate <- round(Rnaught::idea(cases, mu), 2)
+ } else if (estimator$method == "seq_bayes") {
+ mu <- convert_mu_units(dataset[, 2], estimator$mu_units, estimator$mu)
+ estimate <- round(Rnaught::seq_bayes(cases, mu, estimator$kappa), 2)
+ } else if (estimator$method == "wp") {
+ if (is.na(estimator$mu)) {
+ estimate <- Rnaught::wp(cases, serial = TRUE,
+ grid_length = estimator$grid_length,
+ max_shape = estimator$max_shape, max_scale = estimator$max_scale
+ )
+ estimated_mu <- round(sum(estimate$supp * estimate$pmf), 2)
+ estimate <- paste0(round(estimate$r0, 2), " (SI = ", estimated_mu,
+ " ", tolower(dataset[, 2]), ")"
+ )
+ } else {
+ mu <- convert_mu_units(dataset[, 2], estimator$mu_units, estimator$mu)
+ estimate <- round(Rnaught::wp(cases, mu), 2)
+ }
+ }
+
+ return(estimate)
+ }, error = function(e) {
+ showNotification(
+ paste0(toString(e),
+ " [Estimator: ", sub(" .*", "", estimator_name(estimator)),
+ ", Dataset: ", dataset[, 1], "]"
+ ), duration = 6