-
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
Error in check_time_class()
#377
Comments
Can you please include a small reproducible example? In general, yes -- you need to have time in the prediction grid if time is included in the model. From the help files, you can fit a spatial model with no time argument (and spatiotemporal fields off as a result):
And then you can make a prediction to a grid without time,
|
@javierlenzi any update on this? To be clear, for a spatiotemporal model, you don't need to have all time elements in the prediction |
Dear Sean and Eric,
Thank you for your responses and sorry for my late response.
As I understood I needed the full time period in the prediction grid of my
spatiotemporal model, I paused the use of sdmTMB until I found an HPC. Now
that I know I can customize the number of years to predict (I didn't notice
this in the vignette), I will resume this analysis and let you know whether
it worked.
Thanks again!
Javier.
…On Tue, Mar 4, 2025 at 10:14 PM Sean Anderson ***@***.***> wrote:
@javierlenzi <https://github.com/javierlenzi> any update on this? To be
clear, for a spatiotemporal model, you don't *need* to have all time
elements in the prediction newdata data frame unless you want to predict
on all time elements. You just need to have a time column of the same class
with at least one value that matches a fitted time element. You can pick
any representative year and set a time column to that value. As
@ericward-noaa <https://github.com/ericward-noaa> noted above, for a
spatial model you don't need a time column at all.
—
Reply to this email directly, view it on GitHub
<#377 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQKZXFM4FP2DARS73MMTKOT2SYJTVAVCNFSM6AAAAABQOPAD4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJYHEZDGMJZG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: seananderson]*seananderson* left a comment (pbs-assess/sdmTMB#377)
<#377 (comment)>
@javierlenzi <https://github.com/javierlenzi> any update on this? To be
clear, for a spatiotemporal model, you don't *need* to have all time
elements in the prediction newdata data frame unless you want to predict
on all time elements. You just need to have a time column of the same class
with at least one value that matches a fitted time element. You can pick
any representative year and set a time column to that value. As
@ericward-noaa <https://github.com/ericward-noaa> noted above, for a
spatial model you don't need a time column at all.
—
Reply to this email directly, view it on GitHub
<#377 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQKZXFM4FP2DARS73MMTKOT2SYJTVAVCNFSM6AAAAABQOPAD4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJYHEZDGMJZG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Dear Sean and others,
I am running a series of sdmTMB binomial models with the same response and predictors, with and without space and time random fields. When using the function predict() to get the predictions over my SpatRaster stack of predictors for the study area (the Baltic Sea), I keep receiving this error message:
Error in
check_time_class()
:! Class of fitted time column (integer) does not match class of
newdata
time column (SpatRaster)Reading the sdmTMB vignette, I realized that you need to predict using a data frame replicated for each of the years in the training set. Is this correct?
grid_yrs <- replicate_df(qcs_grid, "year", unique(pcod$year))
In my case, predictors are just one tiff layer stacked in a SpatRaster object (dimensions : 11023, 9825, 33 (nrow, ncol, nlyr)) with no time stamp associated to them, they are static. Is there any way that I could use sdmTMB to predict using my static raster stack with no need to convert it into a data frame and replicate it over the years of my observations?
This will simplify things a lot because although I have a column "year" in my observations I am not interested in predicting for each year at this time. Further, my 33 static predictors are in high spatial resolution (250 m, 11023 x 9825 cells each) for the entire Baltic Sea, and my computer is not able to handle the conversion to a data frame due to memory issues.
Thanks a lot for any help and guidance you can provide.
Javier.
The text was updated successfully, but these errors were encountered: