Skip to main content

Nonparametric Test Statistics

Project description

# PyNonpar

[![PyPI version](](
[![Travis-CI Build Status](](
[![Codacy Badge](](

Test statistics based on ranks may lead to paradoxical results. A solution are so-called pseudo-ranks.
This package provides a function to calculate pseudo-ranks which are used in nonparametric statistics for rank tests.
For a definition and discussion of pseudo-ranks, see for example [1].

To install the package from PyPi, simply type
pip install PyNonpar

## Table of Contents
**[Two-Sample Tests](#two-sample-tests)**<br>
**[Multi-Sample Tests](#multi-sample-tests)**<br>

## Pseudo-Ranks
If there are ties (i.e., observations with the same value) in the data, then the pseudo-ranks have to be adjusted. There
are the options 'minimum', 'maximum' and 'average'. It is recommended to use 'average' as for this adjusmtent, normalized
empirical distribution functions are used.
See the example for details on the usage of the function 'psrank'.

import PyNonpar
from PyNonpar import*

# some artificial data
x = [1, 1, 1, 1, 2, 3, 4, 5, 6]
group = ['C', 'C', 'B', 'B', 'B', 'A', 'C', 'A', 'C']

PyNonpar.pseudorank.psrank(x, group, ties_method = "average")

## Nonparametric Test Statistics

### Two-Sample Tests

1. Asymptotic Wilcoxon-Mann-Whitney test: brunner_munzel_test()
2. Brunner-Munzel test (Generalized Wilcoxon test): brunnzer

The Hodges-Lehmann estimator can be calculated in a location shift model: hodges_lehmann(). The confidence interval for this estimator is
only asymptotic and assumes continuous distributions.

### Multi-Sample Tests

1. The Hettmansperger-Norton Test for Patterned Alternatives: hettmansperger_norton_test()
2. Kruskal-Wallis test: kruskal_wallis_test()

#### 1. The Hettmansperger-Norton Test for Patterned Alternatives
This package provides a function to calculate the Hettmansperger-Norton test for patterned alternatives
using pseudo-ranks. Originally, this test was developed for ranks but this version was adapted to pseudo-ranks.

For the alternative, it is possible to use 'increasing' (i.e., trend = [1, 2, 3, ..., g]), 'decreasing'
(i.e., trend = [g, g-1, g-2, ..., 1]) or 'custom' where the trend has to be specified manually. Note, that the trend is
a list of length g where g is the number of groups.

import PyNonpar
from PyNonpar import*

# some artificial data
x = [1, 1, 1, 1, 2, 3, 4, 5, 6]
group = ['C', 'C', 'B', 'B', 'B', 'A', 'C', 'A', 'C']

PyNonpar.hettmansperger.hettmansperger_norton_test(x, group, alternative = "custom", trend = [1,3,2])

## References
[1] Brunner, E., Bathke A. C. and Konietschke, F: Rank- and Pseudo-Rank Procedures in Factorial Designs - Using R and SAS, Springer Verlag, to appear.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyNonpar-0.0.3.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

PyNonpar-0.0.3-py3-none-any.whl (12.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page