Closed fipoucat closed 1 year ago
This code:
library(meteo) library(sp) library(spacetime) library(gstat) library(plyr) library(xts) library(snowfall) library(doParallel) library(CAST) library(ranger) library(sf)
demo(meuse, echo=FALSE) meuse <- meuse[complete.cases(meuse@data),]
#################### rfsi ####################
fm.RFSI <- as.formula("zinc ~ dist + soil + ffreq")
rfsi_model <- rfsi(formula = fm.RFSI, data = meuse, zero.tol = 0, n.obs = 5, # number of nearest observations s.crs = NA, # or meuse@proj4string # nedded only if in lon/lat (WGS84) t.crs = NA, # or meuse@proj4string # nedded only if in lon/lat (WGS84) cpus = detectCores()-1, progress = TRUE,
importance = "impurity",
seed = 42,
num.trees = 250,
mtry = 5,
splitrule = "variance",
min.node.size = 5,
sample.fraction = 0.95,
quantreg = FALSE)
rfsi_model
sort(rfsi_model$variable.importance)
#################### pred.rfsi ####################
rfsi_prediction <- pred.rfsi(model = rfsi_model, data = meuse, # meuse.df (use data.staid.x.y.time) zcol = "zinc", newdata = meuse.grid, # meuse.grid.df (use newdata.staid.x.y.time) output.format = "SpatialPixelsDataFrame", zero.tol = 0, s.crs = meuse@proj4string, # NA newdata.s.crs = meuse@proj4string, # NA t.crs = meuse@proj4string, # NA cpus = detectCores()-1, progress = TRUE )
spplot(rfsi_prediction['pred'])
Hi,
I found your interesting package and installed it. While trying to run the example I am having an error: [1] "Preparing data ..." Error in data.prepare(data = data, data.staid.x.y.z = data.staid.x.y.z, : The argument data/newdata must be of sf, sftime, SpatVector, SpatRaster (as newdata only), data.frame class! What's the cause and what to do?