Click or drag to resize
Accord.NET (logo)

WilcoxonSignedRankTest Class

Wilcoxon signed-rank test for the median.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.TestingHypothesisTestWilcoxonDistribution
    Accord.Statistics.TestingWilcoxonTest
      Accord.Statistics.TestingWilcoxonSignedRankTest

Namespace:  Accord.Statistics.Testing
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class WilcoxonSignedRankTest : WilcoxonTest
Request Example View Source

The WilcoxonSignedRankTest type exposes the following members.

Constructors
  NameDescription
Public methodWilcoxonSignedRankTest
Tests the null hypothesis that the sample median is equal to a hypothesized value.
Top
Properties
  NameDescription
Public propertyCriticalValue
Gets the critical value for the current significance level.
(Inherited from HypothesisTestTDistribution.)
Public propertyDelta
Gets the differences between the samples.
(Inherited from WilcoxonTest.)
Public propertyHasTies
Gets wether the samples to be ranked contain ties.
(Inherited from WilcoxonTest.)
Public propertyHasZeros
Gets wether the samples to be ranked contain zeros.
(Inherited from WilcoxonTest.)
Public propertyHypothesis
Gets the alternative hypothesis under test. If the test is Significant, the null hypothesis can be rejected in favor of this alternative hypothesis.
Public propertyIsExact
Gets whether we are using a exact test.
(Inherited from WilcoxonTest.)
Public propertyNumberOfSamples
Gets the number of samples being tested.
(Inherited from WilcoxonTest.)
Public propertyPValue
Gets the P-value associated with this test.
(Inherited from HypothesisTestTDistribution.)
Public propertyRanks
Gets the rank statistics for the differences.
(Inherited from WilcoxonTest.)
Public propertySignificant
Gets whether the null hypothesis should be rejected.
(Inherited from HypothesisTestTDistribution.)
Public propertySigns
Gets the signs for each of the Delta differences.
(Inherited from WilcoxonTest.)
Public propertySize
Gets the significance level for the test. Default value is 0.05 (5%).
(Inherited from HypothesisTestTDistribution.)
Public propertyStatistic
Gets the test statistic.
(Inherited from HypothesisTestTDistribution.)
Public propertyStatisticDistribution
Gets the distribution associated with the test statistic.
(Inherited from HypothesisTestTDistribution.)
Public propertyTail
Gets the test type.
(Inherited from HypothesisTestTDistribution.)
Top
Methods
  NameDescription
Protected methodCompute(Double, Double, DistributionTail, NullableBoolean)
Computes the Wilcoxon Signed-Rank test.
(Inherited from WilcoxonTest.)
Protected methodCompute(Int32, Double, DistributionTail, NullableBoolean, Boolean)
Computes the Wilcoxon Signed-Rank test.
(Inherited from WilcoxonTest.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnSizeChanged
Called whenever the test significance level changes.
(Inherited from HypothesisTestTDistribution.)
Public methodPValueToStatistic
Converts a given p-value to a test statistic.
(Inherited from WilcoxonTest.)
Public methodStatisticToPValue
Converts a given test statistic to a p-value.
(Inherited from WilcoxonTest.)
Public methodToString
Converts the numeric P-Value of this test to its equivalent string representation.
(Inherited from HypothesisTestTDistribution.)
Public methodToString(String, IFormatProvider)
Converts the numeric P-Value of this test to its equivalent string representation.
(Inherited from HypothesisTestTDistribution.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

The Wilcoxon signed-rank test is a non-parametric statistical hypothesis test used when comparing two related samples, matched samples, or repeated measurements on a single sample to assess whether their population mean ranks differ (i.e. it is a paired difference test). It can be used as an alternative to the paired Student's t-test, t-test for matched pairs, or the t-test for dependent samples when the population cannot be assumed to be normally distributed.

The Wilcoxon signed-rank test is not the same as the Wilcoxon rank-sum test, although both are nonparametric and involve summation of ranks.

This test uses the positive W statistic, as explained in https://onlinecourses.science.psu.edu/stat414/node/319

References:

  • Wikipedia, The Free Encyclopedia. Wilcoxon signed-rank test. Available on: http://en.wikipedia.org/wiki/Wilcoxon_signed-rank_test

Examples
// This example has been adapted from the Wikipedia's page about
// the Z-Test, available from: http://en.wikipedia.org/wiki/Z-test

// We would like to check whether a sample of 20
// students with a median score of 96 points ...

double[] sample = 
{ 
    106, 115, 96, 88, 91, 88, 81, 104, 99, 68,
    104, 100, 77, 98, 96, 104, 82, 94, 72, 96
};

// ... could have happened just by chance inside a 
// population with an hypothesized median of 100 points.

double hypothesizedMedian = 100;

// So we start by creating the test:
WilcoxonSignedRankTest test = new WilcoxonSignedRankTest(sample,
  hypothesizedMedian, OneSampleHypothesis.ValueIsSmallerThanHypothesis);

// Now, we can check whether this result would be
// unlikely under a standard significance level:

bool significant = test.Significant; // false (so the event was likely)

// We can also check the test statistic and its P-Value
double statistic = test.Statistic; // 40.0
double pvalue = test.PValue; // 0.98585347446367344
See Also