Skip to content

Commit

Permalink
also use glmmTMB, more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 2, 2023
1 parent 046d0eb commit e535813
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions R/convert_bayesian_to_frequentist.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ convert_bayesian_as_frequentist <- function(model, data = NULL, REML = TRUE) {
# subset,
# knots,
# meta-analysis
if (info$is_dispersion ||
info$is_zero_inflated ||
info$is_zeroinf ||
info$is_hurdle) {
if (info$is_dispersion || info$is_zero_inflated || info$is_zeroinf || info$is_hurdle) {
insight::check_if_installed("glmmTMB")

cond_formula <- .rebuild_cond_formula(formula)
Expand Down Expand Up @@ -124,6 +121,7 @@ convert_bayesian_as_frequentist <- function(model, data = NULL, REML = TRUE) {
)
} else if (info$is_mixed) {
insight::check_if_installed("lme4")
insight::check_if_installed("glmmTMB")

cond_formula <- .rebuild_cond_formula(formula)
if (info$is_linear) {
Expand All @@ -135,6 +133,7 @@ convert_bayesian_as_frequentist <- function(model, data = NULL, REML = TRUE) {
error = function(e) e
)
} else {
## TODO: check if beta/Gamma are correctly captured
freq <- tryCatch(
lme4::glmer(
formula = cond_formula,
Expand All @@ -143,6 +142,16 @@ convert_bayesian_as_frequentist <- function(model, data = NULL, REML = TRUE) {
),
error = function(e) e
)
if (inherits(freq, "error")) {
freq <- tryCatch(
glmmTMB::glmmTMB(
formula = cond_formula,
family = family,
data = data
),
error = function(e) e
)
}
}
} else {
if (info$is_linear) {
Expand Down

0 comments on commit e535813

Please sign in to comment.