/* nag_wilcoxon_test (g08agc) Example Program. * * Copyright 2000 Numerical Algorithms Group. * * Mark 6, 2000. */ #include #include #include #include int main (void) { double median, p, w, z, *x=0, *y=0, *data=0; Integer i, n, non_zero; Integer exit_status=0; NagError fail; INIT_FAIL(fail); Vprintf("g08agc Example Program Results"); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vscanf("%ld", &n); if (!(x = NAG_ALLOC(n, double)) || !(y = NAG_ALLOC(n, double)) || !(data = NAG_ALLOC(n, double))) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } for (i = 1; i <= n; ++i) Vscanf("%lf", &x[i - 1]); for (i = 1; i <= n; ++i) Vscanf("%lf", &y[i - 1]); Vprintf("\n\n"); Vprintf("%s\n", "Wilcoxon one sample signed ranks test"); Vprintf("\n"); Vprintf("%s", "Data values\n"); for (i = 1; i <= n; ++i) Vprintf("%5.1f%s", x[i - 1], i%8?"":"\n"); for (i = 1; i <= n; ++i) Vprintf("%5.1f%s", y[i - 1], i%8?"":"\n"); for (i = 1; i <= n; ++i) data[i - 1] = x[i - 1] - y[i - 1]; median = 0.0; g08agc(n, data, median, Nag_TwoTail, Nag_IncSignZerosN, &w, &z, &p, &non_zero, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from g08agc.\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("\n\n"); Vprintf("%s%8.4f\n", "Test statistic = ", w); Vprintf("%s%8.4f\n", "Normalized test statistic = ", z); Vprintf("%s%8ld\n","Degrees of freedom = ", non_zero); Vprintf("%s%8.4f\n", "Two tail probability = ", p); END: if (x) NAG_FREE(x); if (y) NAG_FREE(y); if (data) NAG_FREE(data); return exit_status; }