robslopes: Efficient Computation of the (Repeated) Median Slope

Modern use of slope estimation often involves the (repeated) estimation of a large number of slopes on a large number of data points. Some of the most popular non-parametric and robust alternatives to the least squares estimator are the Theil-Sen and Siegel’s repeated median slope estimators. The robslopes package contains fast algorithms for these slope estimators. The implemented randomized algorithms run in \(\mathcal{O}(n\log(n))\) and \(\mathcal{O}(n\log^2(n))\) expected time respectively and use \(\mathcal{O}(n)\) space. They achieve speedups up to a factor \(10^3\) compared with existing implementations for common sample sizes, as illustrated in a benchmark study, and they allow for the possibility of estimating the slopes on samples of size \(10^5\) and larger thanks to the limited space usage. Finally, the original algorithms are adjusted in order to properly handle duplicate values in the data set.

Jakob Raymaekers (Maastricht University and KU Leuven)

Supplementary materials

Supplementary materials are available in addition to this article. It can be downloaded at



Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

Raymaekers, "The R Journal: robslopes: Efficient Computation of the (Repeated) Median Slope", The R Journal, 2023

BibTeX citation

  author = {Raymaekers, Jakob},
  title = {The R Journal: robslopes: Efficient Computation of the (Repeated) Median Slope},
  journal = {The R Journal},
  year = {2023},
  note = {},
  doi = {10.32614/RJ-2023-012},
  volume = {14},
  issue = {4},
  issn = {2073-4859},
  pages = {38-49}