Skip to content

How do you obtain and display a spline in the sdmTMB model object? #272

Answered by seananderson
dpanzeri asked this question in Q&A
Discussion options

You must be logged in to vote

Here's an example below.

Note the example is about the 'delta' or hurdle families. For non-delta families you can skip the visreg_delta() part and use visreg::visreg() directly and skip set_delta_model() and use ggeffects::ggpredict() directly.

Also note that these examples require the latest sdmTMB (0.4.1 or the GitHub version).

library(sdmTMB)
library(ggplot2)

fit_dg <- sdmTMB(
  density ~ s(depth_scaled, k = 3),
  data = pcod_2011,
  spatial = "off",
  family = delta_gamma()
)

# with visreg:
visreg_delta(fit_dg, xvar = "depth_scaled", model = 1, gg = TRUE)
#> These are residuals for delta model component 1. Use the `model` argument to
#> select the other component.

visreg_delta(fit_dg

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by seananderson
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants