-
Notifications
You must be signed in to change notification settings - Fork 27
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
cross-validation vignette needs updating #259
Comments
also, this model won't converge, with a non-positive-definite Hessian: test_years <- c(2011, 2013, 2015, 2017) models <- list() models[[i]] <- sdmTMB_cv( log_lik[[i]] <- sum(m_cv$data$cv_loglik[which(m_cv$data$year == test_years[i])]) |
I made some quick fixes and also switched library(sdmTMB)
mesh <- make_mesh(pcod, c("X", "Y"), cutoff = 25)
m_lfocv <- sdmTMB_cv(
present ~ s(year, k = 3),
data = pcod,
mesh = mesh,
lfo = TRUE, # do LFOCV
lfo_forecast = 2, # number of time steps to forecast
lfo_validations = 3, # number of times to validate
family = binomial(),
spatiotemporal = "off",
time = "year" # must be specified
)
#> Running fits with `future.apply()`.
#> Set a parallel `future::plan()` to use parallel processing.
# See how the LFOCV folds were assigned:
example_data <- m_lfocv$models[[2]]$data
table(example_data$cv_fold, example_data$year)
#>
#> 2003 2004 2005 2007 2009 2011 2013 2015 2017
#> 1 232 230 224 255 233 0 0 0 0
#> 2 0 0 0 0 0 251 0 0 0
#> 3 0 0 0 0 0 0 240 0 0
#> 4 0 0 0 0 0 0 0 238 0
#> 5 0 0 0 0 0 0 0 0 240 Created on 2023-09-29 with reprex v2.0.2 Here is what I would have expected: An example of LFOCV with 9 time steps, lfo_forecast = 2, and lfo_validations = 3: One thing I'm not sure is if the time steps are 2007, 2008, 2009 etc. or 2007, 2009, 2011 (the steps provided). But I'm also just not sure how |
Sorry I was slow here, see #262 For your example, of LFOCV with 9 time steps, lfo_forecast = 2, and lfo_validations = 3, the model is doing: This can be seen in a couple places in the code, e.g. Line 335 in e960d1e
The time steps used are those provided (2007, 2009, 2011). Here's an example of how the table is made, using a snippet from sdmTMB_cv:
|
There is no elpd object created in most recent version, but this is a metric that the vignette focuses on and expects to be in the model object
The text was updated successfully, but these errors were encountered: