/***********************************************************************
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.multiple.concordanceCoefficient;
import java.util.Arrays;
import javanpst.data.structures.dataTable.DataTable;
import javanpst.tests.StatisticalTest;
import javanpst.distributions.common.continuous.ChiSquareDistribution;
/**
* A concordance coefficient-based test.
*
* This procedure test rankings correlation of k rank procedures.
* Q statistic (approximated to a chi-square distribution) and W coefficient
* (Kendall's coefficient of concordance) are provided.
*
* All samples must have the same number of values
*
* @author Joaqu�n Derrac Rus (jderrac@decsai.ugr.es)
* @version 1.0
*/
public class ConcordanceCoefficient extends StatisticalTest{
/**
* Data to analyze
*/
private DataTable data;
/**
* Populations samples
*/
private double samples [][];
/**
* Array of ranks
*/
private double ranks [][];
/**
* Sum of ranks for each population
*/
private double sumRanks[];
/**
* S statistic
*/
private double S;
/**
* Q statistic
*/
private double Q;
/**
* W coefficient
*/
private double W;
/**
* Reduction to variance of Q due to ties
*/
private double tiesWeight;
/**
* P-value
*/
private double pValue;
/**
* Default builder
*/
public ConcordanceCoefficient(){
setReportFormat();
clearData();
}//end-method
/**
* Clears the data stored in the test
*/
public void clearData(){
data=new DataTable();
performed=false;
dataReady=false;
S=0.0;
Q=0.0;
W=0.0;
samples=null;
ranks=null;
sumRanks=null;
pValue=-1.0;
}//end-method
/**
* Builder. Load data to test.
*
* @param newData data to test.
*/
public ConcordanceCoefficient(DataTable newData){
setReportFormat();
data=DataTable.newInstance(newData);
if(data.getColumns()<3){
System.out.println("Concordance coefficient test only can be employed with more than two samples");
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()];
ranks=new double[data.getRows()][data.getColumns()];
sumRanks=new double[data.getColumns()];
for(int i=0;i0){
System.out.println("No null values allowed in this test.");
clearData();
return;
}
}
samples=new double[data.getRows()][data.getColumns()];
ranks=new double[data.getRows()][data.getColumns()];
sumRanks=new double[data.getColumns()];
for(int i=0;imax)){
max=samples[i][j];
count=1;
}
}
if(count==1){
newRank=rank;
}
else{
tiesWeight+=count*((count*count)-1.0);
newRank=0.0;
for(int k=0;k
Ads help maintain this website.