Models with smooth terms no longer run - "object of type 'symbol' is not subsettable" #260
-
The ErrorI'm a very new user of sdmTMB but have successfully run a number of models on fisheries data. In going back to some models I was running successfully last week. I'm getting this error and have traced it to the inclusion of smooth terms:
I came back to the models because I was having convergence problems. I saw the note about the nlminb_loops. Increasing the number of loops to 2 worked on models without smooth terms. I tried installing the development version of sdmTMB but that didn't solve it. I tried running the same model with smooth terms using gam() from mgcv and it runs. Same for brm() from brms. Simulated ExampleIn terms of reproducible example, using this simulated data I get the same errror.
This runs:
This produces the error:
TracebackThis is from RStudio's Traceback feature.
Package UpdatesI updated a number of R packages since running the models successfully before, I wasn't paying close attention to which ones updated. I was getting a warning about a mismatch in versions of the Matrix package, but that was back when the models ran fine. Session InfoHere is the session info from running the model on the simple, simulate data.
Matrix products: default locale: attached base packages: other attached packages: loaded via a namespace (and not attached): |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Thanks for the reproducible example. That does run for me (other than the smoother penalization terms collapsing to zero, which is to be expected in this simple example). I've simplified it here to isolate the smoothers. Does this run for you? I believe I've seen that error before and it's from mgcv parsing the library(sdmTMB)
set.seed(1)
sim_data <- data.frame(
depth = runif(1000, 100, 300),
haul_hours = runif(1000, 0.5, 5),
catch = rnorm(1000, mean = 50, sd = 24)
)
m1 <- sdmTMB(
catch ~ depth + haul_hours,
data = sim_data,
spatial = "off"
)
m1
#> Model fit by ML ['sdmTMB']
#> Formula: catch ~ depth + haul_hours
#> Mesh: NULL (isotropic covariance)
#> Data: sim_data
#> Family: gaussian(link = 'identity')
#>
#> coef.est coef.se
#> (Intercept) 49.54 3.30
#> depth -0.01 0.01
#> haul_hours 0.86 0.59
#>
#> Dispersion parameter: 24.91
#> ML criterion at convergence: 4634.250
#>
#> See ?tidy.sdmTMB to extract these values as a data frame.
m1s <- sdmTMB(
catch ~ s(depth) + s(haul_hours),
data = sim_data,
spatial = "off"
)
m1s
#> Model fit by ML ['sdmTMB']
#> Formula: catch ~ s(depth) + s(haul_hours)
#> Mesh: NULL (isotropic covariance)
#> Data: sim_data
#> Family: gaussian(link = 'identity')
#>
#> coef.est coef.se
#> (Intercept) 49.61 0.79
#> sdepth 0.65 0.79
#> shaul_hours -1.15 0.79
#>
#> Smooth terms:
#> Std. Dev.
#> sds(depth) 0
#> sds(haul_hours) 0
#>
#> Dispersion parameter: 24.91
#> ML criterion at convergence: 4634.250
#>
#> See ?tidy.sdmTMB to extract these values as a data frame.
#>
#> **Possible issues detected! Check output of sanity().**
packageVersion("mgcv")
#> [1] '1.9.0'
packageVersion("sdmTMB")
#> [1] '0.3.1.9000' Created on 2023-10-10 with reprex v2.0.2
|
Beta Was this translation helpful? Give feedback.
-
Ah, it's because of the glmmTMB update to 1.1.8 and some change to |
Beta Was this translation helpful? Give feedback.
-
Should be fixed now with the latest commit on GitHub. Let me know if not. |
Beta Was this translation helpful? Give feedback.
-
Sorry, my fix broke other things. I hope the latest will pass all checks. |
Beta Was this translation helpful? Give feedback.
Should be fixed now with the latest commit on GitHub. Let me know if not.