sdmTMB (development version)
Breaking changes
Removed the defunct
delta_poisson_link_gamma()anddelta_poisson_link_lognormal(). Usedelta_gamma(type = "poisson-link")ordelta_lognormal(type = "poisson-link").Removed the defunct
extract_mcmc()andadd_barrier_mesh()functions; use the versions in sdmTMBextra. Also removed the defunctprevious_fitargument ofsdmTMB_simulate()(usesimulate.sdmTMB()) and the error for the oldexperimental = list(lwr, upr)censoring syntax.sdmTMB_cv()now scores held-out data with a predictive density integrated over the approximate posterior of the random effects (predictive = "mle-mvn") instead of at their estimated values ("mle-eb").predictive = "joint"also integrates over the fixed effects and variance parameters.nsimsets the number of draws per fold, sosum_logliknow depends on the random seed. The"mle-eb"values are always returned incv_loglik_mle_ebandsum_loglik_mle_eb. Random field uncertainty on out-of-sample predictions generally increases with more spatial knots, so it becomes increasingly important to account for random field uncertainty at finer mesh resolutions and it’s particularly important for comparing across mesh resolutions.get_index_split()now defaults tobias_correct = TRUE, matchingget_index().predict(allow_new_levels = FALSE)now gives an error for new levels of a random effect grouping factor, as in lme4 and glmmTMB. Previously it gave the same warning as the default (NULL).The arguments of
sdmTMB()afterfamilyare reordered into groups: random fields, observation model, other model terms, estimation, and deprecated arguments. Code that passes arguments afterfamilyby position must name them.Censoring bounds for
censored_poisson()andcensored_betabinomial()are now supplied with thecensored_upperargument ofsdmTMB(), which also accepts a column name indata. Thecensored_upperargument ofsdmTMBcontrol()has been removed. UseInfinstead ofNAfor no upper bound;NAis deprecated and is treated asInfwith a warning.get_censored_upper()now caps the bounds at the number of hooks. This also fixessdmTMB_cv()misaligning the bounds with the data when folds were assigned randomly with atimecolumn.predict.sdmTMB()now errors fortype = "response"withse_fit = TRUE(previously a warning, with link-scale output) and with asims_varother than"est". Usetype = "link"for standard errors ornsimfor response-scale uncertainty.sims_varaccepts only"est","omega_s","zeta_s","epsilon_st","est_rf", and"est_non_rf"; usereturn_tmb_report = TRUEwithnsimfor other reported variables.diffusion(x) + time_lag(x)innonlocal_formulanow fits one stationary joint space–time distributed-lag operator with one coefficient. Temporal persistence is constrained to be non-negative. The temporal parameter is estimated aslog_kappaT_nl(equal tologit(rhoT)) rather thankappaT_nl_raw,sdmTMB_simulate()requires0 < lags_rhoT < 1, and the derived summaries are namedMSDKandRMSDKrather thanMSDandRMSD.time_lag()now starts from a stationary state by default (the covariate is assumed to have held at its first time slice); usestart = "zero"for the previous behaviour, which matches Thorson et al. (2026).spatial_varyingnow respects its own model matrix, and the(Intercept)column is dropped only whenspatial = "on". Forspatial = "off", spatial_varying = ~ 1 + factor, the model now fits a genuine intercept field plusK - 1deviation fields instead of omitting the reference field, with a one-time warning. Thesvc-factor-modelsarticle clarifies howspatial,spatial_varying, and the intercept of thespatial_varyingdesign matrix interact.For
truncated_nbinom1()andtruncated_nbinom2(),phinow comes from each fit’s own parameters rather than the family object, so callingfamily$linkinv()directly for these families requiresphi.The experimental
epsilon_modelandepsilon_predictoroptions are removed and now error. File an issue if you’re interested in using this functionality and we can consider adding it back.
New features
simulate_new()now works with areal SAR/CAR models: pass an areal domain frommake_areal_domain()asmesh, setspatial_model = "sar"or"car", and supplyrho_saroralpha_carinstead ofrange. #552Added
lognormal_prior()as an option forsdmTMBpriors(sigma_V = ...)priors on time-varying coefficient SDs.-
RTMB is now the default backend. The model code is written in R (via RTMB) with about 50% fewer lines, and gives the same results as the TMB backend in all our tests, although simulated values differ between backends for the same seed. The TMB backend is retained for now but will eventually be dropped. To keep using it, set
control = sdmTMBcontrol(backend = "tmb")per fit oroptions(sdmTMB.backend = "tmb")per session. The move uncovered several bugs, which are fixed as listed below, and allowed for optimization of the model. Speedups relative to sdmTMB 1.1.0 on an example model with the built-inpcoddataset:- fitting: 1.2x
-
predict(): 13.5x -
get_index(bias_correct = FALSE): 10.4x -
get_index(bias_correct = TRUE): 1.5x -
simulate(nsim = 400): 1.9x -
project(nsim = 400)(30-year AR1 projection): 9.3x
simulate.sdmTMB()gains asimulate_reargument to choose which random effects are simulated as new (any of"spatial","spatiotemporal","spatial_varying","group_re","time_varying"). Random effects not named are held at their empirical Bayes estimates (type = "mle-eb") or at an approximate posterior draw (type = "mle-mvn"). For example,simulate_re = "spatiotemporal"withtype = "mle-mvn"holds the spatial fields at one posterior draw while simulating new spatiotemporal fields.Add custom priors for the RTMB backend:
sdmTMBpriors(custom = function(par, theta) ...)adds arbitrary log densities on raw (par) or natural-scale (theta) parameters, including random effects, to the joint objective. Withbayesian = TRUE,custom_log_jacobiansupplies the matching Jacobian adjustment. Newget_prior_parameters()lists the available parameters andget_prior_densities()evaluates the terms at the estimates. See the new vignette “Custom priors and penalties”.Add experimental multi-family models, where each row of the data can use a different observation family (e.g., binomial, count, and delta-lognormal data in one model with shared fields). Supply a named list to
familyand name the column mapping rows to families withdistribution_column. See the new multi-family vignette.Add
ordbeta()for ordered beta regression (Kubinec 2023), an alternative to zero-one-inflated beta for continuous data on[0, 1]with point masses at 0 and 1 (#515). Response-scale predictions and indices include the point masses.Add
censored_betabinomial()for censored beta-binomial counts, e.g., to account for hook competition in hook-and-line surveys with the number of hooks as the number of trials. It usessdmTMB(censored_upper = ...)likecensored_poisson(), withInfmeaning censoring between the observed count and the number of trials. It needs the RTMB backend. The likelihood sums the shorter of each interval and its complement, with a precision check and fallback to the direct sum after fitting (sdmTMBcontrol(censored_method = "direct")forces the direct sum). See the new article “Accounting for hook competition with censored count models”.Add
censored_binomial()for censored binomial counts. It works likecensored_betabinomial()(RTMB backend, number of trials viaweights). Withlink = "cloglog"and an observation-level random intercept, it is a Poisson-lognormal model of the per-hook catch rate with at most one fish per hook, soget_index(derived_link = "log")is proportional to the mean catch rate.Add
censored_nbinom1()andcensored_nbinom2()for censored negative binomial counts (RTMB backend). They usesdmTMB(censored_upper = ...)likecensored_poisson(), with no upper limit on the count, e.g., for catch without hook competition with an offset of log hooks.Add the
dispformulaargument tosdmTMB()for modelling the observation dispersion parameter with fixed-effect predictors. It is not supported for multi-family models or truncated negative binomial families.Add
compare_deviance()for deviance explained (a pseudo-R^2) relative to a simpler model.Add a
loo::elpd()method forsdmTMB_cv()output so models can be compared withloo::loo_compare(), including a standard error of the difference. See?sdmTMB_cv()for an example.Add deviance residuals and
deviance()forgengamma()andcensored_poisson().Add
make_zero_one_map()for categories (e.g., year factors) where the response is all zeros or ones (#386).Add
sample_feargument topredict.sdmTMB(). Withnsim > 0andsample_fe = FALSE, fixed effects are held at their estimates and only random effects are drawn.get_index(),get_cog(),get_eao(), andget_weighted_average()can now take a fitted model and prediction grid directly, e.g.,get_index(fit, newdata = grid). These functions andget_index_split()also gain anoffsetargument.project()gainssample_fe,sample_historical_re, andsample_future_rearguments to separate parameter uncertainty, historical latent state uncertainty, and future process variation, and afuture_reargument for including (the default), zeroing, or fixing future spatiotemporal and time-varying effects. Projections are faster whennewdatarepeats spatial locations across time, andproject()now keeps only the simulated values it returns, which more than halves peak memory use with many simulations.sdmTMB_cv(lfo = TRUE)now supports delta/hurdle families.Add opt-in
collapse_spatiotemporal_ar1andcollapse_ar1_thresholdcontrols to simplify spatiotemporal AR1 fields to IID or random-walk fields when the estimated correlation is near zero or one.Covariate diffusion handles non-local covariates better: time-indexed formulas are distinguished, external grids are supported for prediction and cross-validation, and insufficient grid coverage gives clear errors.
Covariate diffusion’s
kappaS_nlnow starts at a value scaled to the data’s spatial extent andlog_kappaS_nlis bounded by default, which avoids degenerate over-smoothed fits. Override the bounds withlowerorupperinsdmTMBcontrol().
Bug fixes: statistical and likelihood
Simulating new correlated random intercepts and slopes, e.g.,
(1 + x | g), withsimulate(re_form = ~0)on the TMB backend no longer gives an error.Rows with missing values in the response or any variable the model uses (including
weightsandoffset) are now omitted before fitting, as withna.omitinglm(), with a message unlesssilent = TRUE. Previously, such rows were not removed from the spatial, temporal, random-effect, and spatially varying inputs, so later rows were matched to the wrong locations and times and fits were silently incorrect.predict(),residuals(), andsdmTMB_cv()now work for these fits, and the fitted object’sdataholds the rows used.sdmTMB_simulate()now errors ifsigma_Ehas more than one value, which previously silently simulated a constant SD.truncated_nbinom1()andtruncated_nbinom2()now error on a response of zero in non-delta models instead of reporting convergence with an infinite objective.Fix three bugs in priors.
normal()priors onbused the standard deviations as variances; a singlebprior with multiple coefficients was silently dropped and is now applied to every coefficient; and withbayesian = TRUEthe Jacobian forpc_matern()priors was incorrect.-
Fix several other statistical bugs in both backends:
-
ordbeta()cutpoints are now constrained to be ordered. -
gengamma()returns aNaNlikelihood where its mean does not exist. - A
matern_stpc_matern()prior with a shared range no longer drops its range term when there is nomatern_sprior. - With
bayesian = TRUE, thethreshold_logistic_s95prior includes its Jacobian adjustment. - Response means without observation error (e.g.,
simulate(observation_error = FALSE)) are now expectations for the beta-binomial, truncated negative binomial, mixture, and ordered beta families. -
get_eao()weights density by area. -
sigma_Vpriors are no longer applied twice in delta models.
-
Fix
censored_poisson()likelihoods and gradients, which since sdmTMB 0.4.0 evaluated the censored CDF terms at the starting values. Log likelihoods are also now computed on the log scale, avoiding-Inffor observations far in the tails.Fix
time_varyingmodels with more than one column (e.g.,~ 1 + x), where estimatedb_rw_tandsigma_Vfor all but the last term were shrunk. Likelihoods, fitted values, and predictions are unchanged.Fix
breakpt()likelihoods and gradients after the cutpoint moves from its starting value in the TMB backend.Fix
ordbeta()simulation, which understated ones and the mean. The likelihood was unaffected.Fix TMB-backend simulation of AR1 and RW spatiotemporal fields with a barrier mesh, which had the wrong variance.
Fix deviance and deviance residuals: they now include observation weights, binomial residuals work for responses with more than one trial,
nbinom1()uses the saturated model withphifixed, and Poisson-link delta encounter residuals are negative for zeros.Fix
sdmTMB_cv(lfo = TRUE)log likelihoods for lognormal models, which omitted a logarithm.Mixture-family predictions now respect non-log links and population-level predictions (
re_form = NA).Fix delta models with
spatial_varyingwhere a component hasspatial = "off"(e.g.,spatial = list("on", "off")). That component’s spatially varying coefficient fields entered the model without a random field penalty and with an unidentified SD parameter. They now have a random field density and their own estimated range.
Bug fixes: prediction, indices, and other
tidy(effects = "ran_vals")for delta models withtime_varyingcoefficients now labels each row with the correctmodelcomponent. It was returning both components labelled with the requestedmodel. As with IID random effects, both components are returned regardless ofmodel.tidy(effects = "ran_pars")again reportssigma_V, the SD of time-varying coefficients, for alltime_varying_typevalues. It was being silently dropped, and AR1 time-varying models were skipped entirely. With more than one time-varying coefficient, thesigma_Vandrho_timeterms are now labelled with their coefficient, e.g.sigma_V[depth_scaled]andrho_time[depth_scaled].sanity()no longer warns (“no non-missing arguments to min”) for non-spatial models fit without a mesh.get_cog()now errors informatively for areal (SAR/CAR) models instead of returning a centre of gravity of zero.The
typecolumn returned byget_eao()is now"eao"instead of the misspelled"eoa".The
silentargument ofget_index(),get_cog(),get_eao(), andget_weighted_average()was ignored and now controls TMB’s output.get_index(),get_cog(), andget_eao()now honourpredict_args = list(re_form = NA)for single-component models. Previously the random fields were always included unless the model was a delta model.predict.sdmTMB()withoutnewdatanow returns the same values aspredict(fit, newdata = fit$data, offset = fit$offset). Previously,est_non_rfleft out smoothers and the offset,est_rfleft out spatially varying coefficient terms, andestfor mixture families lacked the mixture-mean adjustment. The fitted offset is now used for all prediction types whenoffset = NULL(previously it was 0 for delta models and internally rebuilt predictions) (#274). Setoffset = 0for predictions at an offset of 0.Fix
predict.sdmTMB()withnewdataforspatial_varying,time_varying, anddispformulaterms with data-dependent transformations such aspoly(). The fitted encoding is now saved with the model and reused, and new factor levels or missing values give an informative error. Refit models from earlier versions for exact reproduction.Fix
predict.sdmTMB()withnewdata = NULLignoringreturn_tmb_report,return_tmb_data, andnonlocal_newdata.Draws from
predict.sdmTMB()(nsimormcmc_samples) now honourre_form = NA. Population-level predictions also order columns as full predictions do, andnewdatacoordinate columns are no longer dropped for non-spatial models.Fix response-scale
est1andest2frompredict.sdmTMB()for Poisson-link delta models with a nonzero offset.Fix
type = "response"predictions fortruncated_nbinom1()andtruncated_nbinom2(), which used the starting value ofphi.Fix
residuals(type = "response")fortruncated_nbinom1()andtruncated_nbinom2(), which subtracted the untruncated mean.Fix randomized quantile residuals for zero observations with
betabinomial(), which were all set to the same value.Fix calling the index functions directly on a
do_index = TRUEfit:get_index()now honoursarea, andget_eao(),get_weighted_average(), andget_cog()no longer error (#549).Fix
sdmTMBcontrol(suppress_nlminb_warnings = TRUE), which previously had no effect.The “Maximum final gradient” convergence warning now considers the absolute value of the gradients; large negative gradients were previously ignored.
Make extra optimization more robust.
run_extra_optimization()now updates the parameters used bypredict(), leaves the original fit unchanged, updatespos_def_hessian, and counts iterations correctly. Newton updates (newton_loops) insdmTMB()andrun_extra_optimization()halve steps that cross limits or worsen the objective, and are skipped rather than erroring when the gradient, objective, or Hessian is unusable. A failed firstmultiphasephase falls back to the default starting values. The needless Newton/parameter-limit message is removed.Fix
print()showingTime column: characterinstead of the time column name (a regression in sdmTMB 0.8.1).Fix
reload_model()for models fit withnormalize = TRUE.Fix
update.sdmTMB()for binomialcbind()responses with random effects (#544).Fix
collapse_spatial_variancewith delta models so fields already disabled in one linear predictor are not treated as newly collapsed, and evaluate its internalupdate()call in the parent environment sosdmTMB()arguments can be objects within another function.Simulate correlated IID random effects with the RTMB backend when
re_form = NA.sdmTMB()checks more robustly for differing formula random effects in delta model list formulas.A
meshthat does not matchnrow(data)now errors whennonlocal_formulais used, even with spatial and spatiotemporal fields off.
Other improvements and changes
Beyond the RTMB speedups above, speed up
simulate.sdmTMB()withtype = "mle-mvn",cAIC(), andsdmTMB_cv(). For example,cAIC()takes 0.68 s instead of 41 s on a model with about 5,800 random effects.sdmTMB_cv()withsave_models = TRUEalso returns smaller objects.collapse_thresholdinsdmTMBcontrol()is deprecated in favour ofcollapse_spatial_variance_threshold.predict(..., return_tmb_object = TRUE)is soft-deprecated for index calculations; passnewdatato the index functions instead.sdmTMB(do_index = TRUE)(and itspredict_argsandindex_args) is soft-deprecated; fit the model and passnewdatato the index functions instead.Make sdmTMB compatible with visreg 3.0.0.
Revise the model description vignette and many articles.
sdmTMB 1.1.0
CRAN release: 2026-07-03
New features
sdmTMB()gains experimental support for CAR/SAR areal models as an alternative to the SPDE. See the relevant vignette at https://sdmtmb.github.io/sdmTMB/articles/index.htmlsdmTMB()gains non-local covariate support, including spatial diffusion and time lags, with newnonlocal_formulaandnonlocal_dataarguments.plot_nonlocal_kernel()andplot_nonlocal_covariate()support visualizing the resulting kernels and covariates (#507). See the relevant vignette at https://sdmtmb.github.io/sdmTMB/articles/index.htmlsdmTMB()now supports uncorrelated random slopes and intercepts with the form(1 + slope_var || group), and reports the results correctly. (@Joseph-Barss, #536).predict.sdmTMB()gainsallow_new_levelsfor prediction with new random intercept or slope levels; new levels use the population value (#196, #480).get_index()now reports index totals on a log-total scale after integrating response-scale predictions. This preserves existing behaviour for log-link abundance models and allows binomial and beta-binomial proportion models, includinglogitandclogloglinks, to useareaas an explicit standardization multiplier for expected-count indices.get_index()gainsderived_linkto override the inverse link, which is useful when fitting Bernoulli data with a cloglog link and predicting an expected count from a thinned count process (#339).sdmTMB()gains experimental Restricted Spatial Regression (RSR) fixed effects adjusted for spatial confounding with the random fields (Hanks et al. 2015; Diaz and Thorson 2025). Usecontrol = sdmTMBcontrol(get_rsr = TRUE)andtidy(fit, effects = "rsr").
Minor improvements and fixes
Fix compatibility with next RcppEigen (#538).
print()andtidy()now display the correctly transformed correlation between a random slope and intercept.sdmTMB()now usestryCatch()around Newton loops in optimization so those steps abort cleanly instead of producing an error.predict.sdmTMB()now allows missing factor levels when predicting with time-varying factor predictors (#533).sanity()now identifies the fixed effects, providing more useful diagnostics (#506).delta_poisson_link_gamma()anddelta_poisson_link_lognormal()now raise deprecation errors instead of warnings. Usedelta_gamma(type = "poisson-link")anddelta_lognormal(type = "poisson-link")instead.-
spatial_varyingnow respects its own model matrix. The(Intercept)column is only dropped whenspatial = "on", in which case the ordinary spatial fieldomega_sis used as the SVC intercept or reference-level field.A single informational message is issued at fit time, suppressible via
silent = TRUE.The only material change in fitted-model structure versus published releases is for
spatial = "off", spatial_varying = ~ 1 + factor: this previously stripped the intercept and zeroedomega_s, leaving onlyK - 1deviation fields with no reference field. It now fits a genuine SVC intercept field plusK - 1deviation fields. A warning is emitted for this specification for now.The previous message suggesting
spatial = "off"when usingspatial = "on", spatial_varying = ~ 0 + factor_varhas been removed; this is a valid model specification (global spatial field plus per-level SVC deviations) although it can be more challenging to estimate. get_index()now returns the correctse_naturalcolumn (@CataRoman, @gavinfay, #523).residuals()now uses the correct inverse link for encounter and positive-component mechanisms, including offsets, in Poisson-link delta models, avoiding spuriousNaNandInfvalues in the first linear predictor residuals. For most scenarios, simulation-based residuals fromdharma_residuals()remain the most straightforward choice for combined residuals in delta models (#512).predict.sdmTMB()now works whennewdatacontainsNAin the response column for models with random effects and the response column is present but unused for prediction (#508).
sdmTMB 1.0.0
CRAN release: 2026-01-24
- Switch the recommended citation from the preprint to the Journal of Statistical Software version. See
citation("sdmTMB").
Minor improvements and fixes
Fix crash with betabinomial and binomial when a response value was
NAbut the correspondingweightsargument (turned into ‘size’) was notNA.Add
simulate_new()as a synonym forsdmTMB_simulate().simulate_new()is recommended going forward because it is more expressive.
sdmTMB 0.8.1
CRAN release: 2026-01-08
Minor improvements and fixes
Refactor
get_cog(),get_weighted_average(), andget_eao().get_cog()should be more memory efficient and bias correction is now enabled forget_eao()andget_weighted_average(). These all now work with subsets of the full set of fitted time elements asget_index()has for a while.Optimize memory usage and speed of
get_range_edge().Remove extraDistr import to avoid CRAN warning.
Switch from
lme4toreformulaspackage for random effects parsing functions (findbars(),nobars(),subbars(),mkReTrms()). Thelme4maintainers moved these formula utilities to the separatereformulaspackage.Fix
predict()withse_fit = TRUEfor delta models to correctly return standard errors on combined predictions whenmodel = NA. Previously, standard errors were only calculated for the first component (est1) instead of the combined estimate (est). #496Fix typo in
predict()for delta models that incorrectly calculated combined predictions asp1 * p1instead ofp1 * p2in the specific case ofre_form = NAandtype = "link". #496Dramatically improve
print()performance for models with large embedded objects in calls (e.g., cross-validation scenarios with replicated data). The fix avoids expensivedeparse()operations on large data frames and mesh objects by extracting only the argument names needed for display. #492Fix error when parsing model when including
extra_timein delta-family models with a list formula. #493
sdmTMB 0.8.0
CRAN release: 2025-11-26
New features
sdmTMB_cv()now supports theweightsargument. User-supplied weights are combined with the internal fold-assignment mechanism (held-out data are assigned weight 0). Weights must be positive (> 0). #486Add experimental
collapse_spatial_varianceoption tosdmTMBcontrol()to automatically detect and turn off spatial and/or spatiotemporal random fields when their SD parameters are estimated to be very small (below a threshold). When enabled, the model will automatically refit with the appropriate fields turned off if SD parameters fall belowcollapse_threshold(default 0.01). This can help avoid boundary issues and improve model stability when random fields are not needed. Set toFALSEby default. #263Add new experimental function
get_range_edge()to calculate range edges as density-weighted quantiles along a spatial axis (e.g., latitude, coastal distance). Range edges are calculated as positions where cumulative density equals specified quantiles. Uses linear interpolation for accurate quantile estimation and simulation from the joint precision matrix for uncertainty quantification. Implements a similar approach to VAST range edge calculations following Fredston et al. (2021) https://doi.org/10.1111/gcb.15614. See the new range edge vignette at https://sdmTMB.github.io/sdmTMB/articles/The Student-t degrees of freedom parameter is now estimated by default in
student(). Previously it was fixed at 3. To fix it at a specific value, setdfto a numeric value (e.g.,student(df = 3)). To estimate it (new default), setdf = NULLor omit the argument. The parameter is constrained to be > 1. The function now prints an informative message about the df parameter behavior.Add deviance residuals for left-out data in the cross validation output. This can be used to calculate deviance explained of left-out data. See
cv_deviance_residcolumn in thedataelement of the output ofsdmTMB_cv().Add
save_modelsargument tosdmTMB_cv()(defaults toTRUE). Settingsave_models = FALSEprevents storing fitted model objects for each fold, which can substantially reduce memory usage for large datasets or many folds. WhenFALSE, functions requiring model access (tidy(),cv_to_waywiser()) will error with informative messages. Essential CV metrics (predictions, log likelihoods, deviance residuals, convergence info) remain available.Extend
sdmTMB_simulate()to support time-varying effects with vectorsigma_Vinputs and AR1 correlation (rho_time). #447Add new function
cv_to_waywiser()to convert cross-validation results to sf format for use with the waywiser package. This enables multi-scale spatial assessment of model predictions. #193Add vignette demonstrating how to fit zero-one-inflated beta (ZOIB) models by fitting three separate model components and combining predictions. #440 #441
Add argument to fix probability of extreme events for
*_mix()families. Note that the internal parameter name has also changed fromp_mixtop_extremeand fromlogit_p_mixtologit_p_extreme. #318 #474Add beta-binomial family (
betabinomial()) for modeling overdispersed binomial data. Supports logit and cloglog links, and includes proper residuals support.Add new function
get_weighted_average()to calculate biomass-weighted averages of user-supplied vectors (e.g., depth, temperature). This function follows the same pattern asget_cog()but allows users to specify any variable for weighted averaging. Supports bias correction and area weighting.Add vignette on age (or length) composition standardization. To help with this add a new experimental function
make_category_svc().Add
emmeanssupport for delta/hurdle models. Usemodel = 1for the binomial component ormodel = 2for the positive component when callingemmeans(). Example:emmeans(fit, ~ predictor, model = 2). #247 #249
Minor improvements and fixes
Fix barrier model implementation. The SPDE input matrices for the barrier model from INLA and INLAspacetime had changed. sdmTMB now appropriately uses these new matrices and unit tests in sdmTMBextra should catch such a change in the future. #457
Fix Student-t deviance residuals, which were incorrectly returning
NaNs.Fix
sign()utility function to avoidNaNwhenx = 0. Now returns standard mathematical sign function behavior:sign(0) = 0.Fix bug in
sdmTMB_cv()automatic fold generation that could result in unbalanced folds with duplicate and missing fold IDs. The bug was most severe with largek_foldsvalues (e.g., leave-one-out cross-validation withk_folds = nrow(data)), which could cause errors when folds had no data. User-suppliedfold_idswere not affected.Add check if newdata has been filtered after prediction and before passing to a
get_*()function.Fix
tidy()to only include themodelcolumn for delta models. For non-delta models, themodelcolumn is no longer included in the output foreffects = "ran_pars"andeffects = "ran_vals", making the output cleaner and more consistent.Update package logo.
Add residuals for truncated negative binomial families. #481 Thanks to @Joseph-Barss
Fix an issue with residuals for delta models by consistently using
get_par(), and another issue specifically for delta truncated negative binomial models by replacing NaN with NA. #484Fix
tidy()witheffects = "ran_pars"to report min/max anisotropic ranges (e.g.,range_min,range_max) for models fit withanisotropy = TRUE, matching the values shown inprint_anisotropy(). Standard errors and confidence intervals are set to NA since uncertainty in both the range parameter and H matrix cannot be easily propagated.Fix issue with ggeffects with multiple smoothers + offsets. #450
Improve
t2()printing and appearance intidy.sdmTMB(). #415 #472Fix
emmeanssupport for models with smoothers (s()terms). Previously,emmeanswould fail with “Non-conformable elements in reference grid” when smoothers were included in the model formula.
sdmTMB 0.7.4
CRAN release: 2025-07-29
Minor improvements and fixes
Let
simulate.sdmTMB()work with binomial GLMs with size specified viaweightsandnewdatasupplied. #465Fix issue with fold logic in LFO (leave-future-out) cross validation for
lfo_forecast > 1. #454 Thanks to @Joseph-Barss.Add
update.sdmTMB()so that the mesh argument doesn’t have to be specified if model is loaded in a fresh session. #461Change default in
get_index()etc. tobias_correct = TRUE. This is the recommended setting for final inference and speed improvements within TMB have made it more viable to include the bias correction by default. #456Only retain Newton update parameters if they improve the objective function. #455
Only run Newton updates if maximum absolute gradient is
>= 1e-9to save time. #455Suppress
nlminb()warnings by default, which can usually be ignored by the user and may be confusing. This can be controlled viasdmTMB(..., control = sdmTMBcontrol(suppress_nlminb_warnings = FALSE)). This option now mirrors tinyVAST.Round time-varying AR(1) rho to 2 decimals in model printing/summary.
sdmTMB 0.7.2
CRAN release: 2025-06-19
New features
Add deviance residuals (
residuals(fit, type = "deviance")) anddeviance.sdmTMB()method (deviance(fit)). Proportion deviance explained can be calculated as1 - deviance(fit) / deviance(fit_null)wherefit_nullis a null model, e.g., fit withformula = ~ 1and turning off any random fields as desired (e.g.,spatial = "off", spatiotemporal = "off").Add
observation_errorargument tosimulate.sdmTMB()to allow turning off observation error simulation. The intended use-case is for simulating from random effects but not adding observation error. #431
Minor improvements and fixes
Change the default in
dharma_residuals()totest_uniformity = FALSE. Based on simulation testing, we generally do not recommend using these p-values to reject models.Fix a bug introduced in version 0.7.0 where printing of the 2nd linear predictor smoother fixed effects (
bs) was accidentally a copy of the 1st linear predictor smoother fixed effects.Fix bug in simulation with time-varying AR(1) when using the
project()function. Thanks to A. Allyn for pointing out the bug.Fix reporting of converged models with
sdmTMB_cv(). A recent change resulted in reporting only 1 model converged if all models converged.Remove warning about old default residuals type.
Fix
project()andsimulate.sdmTMB(..., newdata = ...)when random intercepts/slopes are present. #431Remove extra TMB data slots for
project()andsimulate.sdmTMB(..., newdata = ...)to save memory. #431
sdmTMB 0.7.0
CRAN release: 2025-04-01
New features
Add option for random slopes, or random intercepts to be passed in in
lme4style formulas,density ~ (1 | fyear)ordensity ~ (depth | fyear), Matches output oflme4andglmmTMB, and summarizes output withtidy().Add
project()experimental function.Add
get_eao()to calculate effective area occupied.Add priors for
breakpt()andlogistic()parameters. #403Add priors on time-varying SD parameters (
sigma_V).Add
cAIC()for calculating conditional AIC. Theory based on https://arxiv.org/abs/2411.14185; also see https://doi.org/10.1002/ecy.4327. J.T. Thorson wrote the function code. EDF (effective degrees of freedom) will ultimately be further split (e.g., split by smoothers) and added tosummary.sdmTMB(). #383 #387Add EDF (effective degrees of freedom) printing to smoothers with
print.sdmTMB()andsummary.sdmTMB(). Set argumentedf = TRUE. E.g.print(fit, edf = TRUE). #383 #387At experimental function
get_index_split(), which takes care of splitting a prediction grid by time, undoing the prediction and area-integration index calculations for each chunk to save memory.Add
newdataargument tosimulate.sdmTMB(). This enables simulating on a new data frame similar to how one would predict on new data.Add
mle_mvn_samplesargument tosimulate.sdmTMB(). Defaults to “single”. If “multiple”, then a sample from the random effects is taken for each simulation iteration.Allow for specifying only lower or upper limits. #394
sdmTMB_cv()gains atidy()andprint()method for output. #319simulate.sdmTMB()method now has anreturn_tmb_reportargument.
New vignettes/articles
Add forecasting and presence-only article vignettes. See https://sdmTMB.github.io/sdmTMB/articles/
Add vignette on multispecies models with sdmTMB (or any case where one wants additional spatial and or spatiotemporal fields by some group). See https://sdmTMB.github.io/sdmTMB/articles/
Minor improvements and fixes
Add a useful error if memory error occurs on index calculation.
Fix bug in a check in
make_mesh()around if coordinates look overly large. #427Re-enable bias correction for
get_cog()(get center of gravity).Add check for
Inf/-Infvalues before fitting. #408Add time varying AR(1) correlation to
tidy()andprint(). #374Warn if parameter limits are set with
newton_loops > 0. #394Fix bug in
estcolumn when predicting on new data with Poisson-link delta models withtype = "link"andre_form = NA. #389Fix bug in
s95parameter reporting from thetidy()method.s95is present in the logistic threshold models. The model itself was fine but thes95parameter was supposed to be reported bytidy()as a combination of two other parameters. This also affected the output inprint()/summary().Add progress bar to
simulate.sdmTMB(). #346Add AUC and TSS examples to cross validation vignette. #268
Add
model(linear predictor number) argument tocoef()method. Also, write documentation for?coef.sdmTMB. #351Add helpful error message if some coordinates in
make_mesh()areNA. #365Add informative message if fitting with an offset but predicting with offset argument left at
NULLonnewdata. #372Fix passing of
offsetargument through insdmTMB_cv(). Before it was being omitted in the prediction (i.e., set to 0). #372Fig bug in
exponentiateargument fortidy(). Setconf.int = TRUEas default. #353Fix bug in prediction from
delta_truncated_nbinom1()anddelta_truncated_nbinom2()families. The positive component needs to be transformed to represent the mean of the untruncated distribution first before multiplying by the probability of a non-zero. Thanks to @tom-peatman #350Add option for
areato be passed in as the name of a column in the data frame to be used for area weighting. Used inget_index(),get_cog(),get_eao(), etc.
sdmTMB 0.6.0
CRAN release: 2024-05-29
Pass several arguments to
DHARMa::plotQQunif().Add
silentoption insimulate.sdmTMB(). Setting it toFALSEallows monitoring simulations from larger models.-
Fix bug in
est_non_rf1andest_non_rf2columns when all the following conditions were true:- predicting on new data
- using a delta model
- including IID random intercepts or time-varying coefficients See #342. Thanks to @tom-peatman for the issue report.
Fix delta-gamma binomial link printing for
type = 'poisson-link'#340Add suggestion to use an optimized BLAS library to README.
Add warning if it’s detected that there were problems reloading (e.g., with
readRDS()) a fitted model. Simultaneously revert the approach to how reloaded models are reattached.Move
log_ratio_mixparameter to 2nd phase with starting value of -1 instead of 0 to improve convergence.Fix bugs for
nbinom1()andnbinom2_mix()simulation.Allow
profileargument in the control list to take a character vector of parameters. This move these parameters from the outer optimization problem to the inner problem (but omits from the from the Laplace approximation). See documentation in TMB. This can considerably speed up fitting models with many fixed effects.Add theoretical quantile residuals for the generalized gamma distribution. Thanks to J.C. Dunic. #333
Add
"poisson-link"option to delta-mixture lognormal.Fix bug in simulation from Poisson-link delta models.
Simplify the internal treatment of extra time slices (
extra_time). #329 This is much less bug prone and also fixes a recently introduced bug. #335 This can slightly affect model results compared to the previous approach if extra time was used along with smoothers since the ‘fake’ extra data previously used was included when mgcv determined knot locations for smoothers.
sdmTMB 0.5.0
CRAN release: 2024-04-03
Overhaul residuals vignette (‘article’) https://sdmTMB.github.io/sdmTMB/articles/residual-checking.html including brief intros to randomized quantile residuals, simulation-based residuals, ‘one-sample’ residuals, and uniform vs. Gaussian residuals.
Add check if prediction coordinates appear outside of fitted coordinates. #285
Fix memory issue with Tweedie family on large datasets. #302
Add experimental option to return standard normal residuals from
dharma_residuals().Make
simulate.sdmTMB()not includeextra_timeelements.Improved re-initialization of saved fitted model objects in new sessions.
Fix important bug in
simulate.sdmTMB()method for delta families where the positive linear predictor was only getting simulated for observations present in the fitted data.Add new
"mle-mvn"type toresiduals.sdmTMB()and make it the default. This is a fast option for evaluating goodness of fit that should be better than the previous default. See the details section in?residuals.sdmTMBfor details. The previous default is now called"mvn-eb"but is not recommended.Bring
dharma_residuals()back over from sdmTMBextra to sdmTMB. Add a new option in thetypeargument ("mle-mvn") that should make the simulation residuals consistent with the expected distribution. See the same new documentation in?residuals.sdmTMB. The examples in?dharma_residualsillustrate suggested use.Fix bug in
sanity()where gradient checks were missingabs()such that large negative gradients weren’t getting caught. #324Return
offsetvector in fitted object as an element. Ensure any extra time rows of data in thedataelement of the fitted object do not include the extra time slices.Add experimental residuals option “mle-mvn” where a single approximate posterior sample of the random effects is drawn and these are combined with the MLE fixed effects to produce residuals. This may become the default option.
Add the generalized gamma distribution (thanks to J.T. Thorson with additional work by J.C. Dunic.) See
gengamma(). This distribution is still in a testing phase and is not recommended for applied use yet. #286Detect possible issue with factor(time) in formula if same column name is used for
timeandextra_timeis specified. #320Improve
sanity()check output when there are NA fixed effect standard errors.Set
intern = FALSEwithin index bias correction, which seems to be considerably faster when testing with most models.
sdmTMB 0.4.3
CRAN release: 2024-02-29
-
Fix a bug likely introduced in July 2023 that caused issues when
extra_timewas specified. This is an important bug and models fit withextra_timebetween that date (if using the GitHub version) and v0.4.2.9004 (2024-02-24) should be checked against a current version of sdmTMB (v0.4.2.9005 or greater). On CRAN, this affected v0.4.0 (2023-10-20) to v0.4.2. Details:- The essence of the bug was that
extra_timeworks by padding the data with a fake row of data for every extra time element (using the first row of data as the template). This is supposed to then be omitted from the likelihood so it has no impact on model fitting beyond spacing time-series processes appropriately and setting up internal structures for forecasting. Unfortunately, a bug was introduced that caused these fake data (1 per extra time element) to be included in the likelihood.
- The essence of the bug was that
Fix bug in
get_cog(..., format = "wide")where the time column was hardcoded to"year"by accident.Poisson-link delta models now use a
typeargument indelta_gamma()anddelta_lognormal().delta_poisson_link_gamma()anddelta_poisson_link_lognormal()are deprecated. #290Delta families can now pass links that are different from the default
"logit"and"log". #290
sdmTMB 0.4.2
CRAN release: 2024-01-18
Force rebuild of CRAN binaries to fix issue with breaking Matrix ABI change causing
NaN gradienterrors. #288 #287Fix crash in if
sdmTMB(..., do_index = TRUE)andextra_timesupplied along withpredict_args = list(newdata = ...)that lackedextra_timeelements.Allow
get_index()to work with missing time elements.Add the ability to pass a custom randomized quantile function
qres_functoresiduals.sdmTMB().Add check for factor random intercept columns in
newdatato avoid a crash. #278 #280Improve warnings/errors around use of
do_index = TRUEandget_index()ifnewdata = NULL. #276Fix prediction with
offsetwhennewdataisNULLbutoffsetis specified. #274Fix prediction failure when both
offsetandnsimare provided and model includesextra_time. #273
sdmTMB 0.4.1
CRAN release: 2023-11-03
Fix memory issues detected by CRAN ‘Additional issues’ clang-UBSAN, valgrind.
Fix a bug predicting on new data with a specified offset and
extra_time. #270Add warning around non-factor handling of the
spatial_varyingformula. #269Add experimental
set_delta_model()for plotting delta models withggeffects::ggpredict()(GitHub version only until next CRAN version).
sdmTMB 0.4.0
CRAN release: 2023-10-20
Move add_barrier_mesh() to sdmTMBextra to avoid final INLA dependency. https://github.com/sdmTMB/sdmTMBextra
Switch to using the new fmesher package for all mesh/SPDE calculations. INLA is no longer a dependency.
Switch to
diagonal.penalty = FALSEin mgcv::smoothCon(). This changes the scale of the linear component of the smoother, but should result in the same model. https://github.com/glmmTMB/glmmTMB/issues/928#issuecomment-1642862066Implement cross validation for delta models #239
Remove ELPD from cross validation output. Use sum_loglik instead. #235
Turn on Newton optimization by default. #182
print() now checks sanity() and issues a warning if there may be issues. #176
Poisson-link delta models and censored likelihood distributions have been made considerably more robust. #186
Standard errors are now available on SD parameters etc. in tidy() #240
Fix bug in print()/tidy() for delta-model positive model component sigma_E. A recently introduce bug was causing sigma_E for the 2nd model to be reported as the 1st model component sigma_E.
Add new anisotropy plotting function.
sdmTMB 0.3.0
CRAN release: 2023-01-28
Create the sdmTMBextra package to remove rstan/tmbstan helpers, which were causing memory sanitizer errors on CRAN. https://github.com/sdmTMB/sdmTMBextra
-
The following functions are affected:
-
predict.sdmTMB()now takesmcmc_samples, which is output fromsdmTMBextra::extract_mcmc(). -
simulate.sdmTMB()now takesmcmc_samples, which is output fromsdmTMBextra::extract_mcmc(). -
residuals.sdmTMB()now takesmcmc_samples, which is outputsdmTMBextra::predict_mle_mcmc(). This only affectsresiduals(..., type = "mle-mcmc").
-
Move
dharma_residuals()to sdmTMBextra to reduce heavy dependencies.See examples in the Bayesian and residuals vignettes or in the help files for those functions within sdmTMBextra.
sdmTMB 0.2.2
Various fixes to pass CRAN checks. #158
Fix memory issue highlighted by Additional issues CRAN checks. #158
‘offset’ argument can now be a character value indicating a column name. This is the preferred way of using an offset with parallel cross validation. #165
Fix parallel cross validation when using an offset vector. #165
Add leave-future-out cross validation functionality. #156
Example data
qcs_gridis no longer replicated by year to save package space. #158Add message with
tidy(fit, "ran_pars")about why SEs are NA.Fix
predict(..., type = "response", se_fit = TRUE), which involves issuing a warning and sticking to link space. #140
sdmTMB 0.1.4
Relax range parameter
sanity()check from 1x to 1.5x the greatest distance in the data.Add Pearson residuals for several families.
residuals(fit, type = "pearson")Useful for checking for overdispersion with N > 1 binomial or Poisson families, among other uses. See theoverdisp_fun()function at: https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#testing-for-overdispersioncomputing-overdispersion-factorFix bug when using
residuals()orsimulate()with binomial families specified viacbind()orweights = N. The binomial sample size wasn’t being passed through typically resulting in Inf/-Inf.Add mixture families:
gamma_mix(),lognormal_mix()and associated delta/hurdle families:delta_gamma_mix(),delta_lognormal_mix(). These families feature a mixture of two distributions with different means but shared variance parameters.Add
delta_beta()family.
sdmTMB 0.1.3
Tweak
sanity()checking of standard error size.Export previously experimental
plot_anisotropy()function. The old function is nowplot_anisotropy2().Allow passing offset data through
predict.sdmTMB()viaoffsetargument.
sdmTMB 0.1.2
Switch
effects = 'ran_vals'for random intercept values fromtidy.sdmTMB()to match the broom.mixed package.Make
tidy.sdmTMB()return a tibble if the tibble package is installed. Note this could affect old code sincedrop = FALSEis the default for tibbles butdrop = TRUEis the default for data frames (i.e., tibbles always return a data frame when subsetted).Fix longstanding issue with predicting on newdata with mgcv’s
t2(). Previously this was disabled because of issues. It now works as expected.Add
knotsargument insdmTMB(), which is passed to mgcv. A common use would be to specify end points in a cyclical spline (e.g.,s(x, bs = 'cc', k = 4), knots = list(x = c(1, 3, 5, 7))) when the data don’t extend fully to the boundaries that should match up.
sdmTMB 0.1.1
Preparing for release on CRAN.
Add time-varying AR1 option (originally was always a random walk). See
time_varying_typeargument in?sdmTMB.Allow prediction on
newdatawith missing time elements. #130Add check for
offset()(which does not work in sdmTMB, use theoffsetargument instead). #131Add check for random slopes (sdmTMB currently only does random intercepts, although slopes can vary spatially). #131
sdmTMB 0.1.0
ADREPORT several parameters in natural space. https://github.com/sdmTMB/sdmTMB/discussions/113
Improve robustness of model
print()to more esoteric mgcv smoothers.Let
sims_varwork with multiple spatially varying slopes (zeta_s); return output in named list by coefficients. #107Add
threshold_coefstosdmTMB_simulate().Don’t make a fake mesh for non-spatial model (faster).
sdmTMB 0.0.26.9001
Add vignettes on visreg, ggeffects, and delta families (thanks J. Indivero!) #83 #87 #89 Forecasting and presence-only vignettes to be merged in soon.
Add support for emmeans package. See
?emmeans.sdmTMBfor examples.Add support for effects package. The
ggeffects::ggeffect()function can be used to make fast marginal effects plots.ggeffects::ggpredict()works with a custom fork of ggeffects. A pull request will be made shortly. #101Add
vcov(),fixef(),df.residual(),formula(),terms(), andmodel.frame()methods.Add support for
"cloglog"link. Code adapted from glmmTMB for robust likelihood implementation.For delta models, by default share the anisotropy parameters as in VAST. Separate anisotropy (old behavior) can be estimated with
control = sdmTMBcontrol(map = list(ln_H_input = factor(c(1, 2, 3, 4))))Add experimental
do_index,predict_args, andindex_argsinsdmTMB(). These can be used to perform prediction and index calculation at the same time as fitting. For very large datasets or meshes this can save time compared to fitting, predicting, and index calculation in 3 separate steps since the TMB AD object doesn’t have to be rebuilt. This will somewhat slow down the initial fitting.Remove
max_gradientandbad_eigfromget_index()output.Use unique locations on prediction for huge speedups on large
newdatagridded data.Fix bug where in rare cases
get_index()would return gibberish small values.Add
bayesianargument, which whenTRUEadds Jacobian adjustments for non-linear transformed parameters. This should beTRUEif the model will be passed to tmbstan, butFALSEotherwise. #95Add experimental and not-yet-exported
sdmTMB:::plot_anisotropy2().Add many anisotropy, delta model, and index calculation unit tests.
sdmTMB 0.0.24.9001
Enable random walk random field TMB simulation in
sdmTMB_simulate().Add check for irregular time with AR1 or random walk processes.
Fix bugs introduced by delta model code (offsets with
extra_timeand threshold model prediction).Fix bug in
sanity()message with small random field SDs.
sdmTMB 0.0.24.9000
Add support for ‘delta’ (or ‘hurdle’) models. See examples and documentation in
?sdmTMB. This has resulted in a substantial restructuring of the internal model code. By default both model components (e.g., binomial & Gamma) share the same formula, spatial, and spatiotemporal structure, but these can be separated by supplying argument values in lists where the first element corresponds to the first model and the second element corresponds to the second model (with some limitations as described in?sdmTMBdocumentation ‘Details’).Add support for multiple spatially varying coefficients (used to be limited to a single variable).
Add compatibility with the ‘visreg’ package for visualizing conditional effects of parameters. See
?visreg_deltafor examples.Add MCMC residual type to
residuals.sdmTMB(). These are a ‘better’ residuals but slower to calculate. See documentation ‘Details’ in?residuals.sdmTMB.Make
offsetan argument insdmTMB(). Using the reserved wordoffsetin the formula is now deprecated.Add
sanity()function to perform some basic sanity checks on model fits.Make an
sdmTMB()model object compatible withupdate()method.Remove several deprecated arguments.
Overhaul examples in
?sdmTMB.Use faster “low-rank sparse hessian bias-correction” TMB bias correction.
Add parallel processing support. See
parallelargument insdmTMBcontrol. By default, grabs value ofsdmTMB.coresoption. E.g.options(sdmTMB.cores = 4). Only currently enabled on Mac/Linux. Using too many cores can be much slower than 1 core.Use ‘cli’ package
cli_abort()/cli_warn()/cli_inform()overstop()/warning()/message().Add many unit tests.
sdmTMB 0.0.23.9000
- A package version number that was used for internal testing in the ‘delta’ branch by several people.
sdmTMB 0.0.22.9000
- Fix bug in predictions with
poly(..., raw = FALSE)on newdata. #77
sdmTMB 0.0.21.9009
Add experimental
sdmTMB_stacking()for ensemble model stacking weights.Add fake mesh if random fields are all off. #59
Make
predict(..., newdata = NULL)also uselast.par.bestinstead oflast.parto matchnewdata = df.Fix bug in MVN fixed-effect prior indexing
simsandn_simsarguments have been deprecated and standardized tonsimto match thesimulate()S3 method.Bias correction on
get_index()andget_cog()is now selective and is just applied to the necessary derived parameters.INLA projection matrix ‘A’ is now shared across spatial and spatiotemporal fields.
Add
add_utm_columns()to ease adding UTM columns.
sdmTMB 0.0.20.9001
Add
dharma_residuals().Fix bug in
simulate.sdmTMB()andresiduals.sdmTMB()for binomial family.
sdmTMB 0.0.20.9000
Smoothers now appear in
print()output. The format should roughly match brms. The main-effect component (e.g.,sdepthfors(depth)) represents the linear component and the random effect (e.g.,sds(depth)) component in the output corresponds to the standard deviation of the penalized weights.Add
censored_poisson(link = 'log')family; implemented by @joenomiddlenamefieldsinsdmTMB()is now deprecated and replaced byspatiotemporal.include_spatialinsdmTMB()is now deprecated and replaced byspatial.spatial_onlyinsdmTMB()is now deprecated and replaced byspatiotemporal. E.g.spatial_only = TRUEis nowspatiotemporal = 'off'or leavingtime = NULL.spdeinsdmTMB()is now deprecated and replaced bymesh.sdmTMB_simulate()is new and will likely replacesdmTMB_sim()eventually.sdmTMB_simulate()is set up to take a formula and a data frame and is easier to use if you want different spatial observations (and covariates) for each time slice. It can also take a fitted model and modify parts of it to simulate. Finally, this function uses TMB for simulation and so is much faster and more flexible in what it can simulate (e.g., anisotropy) than the previous version.spatial_trendis nowspatial_varyingand accepts a one-sided formula with a single predictor of any coefficient that should varying in space as a random field. Note that you may want to include a fixed effect for the same variable to improve interpretability. If the (scaled) time column is used, it will represent a local-time-trend model as before.The Tweedie power (p) parameter is now in
print()andtidy()output.thetafis nowtweedie_pinsdmTMB_sim().
sdmTMB 0.0.19.9002
- Simulation from the parameter covariance matrix works if random effects are turned off. #57
sdmTMB 0.0.19.9000
- Smoothers
s()are now penalized smoothers: they determine the degree of wiggliness (as in mgcv) and it is no longer necessary to choose an appropriatekvalue a priori. Models fit with previous versions of sdmTMB withs(x, k = ...)will not match models specified the same way in version >= 0.0.19 since the basis functions are now penalized. All the variousmgcv::s()options should be supported butt2()(andti()andte()) are not supported.
sdmTMB 0.0.18.9001
Add ELPD (expected log predictive density) to
sdmTMB_cv()https://arxiv.org/abs/1507.04544Fix bug evaluating
...whensdmTMB_cv()was called within a function. #54
sdmTMB 0.0.17.9000
Add random walk option:
fields = "RW".Depreciate
ar1_fieldsargument. See newfieldsargument in `sdmTMB().Many packages moved from ‘Imports’ to ‘Suggests’
sdmTMB 0.0.16.9000
Lower default
nlminb()eval.maxanditer.maxto 1000 and 2000.Added
profileoption insdmTMBcontrol(). This can dramatically improve model fitting speed with many fixed effects. Note the result is likely to be slightly different withTRUEvs.FALSE.Added simulation from the MVN precision matrix to
predict.sdmTMB(). See thesimsargument.Added
gather_sims()andspread_sims()to extract parameter simulations from the joint precision matrix in a format that matches the tidybayes package.Added
get_index_sims()for a population index calculated from the MVN simulation draws.Added
extract_mcmc()to extract MCMC samples if the model is passed to tmbstan.Added the ability to predict from a model fitted with tmbstan. See the
tmbstan_modelargument inpredict.sdmTMB().Allowed for separate random field Matern range parameters for spatial and spatiotemporal fields. E.g.
sdmTMB(shared_range = FALSE)Bounded the AR1 rho parameter between -0.999 and 0.999 to improve convergence; was -1 to 1. Please post an issue if this creates problems for your model.
Added
map,start,lower, andupperoptions to control model fitting. SeesdmTMBcontrol().Added priors for all parameters. See
?sdmTMB::priorsand thepriorsargument insdmTMB(). PC priors are available for the random fields. See?pc_maternand the details there.Moved many less-common arguments from
sdmTMB()tosdmTMBcontrol().Fix bug in
sdmTMB_cv()where fitting and testing data splits were reversed. I.e., the small chunk was fit; the big chunk was tested.
sdmTMB 0.0.15.9000
Added experimental penalized complexity (PC) prior as used in INLA. See arguments
matern_prior_Oandmatern_prior_E.Added back
normalizeargument tosdmTMB()and default toFALSE. Setting toTRUEcan dramatically speed up some model fits (~4 times for some test models).
sdmTMB 0.0.14.9001
- Added some protections for possible user errors:
- AR1 with a spatial-only model
- Missing factor levels in time
- Coordinate systems that are too big
sdmTMB 0.0.14.9000
Add
re_form_iidtopredict.sdmTMB().Add
map_rfoption tosdmTMB(). This lets you map (fix at their starting values of zero) all random fields to produce a classic GLM/GLMM.
sdmTMB 0.0.13.9000
- Add IID random intercepts interface. E.g.
... + (1 | g)#34
sdmTMB 0.0.12.9000
- Add
epsilon_predictorargument insdmTMB()to allow a model of the spatiotemporal variance through time.
sdmTMB 0.0.10.9000
Fixed parameter initialization for inverse links #35
Switched Gamma ‘phi’ parameter to representing shape instead of CV to match glm(), glmmTMB(), etc.
sdmTMB 0.0.9.9000
- Switched the density/abundance index calculation to use the link function as opposed to a hardcoded log() so that the
get_generic()function can be used to grab things like standardized average values of the response across a grid. What used to belog_totalin the raw TMB output is nowlink_totalbut most users you shouldn’t notice any difference.
sdmTMB 0.0.8.9000
Overhauled the simulation function. The function is now called
sdmTMB_sim()and uses INLA functions instead of RandomFields functions for simulating the random fields.The simulation function can now accommodate all families and links and takes an INLA mesh as input.
sdmTMB 0.0.7.9001
- Allow specifying degrees of freedom in the Student-t family #29
sdmTMB 0.0.7.9000
Added a
tidy()method (from broom and broom.mixed) to return a data frame of parameter estimates. The function can extract the fixed effects or the random effect parameters (variances, AR1 correlation, spatial range).Added an argument
extra_timetosdmTMB(). This introduces additional time slices that you can then predict on if you want to interpolate or forecast. Internally, it uses Eric Ward’s ‘weights hack’. This is also useful if you have data unevenly spaced in time and you want the gaps evenly spaced for a random walk or AR1 process (add any missing years toextra_time).make_spde()is now replaced withmake_mesh()andmake_spde()has been soft deprecated.make_mesh()carries through the x and y column names to the predict function and is more in line with the tidyverse style of taking a data frame first.make_mesh()can acceptcutoffas an argument (as in INLA), which is likely a better default way to specify the mesh since it scales across regions better and is line with the literature on INLA.make_mesh()can use a binary search algorithm to find a cutoff that best matches a desired number of knots (thanks to Kelli Johnson for the idea).Barrier meshes are now possible. See
add_barrier_mesh()for an example.There is a pkgdown website now that gets auto generated with GitHub actions.
There is the start of a model description vignette. It is very much a work in progress.
sdmTMB 0.0.6.9005
- Fixed bug in predictions with standard errors where one(?) parameter (a breakpoint parameter) would be passed in at its initial instead of MLE value.
sdmTMB 0.0.6.9004
Fixed bug with predictions on new data in models with break points
-
Overhauled cross validation function. The function now:
- uses Eric’s weights hack so it can also be used for forecasting
- initializes subsequent folds at the MLE of the first fold for considerable speed increases
- works in parallel if a future plan initialized; see examples
Added threshold parameters to the print method
Added forecasting example with the weights hack
Fixed bug in linear break point models
sdmTMB 0.0.6.9002
Fixed GAM predictions with all 0s in new data.
Add linear and logistic threshold models. #17
sdmTMB 0.0.5.9000
Added parsing of mgcv formulas for splines. #16
Added ability to predict with standard errors at the population level. This helps with making marginal-effect plots. #15
Added optimization options to aid convergence. Also added
run_extra_optimization()to run these on already fit models. Default is for no extra optimization.Added binomial likelihood to cross validation. Git hash
ee3f3ba.Started keeping track of news in
NEWS.md.
