/* nag_friedman_test (g08aec) Example Program. * * Copyright 2000 Numerical Algorithms Group. * * Mark 6, 2000. */ #include #include #include #include int main (void) { Integer exit_status=0, i, ix, j, k, n; NagError fail; double fr, sig, *x=0; #define X(I,J) x[((I)-1)*n +(J)-1] INIT_FAIL(fail); Vprintf("nag_friedman_test (g08aec) Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); n = 18; k = 3; ix = k; if (!(x = NAG_ALLOC(ix*n, double))) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } for (i = 1; i <= ix; ++i) for (j = 1; j <= n; ++j) Vscanf("%lf", &X(i,j)); Vprintf("\nFriedman test\n"); Vprintf("\nData values\n"); Vprintf("\n Group Group Group\n"); Vprintf(" 1 2 3\n"); for (j = 1; j <= 18; ++j) { for (i = 1; i <= 3; ++i) Vprintf("%7.1f", X(i,j)); Vprintf("\n"); } /* nag_friedman_test (g08aec). * Friedman two-way analysis of variance on k matched * samples */ nag_friedman_test(k, n, x, n, &fr, &sig, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from nag_friedman_test (g08aec).\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("\n"); Vprintf("%s%6.3f\n", "Test statistic ", fr); Vprintf("%s%6ld\n", "Degrees of freedom ", k-1); Vprintf("%s%6.3f\n", "Significance ", sig); END: if (x) NAG_FREE(x); return exit_status; }