Open seananderson opened 10 months ago
Similarly, I was wondering if it'd be worth throwing a warning for spatiotemporal delta models in cases where there's no variation in the data. Especially for rare species, some time slices might not have any variation. Example:
mesh <- make_mesh(pcod, c("X", "Y"), cutoff = 20)
pcod$density[which(pcod$year==2005)] = 0
# model fits fine
fit <- sdmTMB(
density ~ s(depth),
data = pcod, mesh = mesh,
family = delta_gamma(),
time="year",
spatiotemporal = "iid"
)
pred <- predict(fit, pcod) # predict all
The presence-absence field is shifted down (and unclear why there's any variation)
# plot spatial fields of presence-absence --
dplyr::filter(pred, year < 2009) %>%
ggplot(aes(X,Y,col=est_rf1)) +
geom_point() +
facet_wrap(~year) +
scale_color_gradient2()
And as expected the positive model is ~ 0 with little variation compared to other years
dplyr::filter(pred, year < 2009) %>%
ggplot(aes(X,Y,col=est_rf2)) +
geom_point() +
facet_wrap(~year) +
scale_color_gradient2()
Might need options:
Warn user if it happens.