Closed psolymos closed 5 years ago
The raster package already have a predict
method that allows this: see ?raster::predict
Make a Raster object with predictions from a fitted model object (for example, obtained with lm, glm). The first argument is a Raster object with the independent (predictor) variables. The names in the Raster object should exactly match those expected by the model. This will be the case if the same Raster object was used (via extract) to obtain the values to fit the model (see the example). Any type of model (e.g. glm, gam, randomForest) for which a predict method has been implemented (or can be implemented) can be used.
This approach (predict a fitted model to raster data) is commonly used in remote sensing (for the classification of satellite images) and in ecology, for species distribution modeling.
Add a function which helps in pulling values (used/avail) from raster and raster stack objects.
Allow newdata to be defined as raster or raster stack.
Need to think about I() and interaction kind of terms (look around how that is done). Polynomials and interactions are really important.