Thanks Tim, This happened when using gam & writing to file & na.rm = FALSE (which in the case of GAM is the same as na.rm=TRUE). The problem was that gam.predict returns an array where raster::predict expected a matrix or a vector. This is now fixed (version 1.8-22). Robert
On Thu, May 12, 2011 at 6:02 AM, <[email protected]> wrote: >> Tim, >> >> That is a tough one. Can you send me the result of >> >> traceback() > > Here is the result: >> mod.gam <- gam(y ~ Slope + Boen_By50m + Hoehe_abs, data=train, >> family=binomial()) >> p <- predict(object = r, model = mod.gam, filename='gebiet_1/sturmwurf.img', > progress='text', na.rm = FALSE, overwrite = TRUE, format = 'HFA', > type='response') > | | > 0%Error in object[-omit, , drop = FALSE] : incorrect number of dimensions >> traceback() > 7: na.omit.default(v) > 6: na.omit(v) > 5: writeValues(predrast, predv, tr$row[i]) > 4: writeValues(predrast, predv, tr$row[i]) > 3: .local(object, ...) > 2: predict(object = r, model = mod.gam, filename = "gebiet_1/sturmwurf.img", > progress = "text", na.rm = FALSE, overwrite = TRUE, format = "HFA", > type = "response") > 1: predict(object = r, model = mod.gam, filename = "gebiet_1/sturmwurf.img", > progress = "text", na.rm = FALSE, overwrite = TRUE, format = "HFA", > type = "response") > > > > I think I found the error. In my rasterStack NA were present. And since the > "na.rm" argument is set to FALSE, predict() fails. > Attached you find data. Hopefully they can help you to clarify, because > though it is working now by setting na.rm=TRUE, it is still curious why > predict() is working with lm() or glm() models but not with gam(). > (...) > > Thank you. > > All the best, > TIM > _______________________________________________ R-sig-Geo mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
