modleR icon indicating copy to clipboard operation
modleR copied to clipboard

Error message with (setup_sdmdata) step

Open SDMENM opened this issue 5 years ago • 4 comments

Hello Everyone,

When I run the first code in ModleR, it gives me an error message. I am posting here the R code and error message. Can someone please help me with this.

setup_sdmdata(species_name = "L_agrorensis", occurrences = occ, predictors = stack, lon = "longitude", lat = "latitude", models_dir = "./models", real_absences = NULL, buffer_type = NULL, dist_buf = NULL, env_filter = FALSE, env_distance = "centroid", buffer_shape = NULL, min_env_dist = NULL, min_geog_dist = NULL, write_buffer = FALSE, seed = NULL, clean_dupl = FALSE, clean_nas = FALSE, clean_uni = FALSE, geo_filt = FALSE, geo_filt_dist = NULL, select_variables = FALSE, cutoff = 0.8, sample_proportion = 0.8, png_sdmdata = TRUE, n_back = 1000, partition_type = C("bootstrap"), boot_n = 1, boot_proportion = 0.7, cv_n = NULL, cv_partitions = NULL) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘res’ for signature ‘"standardGeneric"’

SDMENM avatar Jul 17 '20 17:07 SDMENM

Hello, @SDMENM We would need more details into the reasons for this error, such as the class or structure of "occ" and "stack". For now, the function seems to be having trouble recognizing the resolution of your predictor variables stack (function raster::res()). Please make sure that it is a raster package RasterBrick or RasterStack object, and that you can execute res(stack) with no problems. Please let us know if that works, and thanks for using modleR! :)

AndreaSanchezTapia avatar Jul 17 '20 17:07 AndreaSanchezTapia

raster::res(stack) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘res’ for signature ‘"standardGeneric"’

SDMENM avatar Jul 17 '20 17:07 SDMENM

Thank you Andrea, that worked. let me try the remaining codes.

SDMENM avatar Jul 17 '20 17:07 SDMENM

Hello again,

I am having problem running random forest with ModleR, I think my raster stack have NA values which are not permitted in the default settings of rf, can you please take a look. thanks.

do_any(species_name = "L_agrorensis", predictors = stack, models_dir = "./models", algorithm = c("rf"), project_model = FALSE, proj_data_folder = "./data/proj", mask = NULL, write_rda = FALSE, png_partitions = FALSE, write_bin_cut = FALSE, dismo_threshold = "spec_sens", equalize = TRUE, sensitivity = 0.9, proc_threshold = 0.5) rf L_agrorensis rf run number 1 part. nb. 1 fitting models Error in randomForest.default(x, y, mtry = mtryStart, ntree = ntreeTry, : NA not permitted in predictors In addition: Warning message: In randomForest.default(x, y, mtry = mtryStart, ntree = ntreeTry, : The response has five or fewer unique values. Are you sure you want to do regression?

SDMENM avatar Jul 17 '20 18:07 SDMENM