Repository navigation
Replies: 8 comments 1 reply
|
Sorry to hear this. No, I haven't seen it before ... as it crashes, does your machine memory explode (suggesting a memory issue), or does it crash the terminal without memory hitting the maximum (suggesting some indexing issue, perhaps due to a mismatch in the newdata and data)? |
|
Thank you so much for your answer! p <- predict(fit_b, newdata = fit_b$data[1:50, ], what = "mu_g", remove_origdata = TRUE) |
|
It seems like too big of a model to be useful as "minimal reproducible example", so I'll keep asking questions for you to check, and sorry again about the difficulty. Have you tried decreasing spatial resolution (to decrease memory) and replicating the issue? |
|
Not yet. The full model took about 6 hours to fit (plus almost 2 hours for the Hessian and sdreport), so refitting is a bit slow, but I'm running it now with a coarser mesh and i'll let you know if predict() still crashes! |
|
Well, I think the best guess is that its a memory issue. have you tried
the ***@***.*** branch on github? I think that has some recent
optimization of the C++ code
…On Thu, Nov 19, 2026 at 11:39 AM Chiara Gambardella < ***@***.***> wrote:
Not yet. The full model took about 6 hours to fit (plus almost 2 hours for
the Hessian and sdreport), so refitting is a bit slow, but I'm running it
now with a coarser mesh and i'll let you know if predict() still crashes!
One thing that may help: in an earlier version of this analysis I fitted a
similar multispecies model (binomial presence/absence, 5 species, 2 spatial
factors, survey_gear random effect, IID annual deviations in time_term,
projection parameterization, mesh with 1094 nodes), and predict() worked
fine on a 10 km grid. Compared to that, the current model adds a
spatio-temporal term (14 years x 7 variables), the second linear predictor
of the delta model, and the by-species splines.
—
Reply to this email directly, view it on GitHub
<#144?email_source=notifications&email_token=AL62VMRNPN4KTZL7O56L3VL5Z3EWPA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOJXGM4TONBRUZZGKYLTN5XKU43VMJZWG4TJMJSWJJLFOZSW45FMMZXW65DFOJPWG3DJMNVQ#discussioncomment-19739741>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL62VMTILMNDHEDLID2WABT5Z3EWPAVCNFSNUABIKJSXA33TNF2G64TZHM3TANBZGE4TONZTHNCGS43DOVZXG2LPNY5TCMJTGM4TMMRWUF3AE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
Quick update: the coarser mesh model (321 nodes instead of 1058) also crashes straight away in predict(), on the same 50 rows, with the CRAN version 1.6.3. So I’m not sure it’s only memory.... |
|
OK I ran a few tests to narrow this down. In all of them I call predict() on 50 rows of the data used to fit the model:
Since the small models still crash, I don’t think it’s memory... |
|
can you email me a minimal reproducible version of 5? |
Uh oh!
There was an error while loading. Please reload this page.
Hello!! I’m fitting a multispecies model with tinyVAST and I’m stuck on predictions. The model converges fine, but predict() kills the R session every time, with no error at all, even when I just predict on a few rows of the original data.
The model is fairly big: delta_gamma poisson-link, 212,624 rows (5 species x 42,527 hauls), SPDE mesh with a land barrier (1058 nodes), “projection” parameterization, 2 spatial factors, an IID spatio-temporal field in the first predictor, depth splines by species and a survey_gear random effect. So 217 fixed parameters and around 120,000 random effects. This is the call:
r
fit <- tinyVAST(
formula = N ~ 0 + species + species:factor(Year) + species:substrate_f +
s(log_depth_s, by = species, k = 5) +
species:log_fishing_s + species:I(log_fishing_s^2) + species:dist_coast_s +
s(survey_gear, bs = "re") + offset(log_area),
data = dat_ms,
family = delta_gamma(type = "poisson-link"),
space_term = space_p1, # 2 factors + residual SD per species
spacetime_term = spacetime_p1, # IID, SD per species, factors and one species fixed to 0
delta_options = list(formula = ~ 0 + species + species:factor(Year) + s(survey_gear, bs = "re"),
space_term = space_p2),
spatial_domain = mesh_cov,
variables = c("f1", "f2", sp_names),
control = tinyVASTcontrol(barrier_stiffness = 0.01, gmrf_parameterization = "projection",
newton_loops = 1, getsd = FALSE),
space_columns = c("xkm", "ykm"), time_column = "Year", times = 2010:2023,
variable_column = "var"
)
Everything else seems ok: max gradient 5.8e-6, sdreport gives pdHess TRUE, and after reload_model() both fitted() and simulate(type = “mle-mvn”) work (residuals look good). But this crashes R:
r
p <- predict(fit, newdata = fit$data[1:50, ], what = "mu_g", remove_origdata = TRUE)
Same with remove_origdata = FALSE
On a single-species model with the same data, predict() works...
Is this something you’ve seen before? For now I was thinking of adding the prediction grid to the data with weights = 0 and taking the predictions from fitted(). Would that be fine, or is there a better/faster way?
(tinyVAST 1.6.3, TMB 1.9.25, Matrix 1.7.6, R 4.6.2, macOS)
Thanks a lot!!!!
All reactions