Statistics.Test.WilcoxonT

statistics-0.13.3.0: A library of statistical types, data, and functions

Copyright | (c) 2010 Neil Brown
License | BSD3
Maintainer | bos@serpentine.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell98

Statistics.Test.WilcoxonT

Contents

- Wilcoxon signed-rank matched-pair test
- Data types

Description

The Wilcoxon matched-pairs signed-rank test is non-parametric test which could be used to whether two related samples have different means.

WARNING: current implementation contain serious bug and couldn't be used with samples larger than 1023. https://github.com/bos/statistics/issues/18

Synopsis

- wilcoxonMatchedPairTest :: TestType -> Double -> Sample -> Sample -> Maybe TestResult
- wilcoxonMatchedPairSignedRank :: Sample -> Sample -> (Double, Double)
- wilcoxonMatchedPairSignificant :: TestType -> Int -> Double -> (Double, Double) -> Maybe TestResult
- wilcoxonMatchedPairSignificance :: Int -> Double -> Double
- wilcoxonMatchedPairCriticalValue :: Int -> Double -> Maybe Int
- data TestType
  - = OneTailed
  - | TwoTailed
- data TestResult
  - = Significant
  - | NotSignificant

# Wilcoxon signed-rank matched-pair test

wilcoxonMatchedPairTest #

Arguments

:: TestType | Perform one-tailed test.
-> Double | The p-value at which to test (e.g. 0.05)
-> Sample | First sample
-> Sample | Second sample
-> Maybe TestResult | Return `Nothing` if the sample was too small to make a decision.

The Wilcoxon matched-pairs signed-rank test. The samples are zipped together: if one is longer than the other, both are truncated to the the length of the shorter sample.

For one-tailed test it tests whether first sample is significantly greater than the second. For two-tailed it checks whether they significantly differ

Check `wilcoxonMatchedPairSignedRank` and `wilcoxonMatchedPairSignificant` for additional information.

wilcoxonMatchedPairSignedRank :: Sample -> Sample -> (Double, Double) #

wilcoxonMatchedPairSignificant #

Arguments

:: TestType | Perform one- or two-tailed test (see description below).
-> Int | The sample size from which the (T+,T-) values were derived.
-> Double | The p-value at which to test (e.g. 0.05)
-> (Double, Double) | The (T+, T-) values from `wilcoxonMatchedPairSignedRank`.
-> Maybe TestResult | Return `Nothing` if the sample was too small to make a decision.

Tests whether a given result from a Wilcoxon signed-rank matched-pairs test is significant at the given level.

This function can perform a one-tailed or two-tailed test. If the first parameter to this function is `TwoTailed`, the test is performed two-tailed to check if the two samples differ significantly. If the first parameter is `OneTailed`, the check is performed one-tailed to decide whether the first sample (i.e. the first sample you passed to `wilcoxonMatchedPairSignedRank`) is greater than the second sample (i.e. the second sample you passed to `wilcoxonMatchedPairSignedRank`). If you wish to perform a one-tailed test in the opposite direction, you can either pass the parameters in a different order to `wilcoxonMatchedPairSignedRank`, or simply swap the values in the resulting pair before passing them to this function.

wilcoxonMatchedPairSignificance #

Arguments

:: Int | The sample size
-> Double | The value of T for which you want the significance.
-> Double | The significance (p-value).

Works out the significance level (p-value) of a T value, given a sample size and a T value from the Wilcoxon signed-rank matched-pairs test.

See the notes on `wilcoxonCriticalValue` for how this is calculated.

wilcoxonMatchedPairCriticalValue #

Arguments

:: Int | The sample size
-> Double | The p-value (e.g. 0.05) for which you want the critical value.
-> Maybe Int | The critical value (of T), or Nothing if the sample is too small to make a decision.

Obtains the critical value of T to compare against, given a sample size and a p-value (significance level). Your T value must be less than or equal to the return of this function in order for the test to work out significant. If there is a Nothing return, the sample size is too small to make a decision.

`wilcoxonSignificant` tests the return value of `wilcoxonMatchedPairSignedRank` for you, so you should use `wilcoxonSignificant` for determining test results. However, this function is useful, for example, for generating lookup tables for Wilcoxon signed rank critical values.

The return values of this function are generated using the method detailed in the paper "Critical Values for the Wilcoxon Signed Rank Statistic", Peter Mitic, The Mathematica Journal, volume 6, issue 3, 1996, which can be found here: http://www.mathematica-journal.com/issue/v6i3/article/mitic/contents/63mitic.pdf. According to that paper, the results may differ from other published lookup tables, but (Mitic claims) the values obtained by this function will be the correct ones.

# Data types

data TestType #

Test type. Exact meaning depends on a specific test. But generally it's tested whether some statistics is too big (small) for `OneTailed` or whether it too big or too small for `TwoTailed`

Constructors

OneTailed |
TwoTailed |

Instances

Eq TestType # |
Methods (==) :: TestType -> TestType -> Bool # (/=) :: TestType -> TestType -> Bool #
Data TestType # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TestType -> c TestType # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TestType # toConstr :: TestType -> Constr # dataTypeOf :: TestType -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c TestType) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TestType) # gmapT :: (forall b. Data b => b -> b) -> TestType -> TestType # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TestType -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TestType -> r # gmapQ :: (forall d. Data d => d -> u) -> TestType -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TestType -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TestType -> m TestType # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TestType -> m TestType # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TestType -> m TestType #
Ord TestType # |
Methods compare :: TestType -> TestType -> Ordering # (<) :: TestType -> TestType -> Bool # (<=) :: TestType -> TestType -> Bool # (>) :: TestType -> TestType -> Bool # (>=) :: TestType -> TestType -> Bool # max :: TestType -> TestType -> TestType # min :: TestType -> TestType -> TestType #
Show TestType # |
Methods showsPrec :: Int -> TestType -> ShowS # show :: TestType -> String # showList :: [TestType] -> ShowS #
Generic TestType # |
Associated Types type Rep TestType :: * -> * # Methods from :: TestType -> Rep TestType x # to :: Rep TestType x -> TestType #
FromJSON TestType # |
Methods parseJSON :: Value -> Parser TestType # parseJSONList :: Value -> Parser [TestType] #
ToJSON TestType # |
Methods toJSON :: TestType -> Value # toEncoding :: TestType -> Encoding # toJSONList :: [TestType] -> Value # toEncodingList :: [TestType] -> Encoding #
type Rep TestType # |
type Rep TestType = D1 (MetaData "TestType" "Statistics.Test.Types" "statistics-0.13.3.0-A6M5lvDj6Zg1bzI7OU7tSj" False) ((:+:) (C1 (MetaCons "OneTailed" PrefixI False) U1) (C1 (MetaCons "TwoTailed" PrefixI False) U1))

data TestResult #

Result of hypothesis testing

Constructors

Significant | Null hypothesis should be rejected
NotSignificant | Data is compatible with hypothesis

Instances

Eq TestResult # |
Methods (==) :: TestResult -> TestResult -> Bool # (/=) :: TestResult -> TestResult -> Bool #
Data TestResult # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TestResult -> c TestResult # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TestResult # toConstr :: TestResult -> Constr # dataTypeOf :: TestResult -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c TestResult) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TestResult) # gmapT :: (forall b. Data b => b -> b) -> TestResult -> TestResult # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TestResult -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TestResult -> r # gmapQ :: (forall d. Data d => d -> u) -> TestResult -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TestResult -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TestResult -> m TestResult # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TestResult -> m TestResult # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TestResult -> m TestResult #
Ord TestResult # |
Methods compare :: TestResult -> TestResult -> Ordering # (<) :: TestResult -> TestResult -> Bool # (<=) :: TestResult -> TestResult -> Bool # (>) :: TestResult -> TestResult -> Bool # (>=) :: TestResult -> TestResult -> Bool # max :: TestResult -> TestResult -> TestResult # min :: TestResult -> TestResult -> TestResult #
Show TestResult # |
Methods showsPrec :: Int -> TestResult -> ShowS # show :: TestResult -> String # showList :: [TestResult] -> ShowS #
Generic TestResult # |
Associated Types type Rep TestResult :: * -> * # Methods from :: TestResult -> Rep TestResult x # to :: Rep TestResult x -> TestResult #
FromJSON TestResult # |
Methods parseJSON :: Value -> Parser TestResult # parseJSONList :: Value -> Parser [TestResult] #
ToJSON TestResult # |
Methods toJSON :: TestResult -> Value # toEncoding :: TestResult -> Encoding # toJSONList :: [TestResult] -> Value # toEncodingList :: [TestResult] -> Encoding #
type Rep TestResult # |
type Rep TestResult = D1 (MetaData "TestResult" "Statistics.Test.Types" "statistics-0.13.3.0-A6M5lvDj6Zg1bzI7OU7tSj" False) ((:+:) (C1 (MetaCons "Significant" PrefixI False) U1) (C1 (MetaCons "NotSignificant" PrefixI False) U1))