STARRS is a comprehensive package for STochastic Algorithms for Robust multivaRiate Statistics. Robustness is a key aspect in statistical analysis, especially when dealing with real-world data that may contain outliers or be subject to various types of noise. STARRS provides a suite of tools and algorithms designed to enhance the robustness of multivariate statistical methods, replacing the use of traditional covariance matrices with more robust alternatives. The package includes implementations of several stochastic algorithms for the most common robust multivariate statistics, such as:
To get started with STARRS, you can install the package from CRAN using the following command:
Once installed, you can load the package into your R session
The basic functions in the STARRS package are the computation of median and the median covariance matrix.
These computations have several implementations, based on different algorithms, performed using
Online, Offline or Semi-Online approaches.
Here is an example of how to compute the median and median covariance matrix using the STARRS package:
# Load the STARRS package
library(STARRS)
# Generate some example data
data <- rSphereGM(n=500,d=5,K=3)
# Compute the median using the Weiszfeld algorithm
median_est <- WeiszfeldMedian(data$X)
print(median_est)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] -3.091029 0.8289249 -1.791928 0.7352348 -1.48842
# Compute the median covariance matrix
medianCov <- WeiszfeldMedianCovariance(data$X,median_est=median_est)
print(medianCov)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1.73683853 -0.8026144 0.05780958 0.7713579 -1.1869391
#> [2,] -0.80261439 1.6176385 0.16626145 -1.0306765 0.7072443
#> [3,] 0.05780958 0.1662615 1.31083896 -0.5700337 -1.0024330
#> [4,] 0.77135786 -1.0306765 -0.57003372 2.4663104 0.1583683
#> [5,] -1.18693914 0.7072443 -1.00243303 0.1583683 4.1772426