set_delta_model | R Documentation |
ggeffects::ggpredict()
Set a delta model component to predict from with ggeffects::ggpredict()
.
set_delta_model(x, model = c(NA, 1, 2))
x |
An |
model |
Which delta/hurdle model component to predict/plot with.
|
A complete version of the examples below would be:
fit <- sdmTMB(density ~ poly(depth_scaled, 2), data = pcod_2011, spatial = "off", family = delta_gamma()) # binomial part: set_delta_model(fit, model = 1) |> ggeffects::ggpredict("depth_scaled [all]") # gamma part: set_delta_model(fit, model = 2) |> ggeffects::ggpredict("depth_scaled [all]") # combined: set_delta_model(fit, model = NA) |> ggeffects::ggpredict("depth_scaled [all]")
But cannot be run on CRAN until a version of ggeffects > 1.3.2 is on CRAN. For now, you can install the GitHub version of ggeffects. https://github.com/strengejacke/ggeffects.
The fitted model with a new attribute named delta_model_predict
.
We suggest you use set_delta_model()
in a pipe (as in the examples)
so that this attribute does not persist. Otherwise, predict.sdmTMB()
will choose this model component by default. You can also remove the
attribute yourself after:
attr(fit, "delta_model_predict") <- NULL
fit <- sdmTMB(density ~ poly(depth_scaled, 2), data = pcod_2011,
spatial = "off", family = delta_gamma())
# binomial part:
set_delta_model(fit, model = 1)
# gamma part:
set_delta_model(fit, model = 2)
# combined:
set_delta_model(fit, model = NA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.