/** * Returns chi-squared probability for a given matrix. * * @param matrix the contigency table * @param yates is Yates' correction to be used? * @return the chi-squared probability */ public static double chiSquared(double [][] matrix, boolean yates) { int df = (matrix.length - 1) * (matrix[0].length - 1); return Statistics.chiSquaredProbability(chiVal(matrix, yates), df); }
/** * Returns chi-squared probability for a given matrix. * * @param matrix the contigency table * @param yates is Yates' correction to be used? * @return the chi-squared probability */ public static double chiSquared(double [][] matrix, boolean yates) { int df = (matrix.length - 1) * (matrix[0].length - 1); return Statistics.chiSquaredProbability(chiVal(matrix, yates), df); }
/** * Computes Cramer's V for a contingency table. * * @param matrix the contingency table * @return Cramer's V */ public static double CramersV(double [][] matrix) { int row, col, nrows,ncols, min; double n = 0; nrows = matrix.length; ncols = matrix[0].length; for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { n += matrix[row][col]; } } min = nrows < ncols ? nrows-1 : ncols-1; if ((min == 0) || Utils.eq(n, 0)) return 0; return Math.sqrt(chiVal(matrix, false) / (n * (double)min)); }
/** * Computes Cramer's V for a contingency table. * * @param matrix the contingency table * @return Cramer's V */ public static double CramersV(double [][] matrix) { int row, col, nrows,ncols, min; double n = 0; nrows = matrix.length; ncols = matrix[0].length; for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { n += matrix[row][col]; } } min = nrows < ncols ? nrows-1 : ncols-1; if ((min == 0) || Utils.eq(n, 0)) return 0; return Math.sqrt(chiVal(matrix, false) / (n * (double)min)); }
for (int j = i + 1; j < counts.length; j++) { reducedCounts[1] = counts[j]; double val = ContingencyTables.chiVal(reducedCounts, true); if (val < minVal) { minVal = val; double val = ContingencyTables.chiVal(counts, true); int df = (counts[0].length - 1) * (counts.length - 1); double originalSig = Statistics.chiSquaredProbability(val, df);
for (int j = i + 1; j < counts.length; j++) { reducedCounts[1] = counts[j]; double val = ContingencyTables.chiVal(reducedCounts, true); if (val < minVal) { minVal = val; double val = ContingencyTables.chiVal(counts, true); int df = (counts[0].length - 1) * (counts.length - 1); double originalSig = Statistics.chiSquaredProbability(val, df);
ContingencyTables.chiSquared(matrix, false)); System.out.println("Chi-squared value: " + ContingencyTables.chiVal(matrix, false)); System.out.println("Cochran's criterion fullfilled: " + ContingencyTables.cochransCriterion(matrix));
ContingencyTables.chiSquared(matrix, false)); System.out.println("Chi-squared value: " + ContingencyTables.chiVal(matrix, false)); System.out.println("Cochran's criterion fullfilled: " + ContingencyTables.cochransCriterion(matrix));
for (int i = 0; i < data.numAttributes(); i++) { if (i != classIndex) { m_ChiSquareds[i] = ContingencyTables.chiVal( ContingencyTables.reduceMatrix(counts[i]), false);