Perform Spatial Error Estimation and Variable Importance in Parallel

Implements spatial error estimation and permutation-based variable importance measures for predictive models using spatial cross-validation and spatial block bootstrap.

The main functions of sperrorest have been integrated into mlr. Review is still ongoing. Once it is available in the CRAN version of mlr we will let you know. There will be no active development of sperrorest anymore. We recommend to use mlr for all future (spatial) cross-validation work. We will provide an tutorial for spatial data in the mlr-tutorial soon.

Project Status: Active – The project has reached a stable, usable state and is being actively developed. DOI

Resource: CRAN Travis CI Appveyor
Platforms: Multiple Linux & macOS Windows
R CMD check CRAN version Build status Build status
Test coverage Coverage Status


CRAN_Status_Badge Downloads


Spatial Error Estimation and Variable Importance

This package implements spatial error estimation and permutation-based spatial variable importance using different spatial cross-validation and spatial block bootstrap methods. To cite sperrorest in publications, reference the paper by Brenning (2012). To see the package in action, please check the vignette.


Get the released version from CRAN:


Or the development version from Github:

remotes::install_github("pat-s/[email protected]")


Brenning, A. 2005. “Spatial Prediction Models for Landslide Hazards: Review, Comparison and Evaluation.” Natural Hazards and Earth System Science 5 (6). Copernicus GmbH: 853–62. doi:10.5194/nhess-5-853-2005.

———. 2012. “Spatial Cross-Validation and Bootstrap for the Assessment of Prediction Rules in Remote Sensing: The R Package Sperrorest.” In 2012 IEEE International Geoscience and Remote Sensing Symposium, 5372–5. doi:10.1109/IGARSS.2012.6352393.

Russ, Georg, and Alexander Brenning. 2010a. “Data Mining in Precision Agriculture: Management of Spatial Information.” In Computational Intelligence for Knowledge-Based Systems Design: 13th International Conference on Information Processingand Management of Uncertainty, IPMU 2010, Dortmund, Germany, June 28 - July 2, 2010. Proceedings, edited by Eyke Hüllermeier, Rudolf Kruse, and Frank Hoffmann, 350–59. Berlin, Heidelberg: Springer Berlin Heidelberg. doi:10.1007/978-3-642-14049-5_36.

———. 2010b. “Spatial Variable Importance Assessment for Yield Prediction in Precision Agriculture.” In Lecture Notes in Computer Science, 184–95. Springer Science + Business Media. doi:10.1007/978-3-642-13062-5_18.


sperrorest 2.1.1 (15-Oct-2017)


  • train_fun and test_fun are now handled correctly and eventual sub-sampling is correctly reflected to the resulting 'resampling' object

sperrorest 2.1.0 (25-Sep-2017)


  • error handling during model fitting & performance evaluation: If a model does not converge for some folds or an error occurs during performance calculation, results of this fold are set to NA and a message is printed to the console. sperrorest() will continue normally and uses the successful folds to calculate the repetition error. This helps to run CV with many repetitions using models which do not always converge like maxnet(), gamm() or svm().


  • Size of example data set ecuador has been adjusted to avoid exact duplicates of partitions when using partition_kmeans().

sperrorest 2.0.1 (20-Jul-2017)


  • Fixes a bug which caused equal importance of all predictors when performing permutation-based variable importance assessment

sperrorest 2.0.0 (12-Jun-2017)


  • integration of parsperrorest() into sperrorest().
  • by default, sperrorest() now runs in parallel using all available cores.
  • runfolds() and runreps() are now doing the heavy lifting in the background. All modes are now running on the same code base. Before, all parallel modes were running on different code implementations.
  • function and argument name changes to 'snake_case'


  • new (parallel) modes:
    • apply: calls pbmclapply() on Unix and pbapply() on Windows.
    • future: calls future_lapply() with various future options (multiprocess, multicore, etc.).
    • foreach: foreach() with various future options (multiprocess, multicore, etc.). Default option to cluster. This is also the overall default mode for sperrorest().
    • sequential: sequential execution using future backend.
  • RMSE instead of MSE as error measure
  • You can now pass also single values to repetition argument of sperrorest(). Specifying a range like repetition = 1:10 will also stay valid.
  • New vignette sperrorest::parallel-modes comparing the various parallel modes.
  • New vignette sperrorest::custom-pred-and-model-functions explaining why and how custom defined model and predict functions are needed for some model setups.


  • Limit workers to number of repetitions if number of cores > number of repetitions. This ensures that no unnecessary workers are started and increases robustness of parallel execuction.
  • documentation improvements.
  • do_try argument has been removed.
  • error.fold, error.rep and err.train arguments have been removed because they are all calculated by default now.


  • partial matching of arguments
  • account for factor levels only present in test data but missing in training data. Previously, sperrorest errored during the predict step when this case occured. Now, this is accounted for and an informative message is given.

sperrorest 1.0.0 (08-Mar-2017)

New features:

  • add parsperrorest(): This function lets you exexute sperrorest() in parallel. It includes two modes (par.mode = 1 and par.mode = 2) which use different parallelization approaches in the background. See ?parsperrorest() for more details.

  • add This resampling method enables partitioning based on a given factor variable. This can be used, for example, to resample agricultural data, that is grouped by fields, at the agricultural field level in order to preserve spatial autocorrelation within fields.

  • sperrorest() and parsperrorest(): Add benchmark item to returned object giving information about execution time, used cores and other system details.

Changes to functions:

  • sperrorest(): Change argument naming. err.unpooled is now error.fold and err.pooled is now error.rep

  • sperrorest() and parsperrorest(): Change order and naming of returned object

    • class sperrorestpoolederror is now sperrorestreperror
    • returned sperrorest list is now ordered as follows:
      1. error.rep
      2. error.fold
      3. importance
      4. benchmarks
      5. package.version

Package related:

  • add package NEWS

  • add package vignette -> vignette("sperrorest-vignette", package = "sperrorest")

  • package is now ByteCompiled

  • Github repo of sperrorest now at

sperrorest 0.2-1 (19 June 2012)

  • First release on CRAN

sperrorest 0.2-0 (19 June 2012)

  • last pre-release version
  • replaced Stoyan's data set with Jannes Muenchow's data, adapted examples

sperrorest 0.1-5 (1 Mar 2012)

  • made training set estimation optional
  • robustified code using try()

sperrorest 0.1-2 (29 Jan 2012)

  • internal release 0.1-2
  • some bug fixes, e.g. in err.* functions
  • improved support of pooled versus unpooled error estimation
  • changed some argument names
  • this version was used for Angie's analyses

sperrorest 0.1-1 (29 Dec 2011)

  • built internal release 0.1-1

sperrorest 0.1

  • general code development (2009 - 2011)
  • package project and documentation created (Oct-Dec 2011)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


2.1.1 by Alexander Brenning, 4 months ago

Report a bug at

Browse source code at

Authors: Alexander Brenning [aut, cre], Patrick Schratz [aut], Tobias Herrmann [aut]

Documentation:   PDF Manual  

Task views: Analysis of Spatial Data

GPL-3 license

Imports pbapply, pbmcapply, magrittr, future, doFuture, foreach, ROCR, parallel, graphics, stats, rpart, purrr, stringr, gdata

Suggests ipred, nnet, RSAGA, knitr, testthat, pacman, rmarkdown

See at CRAN