From 4464143e509b7eedfb1511ee0aeed56df7e1d843 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Wed, 19 Jun 2024 10:10:56 -0700 Subject: [PATCH] Fix exponentiate in tidy() #353 And make conf.int = TRUE default --- R/tidy.R | 5 +++-- man/tidy.sdmTMB.Rd | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/R/tidy.R b/R/tidy.R index e1dff0112..0d42765a0 100644 --- a/R/tidy.R +++ b/R/tidy.R @@ -45,7 +45,7 @@ #' tidy(fit, "ran_vals") tidy.sdmTMB <- function(x, effects = c("fixed", "ran_pars", "ran_vals"), model = 1, - conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, + conf.int = TRUE, conf.level = 0.95, exponentiate = FALSE, silent = FALSE, ...) { effects <- match.arg(effects) assert_that(is.logical(exponentiate)) @@ -131,7 +131,6 @@ tidy.sdmTMB <- function(x, effects = c("fixed", "ran_pars", "ran_vals"), model = b_j_se <- se$b_j[!fe_names == "offset", drop = TRUE] fe_names <- fe_names[!fe_names == "offset"] out <- data.frame(term = fe_names, estimate = b_j, std.error = b_j_se, stringsAsFactors = FALSE) - if (exponentiate) out$estimate <- trans(out$estimate) if (x$tmb_data$threshold_func > 0) { if (x$threshold_function == 1L) { @@ -152,6 +151,8 @@ tidy.sdmTMB <- function(x, effects = c("fixed", "ran_pars", "ran_vals"), model = out$conf.low <- as.numeric(trans(out$estimate - crit * out$std.error)) out$conf.high <- as.numeric(trans(out$estimate + crit * out$std.error)) } + out$estimate <- trans(out$estimate) + if (exponentiate) out$std.error <- NULL out_re <- list() log_name <- c("log_range") diff --git a/man/tidy.sdmTMB.Rd b/man/tidy.sdmTMB.Rd index a9ae62a67..d7d03ce3e 100644 --- a/man/tidy.sdmTMB.Rd +++ b/man/tidy.sdmTMB.Rd @@ -8,7 +8,7 @@ x, effects = c("fixed", "ran_pars", "ran_vals"), model = 1, - conf.int = FALSE, + conf.int = TRUE, conf.level = 0.95, exponentiate = FALSE, silent = FALSE,