/***********************************************************************
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.multinomialEqualityTest;
import java.util.Arrays;
import javanpst.data.structures.dataTable.DataTable;
import javanpst.distributions.common.continuous.ChiSquareDistribution;
import javanpst.tests.StatisticalTest;
/**
* A mutinomial equality test
*
* This test can be applied in 2 x K tables 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 not the same (non-directional).
*
* A chi-square approximation of the Q statistic is provided
*
* @author Joaqu�n Derrac Rus (jderrac@decsai.ugr.es)
* @version 1.0
*/
public class MultinomialEqualityTest extends StatisticalTest{
/**
* Data to analyze
*/
private DataTable data;
/**
* Multinomial samples
*/
private double samples [][];
/**
* Total number of elements
*/
private double N;
/**
* Q statistic
*/
private double Q;
/**
* P-value of the test
*/
private double pValue;
/**
* Default builder
*/
public MultinomialEqualityTest(){
setReportFormat();
clearData();
}//end-method
/**
* Clears the data stored in the test
*/
public void clearData(){
data=new DataTable();
performed=false;
dataReady=false;
Q=0.0;
samples=null;
pValue=-1.0;
}//end-method
/**
* Builder. Load data to test.
*
* @param newData data to test.
*/
public MultinomialEqualityTest(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
Ads help maintain this website.