|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectJavaGrinders.ContingencyTable
public class ContingencyTable
contains a crosstabulation frequency table and performs a variety of statistics on it, including G-test, Chi-square, mantel, Kendall's Tau, etc.
| Field Summary | |
|---|---|
boolean |
diagonal
|
int |
iterated
|
double |
itsTotalSum
|
int |
MatrixCols
|
int |
MatrixRows
|
int |
NUM_MAXITERATOR
|
int |
PRECISIONMULT
|
| Constructor Summary | |
|---|---|
ContingencyTable(double[][] theArray)
standard constructor for the ContingencyTable class |
|
ContingencyTable(double[][] theArray,
boolean diagonal)
standard constructor for the ContingencyTable class |
|
ContingencyTable(int MatrixCols,
int MatrixRows,
boolean diagonal)
standard constructor for the ContingencyTable class |
|
ContingencyTable(int MatrixCols,
int MatrixRows,
boolean diagonal,
java.lang.String theName)
standard constructor for the ContingencyTable class |
|
ContingencyTable(int MatrixCols,
int MatrixRows,
java.lang.String theName)
standard constructor for the ContingencyTable class |
|
ContingencyTable(Matrix aMatrix,
boolean diagonal)
constructor for the ContingencyTable class with a JAMA Matrix provided |
|
| Method Summary | |
|---|---|
double[][] |
as2DdoubleArray()
returns the private array of data values for the ContingencyTable |
java.lang.String[][] |
as2DStringArray()
returns the private array of data values for the ContingencyTable |
Matrix |
asJAMAMatrix()
returns the private array of data values for the ContingencyTable |
ContTableResults |
calcContingencyResults(ContingencyTable expectMatrix)
calculates the test of independence and returns ChiSquare and GValue |
GoodnessOfFitResults |
calcGoodnessOfFitResults()
calculates the test of independence and returns ChiSquare and GValue |
boolean |
checkForColumnPs()
checks whether column probabiities have been set |
boolean |
checkMatchingMatrixDimensions(ContingencyTable BTable)
examine whether this matrix has the same dimensions as the one provided? |
void |
checkMatrix()
examines the matrix for invalid entries |
boolean |
checkSquare()
is matrix square? |
void |
clearColumnPs()
clears the external probabilities |
void |
clearPs()
clears the external probabilities |
void |
clearSums()
zero the sums for rows, columns, and total of the ContingencyTable |
void |
clearTable()
zero the sums for all individual cells of the ContingencyTable |
void |
clearTablePs()
clears the external probabilities |
java.lang.Object |
clone()
clone the object |
java.lang.String |
colToString(int col)
returns the formatted object as a string |
double |
DoWilliamsCorr()
calculates the William's correction |
int |
fillPerms()
fills the array with all possible (or desired) permutations |
void |
fillSums()
calculate sums for rows, columns and total of the ContingencyTable |
DataTable |
fold(double[] cells,
int rows,
int cols,
boolean diag)
folds an array of doubles into a DataTable and returns the object |
double |
getCellValue(int xLoc,
int yLoc)
returns the double from one element of this matrix |
java.lang.String |
getColLabel(int column)
returns a particular column label for the ContingencyTable |
java.lang.String[] |
getColLabels()
returns column labels for the ContingencyTable |
double |
getColSum(int col)
returns the sum for a particular row of the table |
double[] |
getColSums()
returns the row sums of the table |
double[] |
getColumnPs()
returns the dimensions of the Table |
ContTableResults |
getContingencyTableResults()
returns the results for a test of independence with expected frequencies calculated from observed |
ContTableResults |
getContingencyTableResults(ContingencyTable expectMatrix)
returns the results for a test of independence with the provided expected values |
int |
getdf()
returns the degrees of freedom for the ContingencyTable |
ContingencyTable |
getDifferenceTable(ContingencyTable bTable)
returns a matrix of dominance relationships between actor and receiver |
double[][] |
getDominanceMatrix()
returns a matrix of dominance relationships between actor and receiver |
ContingencyTable |
getExpectedMatrix()
returns a matrix of expected values for a test of independence |
ContingencyTable |
getExpectedMatrix(boolean aDiagonal)
returns a matrix of expected values for a test of independence |
DataTable |
getExpMatrixDia()
returns a matrix of expected values for a test of independence |
DataTable |
getExpMatrixFromProbabilities()
returns a matrix of expected values for a test of independence |
ContingencyTable |
getExpMatrixNoDia()
returns a matrix of expected values for a test of independence if the diagonal is structurally zero |
DataTable |
getFTukeyDeviates()
returns Freeman-Tukey deviates for a cell wise examination of the table |
GoodnessOfFitResults |
getGoodnessOfFitResults()
coordinates a replicated goodness of fit test |
double |
getMantelP(ContingencyTable BTable,
double actualMantelNumber)
performs Mantel's test with number of permutations limited by MaxPermutations |
double |
getMantelZ(ContingencyTable BTable)
calculate Mantel's Z statistic for a matrix and a second matrix passed in |
int |
getMatrixSize()
returns the dimensions of the Table |
java.lang.String |
getName()
returns the dimensions of the Table |
int |
getNCells()
returns the total number of cells for the ContingencyTable |
int |
getNCols()
returns the number of columns of the Table |
double[][] |
getNoZeroCellMatrix()
returns the values from the matrix with a constant of 0.25 added to each cell |
int |
getNRows()
returns the number of rows of the Table |
ContingencyTable |
getPermutedTable(int[] permOrder)
gets a variant of the interactionTable with rows and columns switched with a given permutation |
ContingencyTable |
getpropMatrixDia()
returns a matrix of expected values for proportional fitting with diagonal present |
ContingencyTable |
getpropMatrixNoDia()
returns a matrix of expected values for proportional fitting with diagonal absent (see Bishop et al., 1975; following Freeman, 1992) |
java.lang.String |
getRowLabel(int row)
returns a particular row label for the ContingencyTable |
java.lang.String[] |
getRowLabels()
returns row labels for the ContingencyTable |
double |
getRowSum(int row)
returns the sum for a particular row of the table |
double[] |
getRowSums()
returns the row sums of the table |
double[][] |
getTablePs()
returns the dimensions of the Table |
double |
getTauKr()
organize a TauKr test for a correlation between actor and receiver matrix |
double |
getTauKrP(double actualKrNumber)
performs the Kr test with number of permutations limited by MaxPermutations |
double[][] |
getTotalsMatrix()
returns a matrix in which cells from actor and receiver section of the ContingencyTable have been summed into a total cell value |
double |
getTotalSum()
returns the sum for a particular row of the table |
int |
getZeroCells()
returns the number of empty cells for the ContingencyTable |
int |
howManyPossiblePermutations()
calculates the number of possible permutations |
void |
incrementCellValue(int xLoc,
int yLoc)
increments a single cell for this matrix by one |
ContingencyTable |
invertTable()
inverts the table with rows to colums and colums to rows |
boolean |
isMatchingMatrix(ContingencyTable BTable)
is this matrix the same as the one provided? |
boolean |
isSquare()
is matrix square? |
void |
listContingencyResults()
does the test and returns its results |
void |
listExpectedTable()
lists a matrix of expected values |
void |
listFTukeyDeviates()
lists Freeman-Tukey deviates for a cell wise examination of the table |
void |
listGoodnessOfFitResults()
reports the results for a replicated goodness of fit test with external hypothesis probabilities |
void |
listMantelZResults(ContingencyTable BTable)
lists Mantel's Z for the table |
void |
listTable()
lists the table |
void |
listTable(boolean doSums)
lists the table |
void |
listTauKrResults()
lists the Tau Kr for the table |
java.lang.String |
noSumsToString()
returns the formatted table without sums as a string |
java.lang.String |
rowToString(int row)
returns the formated object as a string |
void |
set2DArray(double[][] inMatrix)
sets a 2D array of doubles for the ContingencyTable |
void |
setCellValue(int xLoc,
int yLoc,
double inValue)
sets a single element for this matrix with a double |
void |
setColLabel(int column,
java.lang.String aString)
returns a particular column label for the ContingencyTable |
void |
setColLabels(java.lang.String[] Labels)
sets new row and column labels for the ContingencyTable |
void |
setColLabels(java.util.TreeMap Labels)
sets new row and column labels for the ContingencyTable |
void |
setColumnPs(double[] thePs)
sets the expected probabilities for different columns |
void |
setDefaultRowColLabels()
sets default labels for row and column labels for the ContingencyTable |
void |
setDiagonal(boolean diagonal)
sets the diagonal of the ContingencyTable |
void |
setMatrixDimensions(int MatrixCols,
int MatrixRows,
boolean diagonal)
sets new matrix dimensions for the ContingencyTable |
void |
setMatrixSize(int MatrixSize)
sets the dimensions of the DominanceTable |
void |
setName(java.lang.String theName)
sets the name for the ContingencyTable |
void |
setRowColLabels(java.lang.String[] Labels)
sets new row and column labels for the ContingencyTable |
void |
setRowColLabels(java.util.TreeMap Labels)
sets new row and column labels for the ContingencyTable |
void |
setRowLabel(int row,
java.lang.String aString)
returns a particular column label for the ContingencyTable |
void |
setRowLabels(java.lang.String[] Labels)
sets new row and column labels for the ContingencyTable |
void |
setRowLabels(java.util.TreeMap Labels)
sets new row and column labels for the ContingencyTable |
void |
setTablePs(double[][] theTPs)
sets the expected probabilities for different columns |
double |
TauKr(ContingencyTable BTable)
calculate Kendal's tau statistic for a matrix and a second matrix passed in |
void |
toFile(java.io.BufferedWriter bw)
writes a ContingencyTable into the writer for a file |
java.lang.String |
toString(boolean doSums)
returns the formatted object as a string |
ContingencyTable |
transpose()
transposes the table between X and Y dimensions |
double[] |
unfold()
unfold the table into an array of doubles |
double[] |
unfoldUpperTriangle()
unfold the upper triangle of the table into an array of doubles |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final int NUM_MAXITERATOR
public int PRECISIONMULT
public int MatrixRows
public int MatrixCols
public double itsTotalSum
public boolean diagonal
public int iterated
| Constructor Detail |
|---|
public ContingencyTable(int MatrixCols,
int MatrixRows,
boolean diagonal,
java.lang.String theName)
MatrixCols - number of columns in the tableMatrixRows - number of rows in the tablediagonal - does the table have a diagonal?theName - the name of the table
public ContingencyTable(int MatrixCols,
int MatrixRows,
boolean diagonal)
MatrixCols - number of columns in the tableMatrixRows - number of rows in the tablediagonal - does the table have a diagonal?
public ContingencyTable(int MatrixCols,
int MatrixRows,
java.lang.String theName)
MatrixCols - number of columns in the tableMatrixRows - number of rows in the tablepublic ContingencyTable(double[][] theArray)
theArray - the 2D array to install into the Table
public ContingencyTable(double[][] theArray,
boolean diagonal)
theArray - the array to install into the Tablediagonal - does the table have a diagonal?
public ContingencyTable(Matrix aMatrix,
boolean diagonal)
aMatrix - a JAMA matrixdiagonal - does the table have a diagonal?| Method Detail |
|---|
public java.lang.String getName()
public void setName(java.lang.String theName)
theName - the name of the table
public boolean checkForColumnPs()
throws java.lang.Exception
java.lang.Exceptionpublic double[] getColumnPs()
public double[][] getTablePs()
public void setTablePs(double[][] theTPs)
throws java.lang.Exception
theTPs - the array of probabilities
java.lang.Exception
public void setColumnPs(double[] thePs)
throws java.lang.Exception
thePs - the array of probabilities
java.lang.Exceptionpublic void clearColumnPs()
public void clearTablePs()
public void clearPs()
public void setMatrixDimensions(int MatrixCols,
int MatrixRows,
boolean diagonal)
throws java.lang.Exception
MatrixCols - number of columns in the tableMatrixRows - number of rows in the tablediagonal - does the table have a diagonal?
java.lang.Exceptionpublic int getMatrixSize()
public void setMatrixSize(int MatrixSize)
MatrixSize - number of rows and columns in the tablepublic int getNRows()
public int getNCols()
public void setDiagonal(boolean diagonal)
diagonal - does the table contain a diagonal?public void setDefaultRowColLabels()
public void setRowColLabels(java.util.TreeMap Labels)
Labels - the distinct IDs for columns and rowspublic void setRowColLabels(java.lang.String[] Labels)
Labels - the distinct IDs for columns and rowspublic void setRowLabels(java.util.TreeMap Labels)
Labels - the distinct IDs for rowspublic void setRowLabels(java.lang.String[] Labels)
Labels - the distinct IDs for rowspublic void setColLabels(java.util.TreeMap Labels)
Labels - the distinct IDs for columnspublic void setColLabels(java.lang.String[] Labels)
Labels - the distinct IDs for rowspublic java.lang.String[] getRowLabels()
public java.lang.String[] getColLabels()
public void setColLabel(int column,
java.lang.String aString)
column - the column of the tableaString - the string to setpublic java.lang.String getColLabel(int column)
column - the column of the table
public void setRowLabel(int row,
java.lang.String aString)
row - the row of the tableaString - the string to setpublic java.lang.String getRowLabel(int row)
row - the row of the table
public void checkMatrix()
throws java.lang.Exception
java.lang.Exception
public boolean isSquare()
throws java.lang.Exception
java.lang.Exception
public boolean checkSquare()
throws java.lang.Exception
java.lang.Exception
public boolean checkMatchingMatrixDimensions(ContingencyTable BTable)
throws java.lang.Exception
BTable - a ContingencyTable to compare with
java.lang.Exceptionpublic boolean isMatchingMatrix(ContingencyTable BTable)
BTable - a ContingencyTable to compare with
public void set2DArray(double[][] inMatrix)
throws java.lang.Exception
inMatrix - 2D array of doubles to fill the table
java.lang.Exceptionpublic double[][] as2DdoubleArray()
public java.lang.String[][] as2DStringArray()
public Matrix asJAMAMatrix()
public void setCellValue(int xLoc,
int yLoc,
double inValue)
xLoc - x Capture in gridyLoc - y Capture in gridinValue - double value to set
public void incrementCellValue(int xLoc,
int yLoc)
xLoc - x Capture in gridyLoc - y Capture in grid
public double getCellValue(int xLoc,
int yLoc)
xLoc - x Capture in gridyLoc - y Capture in gridpublic void clearSums()
public void clearTable()
public void fillSums()
public double[] getRowSums()
public double getRowSum(int row)
throws java.lang.Exception
java.lang.Exceptionpublic double[] getColSums()
public double getColSum(int col)
throws java.lang.Exception
java.lang.Exception
public double getTotalSum()
throws java.lang.Exception
java.lang.Exception
public ContingencyTable transpose()
throws java.lang.Exception
java.lang.Exception
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic double[][] getTotalsMatrix()
public double[][] getNoZeroCellMatrix()
public ContingencyTable getDifferenceTable(ContingencyTable bTable)
public double[][] getDominanceMatrix()
public DataTable getExpMatrixDia()
throws java.lang.Exception
java.lang.Exception
public DataTable getExpMatrixFromProbabilities()
throws java.lang.Exception
java.lang.Exceptionpublic void listExpectedTable()
public ContingencyTable getExpectedMatrix()
public ContingencyTable getExpectedMatrix(boolean aDiagonal)
public ContingencyTable getExpMatrixNoDia()
throws java.lang.Exception
java.lang.Exception
public ContingencyTable getpropMatrixDia()
throws java.lang.Exception
java.lang.Exception
public ContingencyTable getpropMatrixNoDia()
throws java.lang.Exception
java.lang.Exceptionpublic void listFTukeyDeviates()
public DataTable getFTukeyDeviates()
throws java.lang.Exception
java.lang.Exceptionpublic int getdf()
public int getZeroCells()
public int getNCells()
public double DoWilliamsCorr()
public ContTableResults calcContingencyResults(ContingencyTable expectMatrix)
throws java.lang.Exception
expectMatrix - a ContingencyTable with
the matrix of expected values
java.lang.Exception
public ContTableResults getContingencyTableResults()
throws java.lang.Exception
java.lang.Exception
public ContTableResults getContingencyTableResults(ContingencyTable expectMatrix)
throws java.lang.Exception
expectMatrix - a ContingencyTable with
the matrix of exp0ected values
java.lang.Exceptionpublic void listContingencyResults()
public GoodnessOfFitResults calcGoodnessOfFitResults()
throws java.lang.Exception
java.lang.Exception
public GoodnessOfFitResults getGoodnessOfFitResults()
throws java.lang.Exception
java.lang.Exceptionpublic void listGoodnessOfFitResults()
public ContingencyTable invertTable()
public double getTauKr()
public double TauKr(ContingencyTable BTable)
BTable - second ContingencyTable for the TauKr value
public double getMantelZ(ContingencyTable BTable)
throws java.lang.Exception
BTable - second ContingencyTable for the correlation
java.lang.Exception
public double[] unfold()
throws java.lang.Exception
java.lang.Exception
public double[] unfoldUpperTriangle()
throws java.lang.Exception
java.lang.Exception
public DataTable fold(double[] cells,
int rows,
int cols,
boolean diag)
throws java.lang.Exception
cells - the numbers to fill into the cells of the tablerows - the number of rows for the tablecols - the number of columns for the tablediag - does the table have a diagonal?
java.lang.Exception
public int howManyPossiblePermutations()
throws java.lang.Exception
java.lang.Exception
public ContingencyTable getPermutedTable(int[] permOrder)
throws java.lang.Exception
permOrder - indicates a particular permutation
java.lang.Exception
public int fillPerms()
throws java.lang.Exception
java.lang.Exceptionpublic double getTauKrP(double actualKrNumber)
actualKrNumber - empirically derived TauKr
public double getMantelP(ContingencyTable BTable,
double actualMantelNumber)
BTable - second ContingencyTable for the TauKr valueactualMantelNumber - empirically derived Mantels' zpublic void listTauKrResults()
public void listMantelZResults(ContingencyTable BTable)
BTable - second ContingencyTable for the TauKr valuepublic java.lang.String rowToString(int row)
row - the rowpublic java.lang.String colToString(int col)
col - the columpublic java.lang.String toString(boolean doSums)
public java.lang.String noSumsToString()
public void listTable()
public void listTable(boolean doSums)
doSums - specifies whether to include sums
public void toFile(java.io.BufferedWriter bw)
throws java.lang.Exception
bw - the BufferedWriter to write into
java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||