Run extra optimization on an already fitted object
Source:R/extra-optimization.R
run_extra_optimization.Rd
Arguments
- object
An object from
sdmTMB()
.- nlminb_loops
How many extra times to run
stats::nlminb()
optimization. Sometimes restarting the optimizer at the previous best values aids convergence.- newton_loops
How many extra Newton optimization loops to try with
stats::optimHess()
. Sometimes aids convergence.
Examples
# Run extra optimization steps to help convergence:
# (Not typically needed)
fit <- sdmTMB(density ~ 0 + poly(depth, 2) + as.factor(year),
data = pcod_2011, mesh = pcod_mesh_2011, family = tweedie())
fit_1 <- run_extra_optimization(fit, newton_loops = 1)
max(fit$gradients)
#> [1] 5.791343e-09
max(fit_1$gradients)
#> [1] 5.791343e-09