Closed camilesothe closed 3 years ago
Hi Camile,
thank you very much for your message.
spatialRF was made to fit explanatory models considering the spatial structure of the data. However, incorporating the spatial structure of the data into a model is computationally expensive and limited by the available RAM. That's why I recommend its use for spatial point data with sample sizes between 100 and 5000, but the latter may vary depending on the available RAM.
If you want/need to predict over large raster extents, you will need to fit a non-spatial model with rf(). We don't have straightforward solutions to deal with spatial autocorrelation for large datasets yet. Unfortunately, spatialRF cannot help you with your task.
Best wishes,
Blas
Hi Blas,
Thank you for your answer, that makes sense.
Best,
Camile
Hi Blas,
Thank you for providing this code, it worked well in my data to train a spatial model. However, I'm having issues to run spatial prediction to generate the maps.
I'm trying to run the spatial prediction using SpatialRF model, however looks like I should compute the spatial features for my test data to predict over a large area.
My test data is a stack of remote sensing images converted to data frame. Even I'm creating small tiles, is still to big to create distance matrix for this and if so, how it consider the sample location since is a test data (no information about response variable) where I want to apply my trained model to generate the maps.
If I don't compute the spatial features, I'm getting this error:
Error in predict.ranger.forest(forest, data, predict.all, num.trees, type, : Error: One or more independent variables not found in data.
After this function _predicted <- stats::predict( object = model.spatial, data = testdata, type = "response" )$predictions
Is there a way to join this features to my test data to generate the maps?
Thank you so much for your help,
Camile