MyNixOS website logo
Description

Robust Nonparametric Two-Sample Tests for Location/Scale.

Implementations of several robust nonparametric two-sample tests for location or scale differences. The test statistics are based on robust location and scale estimators, e.g. the sample median or the Hodges-Lehmann estimators as described in Fried & Dehling (2011) <doi:10.1007/s10260-011-0164-1>. The p-values can be computed via the permutation principle, the randomization principle, or by using the asymptotic distributions of the test statistics under the null hypothesis, which ensures (approximate) distribution independence of the test decision. To test for a difference in scale, we apply the tests for location difference to transformed observations; see Fried (2012) <doi:10.1016/j.csda.2011.02.012>. Random noise on a small range can be added to the original observations in order to hold the significance level on data from discrete distributions. The location tests assume homoscedasticity and the scale tests require the location parameters to be zero.

robnptests

Codecov test coverage

The R package robnptests contains different robust and nonparametric tests for the two-sample location problem. The tests allow for comparisons of either the location or the scale parameters of two random samples.

Installation

The released version of robnptests can be installed from CRAN with

install.packages("robnptests")

To install the development version, the devtools package is required:

if (!require("devtools")) {
  install.packages("devtools")
}

devtools::install_github("s-abbas/robnptests")

library(robnptests)

Scope and Usage

The robust and nonparametric tests in this R package follow the construction principle of the popular t-test: A robust estimate for the location difference of the two samples is divided by a robust estimate of scale. The p-values can either be computed using the permutation principle, the randomization principle, or the asymptotic distribution of the estimators. If the principle to compute the p-value is not specified by the user, it will be selected automatically depending on the sample size. The functions used to compute the location and scale estimates are also made available to the user.

The following list shows the currently implemented tests in the package:

  • tests based on the median (med_test), the one-sample Hodges-Lehmann estimator (hl1_test), and the two-sample Hodges-Lehmann estimator (hl2_test), scaled by robust estimators
  • Yuen's t-test (trimmed_test)
  • tests based on the Huber-, Hampel- or Bisquare-M-estimator (m_test).

Even though the test statistics compare location estimates of the samples, they can be used to identify scale differences. This is achieved by setting the argument scale.test = TRUE, with which the observations in the samples are log-transformed so that scale differences between the original samples correspond to location differences in the transformed samples.

Details on the tests and references can be found on the help pages of the functions and the vignette vignette("robnptests").

Example 1: Asymptotic test for location difference using the two-sample Hodges-Lehmann estimator

set.seed(121)
x <- rnorm(50); y <- rnorm(50)

hl2_test(x, y, method = "asymptotic")

# 
# 	Asymptotic test based on HL2-estimator
# 
# data:  x and y
# D = 1.0916, p-value = 0.275
# alternative hypothesis: true location shift is not equal to 0
# sample estimates:
# HL2 of x and y 
#      0.2048249

Example 2: Asymptotic test for scale difference using the two-sample Hodges-Lehmann estimator

hl2_test(x, y, method = "asymptotic", scale.test = TRUE)

# 	Asymptotic test based on HL2-estimator
# 
# data:  x and y
# S = -0.24094, p-value = 0.8096
# alternative hypothesis: true ratio of variances is not equal to 1
# sample estimates:
# HL2 of log(x^2) and log(y^2) 
#                   -0.1040422 

Contributions

We are grateful for any contribution to the further development of the R package. If you experience any problems using the package or have suggestions for new features, please open an issue in the issue tracker. Please consult our contribution guidelines before submitting a pull request.

Metadata

Version

1.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows