org.statcato.statistics.inferential.nonparametrics
Class WilcoxonRankSumTest

java.lang.Object
  extended by org.statcato.statistics.inferential.nonparametrics.WilcoxonRankSumTest

public class WilcoxonRankSumTest
extends java.lang.Object

Wilcoxon Rank Sum test. A nonparametic test that uses ranks of samples from two independent populations to test a claim about the medians of two populations. The two independent samples are combined into one sample, are sorted in ascending order and are ranked based on its place in the one sample. The sum of the ranks corresponding to one of the two samples are computed and is used as test statistics.

Since:
1.0
Version:
%I%, %G%
Author:
Margaret Yau

Field Summary
 double significance
          Significance of the test.
 
Constructor Summary
WilcoxonRankSumTest(java.util.Vector<java.lang.Double> data1, java.util.Vector<java.lang.Double> data2, int testType, double significance)
          Constructor, given two samples of data values.
 
Method Summary
 double criticalValue_R()
           
 double getRankSum(java.util.Vector<java.lang.Double> data1, java.util.Vector<java.lang.Double> data2)
          Returns the rank sum, which is the sum of ranks for the first sample.
 double mu_R()
          Returns the mean of the distribution of rank sum, mu = n1 * (n1 + n2 + 1) / 2.
 double pValue_R()
          Returns the p-value.
 double sigma_R()
          Returns the standard deviation of the distribution of rank sum, sigma = (n1 * n2 * (n1 + n2 + 1) / 12)^0.5
 double testStatistic_R()
          Returns the test statistic z = (R - mu) / sigma, where R is the rank sum of the first same, mu the mean of the distribution of rank sum, and sigma the standard deviatioin of the distribution of rank sum.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

significance

public double significance
Significance of the test.

Constructor Detail

WilcoxonRankSumTest

public WilcoxonRankSumTest(java.util.Vector<java.lang.Double> data1,
                           java.util.Vector<java.lang.Double> data2,
                           int testType,
                           double significance)
Constructor, given two samples of data values.

Parameters:
data1 - vector of double values (sample 1)
data2 - vector of double values (sample 2)
testMedian - hypothesized median
testType - type of alternative hypothesis
Method Detail

testStatistic_R

public double testStatistic_R()
Returns the test statistic z = (R - mu) / sigma, where R is the rank sum of the first same, mu the mean of the distribution of rank sum, and sigma the standard deviatioin of the distribution of rank sum.

Returns:
test statistic z

mu_R

public double mu_R()
Returns the mean of the distribution of rank sum, mu = n1 * (n1 + n2 + 1) / 2.

Returns:
mean

sigma_R

public double sigma_R()
Returns the standard deviation of the distribution of rank sum, sigma = (n1 * n2 * (n1 + n2 + 1) / 12)^0.5

Returns:
standard deviation

pValue_R

public double pValue_R()
Returns the p-value.

Returns:
p-value

criticalValue_R

public double criticalValue_R()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getRankSum

public double getRankSum(java.util.Vector<java.lang.Double> data1,
                         java.util.Vector<java.lang.Double> data2)
Returns the rank sum, which is the sum of ranks for the first sample. Ranks are computed after the two samples are combined and sorted in ascending order.

Parameters:
data - vector of Double values
Returns:
rank sum