Turn sdmTMB model output into a tidy data frame
Output from sdmTMB()
.
A character vector including one or more of "fixed"
(fixed-effect parameters), "ran_pars" (standard deviations, spatial range,
and other random effect and dispersion terms), or "ranef" (individual random
intercepts, if included -- behaves like ranef()
).
Which model to tidy if a delta model (1 or 2).
Include a confidence interval?
Confidence level for CI.
Whether to exponentiate the fixed-effect coefficient estimates and confidence intervals.
Extra arguments (not used).
A data frame
Follows the conventions of the broom and broom.mixed packages.
Currently, effects = "ran_pars"
also includes dispersion-related terms
(e.g., phi
), which are not actually random effects.
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.
fit <- sdmTMB(density ~ poly(depth_scaled, 2, raw = TRUE),
data = pcod_2011, mesh = pcod_mesh_2011,
family = tweedie()
)
tidy(fit)
#> term estimate std.error
#> 1 (Intercept) 3.649391 0.2813973
#> 2 poly(depth_scaled, 2, raw = TRUE)1 -1.538960 0.1859669
#> 3 poly(depth_scaled, 2, raw = TRUE)2 -1.111444 0.1013527
tidy(fit, conf.int = TRUE)
#> term estimate std.error conf.low conf.high
#> 1 (Intercept) 3.649391 0.2813973 3.097862 4.200920
#> 2 poly(depth_scaled, 2, raw = TRUE)1 -1.538960 0.1859669 -1.903449 -1.174472
#> 3 poly(depth_scaled, 2, raw = TRUE)2 -1.111444 0.1013527 -1.310091 -0.912796
tidy(fit, "ran_pars", conf.int = TRUE)
#> term estimate std.error conf.low conf.high
#> 1 range 19.137003 NA 4.5803807 79.955116
#> 3 phi 14.047899 NA 12.7824400 15.438638
#> 4 sigma_O 2.141805 NA 0.9056509 5.065228
#> 5 tweedie_p 1.580328 NA 1.5501157 1.609950