/* nag_chi_sq_2_way_table(g11aac) Example Program. * * Copyright 1996 Numerical Algorithms Group. * * Mark 4, 1996. * */ #include #include #include #include #define RMAX 3 #define CMAX 3 #define TDA CMAX int main(void) { double prob, expt[RMAX][CMAX]; double g; double chist[RMAX][CMAX]; double df, chi; Integer ncol; Integer nrow; Integer i, j; Integer nobst[RMAX][CMAX]; Integer tda = TDA; Vprintf("g11aac Example Program Results\n\n"); /* Skip heading in data file */ Vscanf("%*[^\n] "); Vscanf("%ld %ld %*[^\n] ", &nrow, &ncol); if (nrow <= RMAX && ncol <= CMAX) { for (i = 0; i < nrow; ++i) { for (j = 0; j < ncol; ++j) Vscanf("%ld", &nobst[i][j]); Vscanf("%*[^\n]"); } g11aac(nrow, ncol, &nobst[0][0], tda, &expt[0][0], &chist[0][0], &prob, &chi, &g, &df, NAGERR_DEFAULT); Vprintf("Probability = %6.4f\n", prob); Vprintf("Pearson Chi-square statistic = %8.3f\n", chi); Vprintf("Likelihood ratio test statistic = %8.3f\n", g); Vprintf("Degrees of freedom = %4.0f\n", df); } return EXIT_SUCCESS; }