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

Make sdmTMB() work without a mesh if all fields are turned off #59

Closed
seananderson opened this issue Nov 5, 2021 · 2 comments
Closed

Comments

@seananderson
Copy link
Member

Work in 'sim2' branch where spatial = 'off' and spatiotemporal = 'off' does this (same as map_rf = TRUE. Good suggestion by @joenomiddlename. Will require filling in dummy mesh data and changing a few things that assume a mesh is present (e.g. finding the INLA 'A' matrix).

@seananderson
Copy link
Member Author

I just added a hack that creates a fake mesh if there are no random fields. Not super elegant, but for a small overhead it's guaranteed to work everywhere. I also cleaned up print() if there are no random fields.

fit <- sdmTMB(
  density ~ as.factor(year) + s(depth, k = 3), 
  data = pcod_2011, 
  family = tweedie(link = "log"), 
  spatial = "off", spatiotemporal = "off"
)
Model fit by ML ['sdmTMB']
Formula: density ~ as.factor(year) + s(depth, k = 3)
Mesh: NULL
Data: pcod_2011
Family: tweedie(link = 'log')
                    coef.est coef.se
(Intercept)             2.50    0.16
as.factor(year)2013    -0.05    0.18
as.factor(year)2015     0.34    0.18
as.factor(year)2017    -0.59    0.19
sdepth                  5.02    0.39

Smooth terms:
           Std. Dev.
sds(depth)     88.95

Dispersion parameter: 15.09
Tweedie p: 1.61
ML criterion at convergence: 2973.045

seananderson added a commit that referenced this issue Mar 23, 2022
seananderson added a commit that referenced this issue Mar 23, 2022
@ericward-noaa
Copy link
Collaborator

I did similar when working on the CAR branch

sdmTMB/R/fit.R

Line 491 in 3402fad

mesh <- make_mesh(data,c("car_x","car_y"),n_knots=min(car_k, 8))

but this version is better, so the CAR hack can get deleted

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