/***********************************************************************
This file is part of JavaNPST, a Java library of NonParametric
Statistical Tests.
Copyright (C) 2011
J. Derrac (jderrac@decsai.ugr.es)
S. Garcia (sglopez@ujaen.es)
F. Herrera (herrera@decsai.ugr.es)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
**********************************************************************/
package javanpst.tests.countData.orderedEqualityTest;
import java.util.Arrays;
import javanpst.data.structures.dataTable.DataTable;
import javanpst.distributions.common.continuous.NormalDistribution;
import javanpst.tests.StatisticalTest;
/**
* A multinomial equality test for ordered categories
*
* This test can be applied in 2 x K tables with ordered categories,
* with the aim of testing if column probabilities are the same, that is, if
* p11=p12, p21 = p22, .. , p1k = p2k. Alternative is that
* probabilities are in increasing or decreasing order (directional).
*
* A normal approximation, through a modification of the Wilcoxon rank-sum statistic
* (Mann-Whitney statistic) is provided for all the alternatives.
*
* @author Joaqu�n Derrac Rus (jderrac@decsai.ugr.es)
* @version 1.0
*/
public class OrderedEqualityTest extends StatisticalTest{
/**
* Data to analyze
*/
private DataTable data;
/**
* Multinomial samples
*/
private double samples [][];
/**
* Total number of elements
*/
private double N;
/**
* W statistic for first row (x)
*/
private double Wx;
/**
* W statistic for second row (y)
*/
private double Wy;
/**
* Z value for right tail
*/
private double Zright;
/**
* Z value for left tail
*/
private double Zleft;
/**
* P-value for right tail
*/
private double asymptoticRightTail;
/**
* P-value for left tail
*/
private double asymptoticLeftTail;
/**
* P-value for double tail
*/
private double asymptoticDoubleTail;
/**
* Default builder
*/
public OrderedEqualityTest(){
setReportFormat();
clearData();
}//end-method
/**
* Clears the data stored in the test
*/
public void clearData(){
data=new DataTable();
performed=false;
dataReady=false;
Wx=0.0;
Wy=0.0;
samples=null;
asymptoticRightTail=-1.0;
asymptoticLeftTail=-1.0;
asymptoticDoubleTail=-1.0;
}//end-method
/**
* Builder. Load data to test.
*
* @param newData data to test.
*/
public OrderedEqualityTest(DataTable newData){
setReportFormat();
data=DataTable.newInstance(newData);
if((data.getRows()>2)||(data.getRows()<2)){
System.out.println("Data must be represented in two rows");
clearData();
return;
}
for(int i=0;i0){
System.out.println("No null values allowed in this test.");
clearData();
return;
}
}
samples=new double[data.getRows()][data.getColumns()];
for(int i=0;i2)||(data.getRows()<2)){
System.out.println("Data must be represented in two rows");
clearData();
return;
}
for(int i=0;i0){
System.out.println("No null values allowed in this test.");
clearData();
return;
}
}
samples=new double[data.getRows()][data.getColumns()];
for(int i=0;i X) :"+nf6.format(asymptoticLeftTail)+"\n";
report+="Right tail p-Value (X > Y) :"+nf6.format(asymptoticRightTail)+"\n";
report+="Double tail p-Value (X != Y) :"+nf6.format(asymptoticDoubleTail)+"\n\n";
report+="Contingency table\n\n";
//First row
for(int j=0;j
Ads help maintain this website.