Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to turn off spatial/spatiotemporal fields if they 'collapse' #263

Open
seananderson opened this issue Oct 12, 2023 · 1 comment

Comments

@seananderson
Copy link
Member

Might need options:

  • turn off (set to zero) any that collapse
  • turn off spatial if any collapse
  • turn off spatiotemporal if any collapse

Warn user if it happens.

@ericward-noaa
Copy link
Collaborator

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()

png_1

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()

png2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants