You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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:
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):
# Fit a Tweedie spatial random field GLMM with a smoother for depth:
mesh <- make_mesh(pcod_2011, c("X", "Y"), cutoff = 20)
fit <- sdmTMB(
density ~ s(depth),
data = pcod_2011, mesh = mesh,
family = tweedie(link = "log")
)
fit
And then you can make a prediction to a grid without time,
# Predict on new data:
p <- predict(fit, newdata = qcs_grid)
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: