pbs-assess / sdmTMB

:earth_americas: An R package for spatial and spatiotemporal GLMMs with TMB
https://pbs-assess.github.io/sdmTMB/
183 stars 26 forks source link

Check poisson-link delta models #186

Closed seananderson closed 1 year ago

seananderson commented 1 year ago

Check against VAST. Check for anything that could still be causing under/overflows. Models frequently fall into optimization problems and are slower than I'd expect.

seananderson commented 1 year ago

These are now robust and match VAST exactly (local tests for future reference). We should probably add a vignette because the connection between the linear predictors and inverse-linked predictors is unique. At the very least, these need more explanation in the model description vignette.

library(sdmTMB)
fit <- sdmTMB(
  density ~ 1,
  data = pcod, 
  mesh = make_mesh(pcod, c("X", "Y"), cutoff = 10),
  family = delta_poisson_link_gamma(), 
)
summary(fit)
#> Spatial model fit by ML ['sdmTMB']
#> Formula: density ~ 1
#> Mesh: make_mesh(pcod, c("X", "Y"), cutoff = 10) (isotropic covariance)
#> Data: pcod
#> Family: delta_poisson_link_gamma(link1 = 'log', link2 = 'log')
#> 
#> Delta/hurdle model 1: -----------------------------------
#> Family: binomial(link = 'log') 
#>             coef.est coef.se
#> (Intercept)     -0.6    0.29
#> 
#> Matérn range: 32.44
#> Spatial SD: 1.48
#> 
#> Delta/hurdle model 2: -----------------------------------
#> Family: Gamma(link = 'log') 
#>             coef.est coef.se
#> (Intercept)     3.69    0.11
#> 
#> Dispersion parameter: 0.75
#> Matérn range: 8.72
#> Spatial SD: 1.58
#> 
#> ML criterion at convergence: 6381.834
#> 
#> See ?tidy.sdmTMB to extract these values as a data frame.

fit <- sdmTMB(
  density ~ 1,
  data = pcod, 
  mesh = make_mesh(pcod, c("X", "Y"), cutoff = 10),
  family = delta_poisson_link_lognormal(), 
)
summary(fit)
#> Spatial model fit by ML ['sdmTMB']
#> Formula: density ~ 1
#> Mesh: make_mesh(pcod, c("X", "Y"), cutoff = 10) (isotropic covariance)
#> Data: pcod
#> Family: delta_poisson_link_lognormal(link1 = 'log', link2 = 'log')
#> 
#> Delta/hurdle model 1: -----------------------------------
#> Family: binomial(link = 'log') 
#>             coef.est coef.se
#> (Intercept)    -0.59     0.3
#> 
#> Matérn range: 33.11
#> Spatial SD: 1.51
#> 
#> Delta/hurdle model 2: -----------------------------------
#> Family: lognormal(link = 'log') 
#>             coef.est coef.se
#> (Intercept)     3.74    0.12
#> 
#> Dispersion parameter: 1.33
#> Matérn range: 31.56
#> Spatial SD: 0.47
#> 
#> ML criterion at convergence: 6265.205
#> 
#> See ?tidy.sdmTMB to extract these values as a data frame.

Created on 2023-08-15 with reprex v2.0.2