pbs-assess / sdmTMB

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

Fix coef() to work with delta models #351

Open ericward-noaa opened 1 month ago

ericward-noaa commented 1 month ago

I think the solution here is just modifying coef()to take model as an argument

library(dplyr)
library(tidyr)
library(sdmTMB)

set.seed(1)

# Build a mesh to implement the SPDE approach:
mesh <- make_mesh(pcod_2011, c("X", "Y"), cutoff = 20)

# Quick mesh plot:
plot(mesh)


# Fit a Tweedie spatial random field GLMM with a smoother for depth:
fit <- sdmTMB(
  density ~ s(depth),
  data = pcod_2011, mesh = mesh,
  family = delta_gamma()
)

coef(fit)
#> (Intercept) 
#>  -0.7903428

Created on 2024-06-14 with reprex v2.1.0