Skip to content

Commit

Permalink
Move gengamma Q to 2nd phase
Browse files Browse the repository at this point in the history
Improves convergence
  • Loading branch information
seananderson committed Apr 26, 2024
1 parent fe34ce9 commit 0b9ec47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,7 +1,7 @@
Type: Package
Package: sdmTMB
Title: Spatial and Spatiotemporal SPDE-Based GLMMs with 'TMB'
Version: 0.5.0.9002
Version: 0.5.0.9003
Authors@R: c(
person(c("Sean", "C."), "Anderson", , "sean@seananderson.ca",
role = c("aut", "cre"),
Expand Down
6 changes: 3 additions & 3 deletions R/fit.R
Expand Up @@ -1148,7 +1148,7 @@ sdmTMB <- function(
ln_kappa = matrix(0, 2L, n_m),
# ln_kappa = rep(log(sqrt(8) / median(stats::dist(spde$mesh$loc))), 2),
thetaf = 0,
gengamma_Q = 1, # Not defined at exactly 0
gengamma_Q = 0.5, # Not defined at exactly 0
logit_p_mix = 0,
log_ratio_mix = 0,
ln_phi = rep(0, n_m),
Expand Down Expand Up @@ -1180,7 +1180,7 @@ sdmTMB <- function(
tmb_map$b_j <- NULL
if (delta) tmb_map$b_j2 <- NULL
if (family$family[[1]] == "tweedie") tmb_map$thetaf <- NULL
if ("gengamma" %in% family$family) tmb_map$gengamma_Q <- NULL
if ("gengamma" %in% family$family) tmb_map$gengamma_Q <- factor(NA)
if (family$family[[1]] %in% c("gamma_mix", "lognormal_mix", "nbinom2_mix")) {
tmb_map$log_ratio_mix <- NULL
tmb_map$logit_p_mix <- NULL
Expand Down Expand Up @@ -1212,7 +1212,6 @@ sdmTMB <- function(

if (multiphase && is.null(previous_fit) && do_fit) {


original_tmb_data <- tmb_data
# much faster on first phase!?
tmb_data$no_spatial <- 1L
Expand Down Expand Up @@ -1352,6 +1351,7 @@ sdmTMB <- function(
}

if (tmb_data$threshold_func > 0) tmb_map$b_threshold <- NULL
if ("gengamma" %in% family$family) tmb_map$gengamma_Q <- NULL

for (i in seq_along(map)) { # user supplied
cli_inform(c(i = paste0("Fixing or mirroring `", names(map)[i], "`")))
Expand Down

0 comments on commit 0b9ec47

Please sign in to comment.