| tidy.sdmTMB | R Documentation |
Turn sdmTMB model output into a tidy data frame
## S3 method for class 'sdmTMB'
tidy(
x,
effects = c("fixed", "ran_pars", "ran_vals", "ran_vcov", "rsr", "dispersion"),
model = 1,
conf.int = TRUE,
conf.level = 0.95,
exponentiate = FALSE,
silent = FALSE,
...
)
## S3 method for class 'sdmTMB_cv'
tidy(x, ...)
x |
Output from |
effects |
A character value. One of |
model |
Which model to tidy if a delta model (1 or 2). The |
conf.int |
Include a confidence interval? |
conf.level |
Confidence level for CI. |
exponentiate |
Whether to exponentiate the fixed-effect coefficient estimates and confidence intervals. |
silent |
Omit any messages? |
... |
Extra arguments (not used). |
Follows the conventions of the broom and broom.mixed packages.
Currently, effects = "ran_pars" also includes dispersion-related terms
(e.g., phi) only when dispersion is scalar. With dispformula,
use effects = "dispersion" to extract dispersion-model coefficients.
Time-varying coefficients (from the time_varying argument in sdmTMB())
are returned with effects = "ran_vals", one row per coefficient and time
slice, with terms named "<coefficient>:<time>" (e.g., "(Intercept):2011").
These are on the link scale. Their standard deviation (sigma_V) and, for
time_varying_type = "ar1", correlation (rho_time) are returned with
effects = "ran_pars".
Standard errors for spatial variance terms fit in log space (e.g., variance terms, range, or parameters associated with the observation error) are omitted to avoid confusion. Confidence intervals are still available.
A data frame
Restricted Spatial Regression (effects = "rsr"):
Diaz, R.R., and Thorson, J.T. 2025. When and How to Use Restricted Spatial Regression to Separate Environmental Effects from Spatial Confounding. EcoEvoRxiv. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.32942/X28351")}.
Hanks, E.M., Schliep, E.M., Hooten, M.B., and Hoeting, J.A. 2015. Restricted spatial regression in practice: geostatistical models, confounding, and robustness under model misspecification. Environmetrics 26(4): 243–254. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1002/env.2331")}.
fit <- sdmTMB(density ~ poly(depth_scaled, 2, raw = TRUE),
data = pcod_2011, mesh = pcod_mesh_2011,
family = tweedie()
)
tidy(fit)
tidy(fit, conf.int = TRUE)
tidy(fit, "ran_pars", conf.int = TRUE)
pcod_2011$fyear <- as.factor(pcod_2011$year)
fit <- sdmTMB(density ~ poly(depth_scaled, 2, raw = TRUE) + (1 | fyear),
data = pcod_2011, mesh = pcod_mesh_2011,
family = tweedie()
)
tidy(fit, "ran_vals")
# time-varying coefficients:
fit <- sdmTMB(density ~ 0, time_varying = ~ 1, time = "year",
data = pcod_2011, mesh = pcod_mesh_2011, family = tweedie(),
spatiotemporal = "off"
)
tidy(fit, "ran_vals", conf.int = TRUE)
tidy(fit, "ran_pars")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.