[R-sig-Geo] raster package and predict for GBM models
Michael ODonnell
odonnems at yahoo.com
Thu Nov 4 15:34:28 CET 2010
Hello,
I have little experience using the raster package and I am currently trying to develop a predicted surface based on a gradient boosted model (gbm package).
The basic steps I am using include the following:
# Creating a raster stack of independent variables
USHGT <- raster("ushgt.asc", package="raster")
... (other variables omitted for post)
ras_stk <- stack(USHGT, HYELB, T1TO5LE, URBD_D, SG_UNIT, MINTEMP, ANNPCP, TC_B04, TC_B07)
# Create the prediction model
... I am using a separate script that creates the gbm object and due to the length I will not include. The outcome is a gbm object.
.. Now I use the following, which fails:
r <- predict(ras_stk, myData, filename=OutFile, na.rm=TRUE, overwrite=TRUE, n.trees=myData$n.trees, type="response", progress="window")
Error:
Error in model.frame.default(terms(reformulate(object$var.names)), newdata, :object is not a matrix
The raster package manual states that the predict function will work on any model that a predict method has been implemented.
Does anyone have experience with this or possibly an idea on how I might solve the issue.
Thank you,
mike
More information about the R-sig-Geo
mailing list