[R-sig-Geo] raster package and predict for GBM models

Robert J. Hijmans r.hijmans at gmail.com
Thu Nov 4 17:58:37 CET 2010


Hi Mike,

I cannot know from what you send, but the second argument should be
your gbm object, and from your name "myData" I am guessing it is not
(unless it really is referring to youModel).
One of the two vignettes of the 'dismo' package is about 'gbm'
(boosted regression trees) and 'raster' . So in principle it should
work.

Robert


On Thu, Nov 4, 2010 at 7:34 AM, Michael ODonnell <odonnems at yahoo.com> wrote:
> 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
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list