/***********************************************************************

	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.incompleteConcordance;

import java.util.Arrays;

import javanpst.data.DataDefinitions;
import javanpst.data.structures.dataTable.DataTable;
import javanpst.distributions.common.continuous.ChiSquareDistribution;
import javanpst.distributions.common.continuous.NormalDistribution;
import javanpst.tests.StatisticalTest;

/**
 * A concordance coefficient-based test for incomplete classifications
 * 
 * This procedure test rankings correlation of k rank procedures
 * applied to incomplete classifications. Q statistic 
 * (approximated to a chi-square distribution) and W coefficient
 * (Kendall's coefficient of concordance) are provided.
 * 
 * Missing values are expressed as NULL values in the table
 * 
 * @author Joaqu�n Derrac Rus (jderrac@decsai.ugr.es)
 * @version 1.0
 */
public class IncompleteConcordance extends StatisticalTest{

	/**
	 * Data to analyze
	 */
	private DataTable data;

	/**
	 * Array of ranks
	 */
	private double ranks [][];
	
	/**
	 * Sum of ranks for each population
	 */
	private double sumRanks[];

	/**
	 * Parameters of the incomplete experiment
	 */
	private double k,n,m,lambda;
	
	/**
	 * Q statistic
	 */
	private double Q;
	
	/**
	 * W coefficient
	 */
	private double W;

	/**
	 * P-value
	 */
	private double pValue;
	
	/**
	 * Critical value at 0.90 confidence level
	 */
	private double criticalZ90;
	
	/**
	 * Critical value at 0.95 confidence level
	 */
	private double criticalZ95;
	
	/**
	 * Default builder
	 */
	public IncompleteConcordance(){
		
		setReportFormat();
		clearData();
		
	}//end-method
	
	/**
	 * Clears the data stored in the test
	 */
	public void clearData(){
		
		data=new DataTable();
		
		performed=false;
		dataReady=false;
		
		Q=0.0;
		W=0.0;

		ranks=null;
		sumRanks=null;
		
		pValue=-1.0;
		
	}//end-method
	
	/**
	 * Builder. Load data to test.
	 * 
	 * @param newData data to test.
	 * @param lambda number of objects ranked by each observer
	 */
	public IncompleteConcordance(DataTable newData,double lambda){
		
		setReportFormat();
		
		data=DataTable.newInstance(newData);
		
		if(data.getColumns()<3){
			System.out.println("Incomplete concordance test only can be employed with more than two samples");
			clearData();
			return;
		}
		
		n=data.getColumns();
		this.lambda=lambda;
		ranks=new double[data.getRows()][data.getColumns()];
		sumRanks=new double[data.getColumns()];
		
		m=0;
		
		double mAux;
		for(int i=0;i 

Ads help maintain this website.