/* nag_anova_random}(g04bbc) Example Program. * * Copyright 1998 Numerical Algorithms Group. * * Mark 5, 1998. * * Mark 6 revised, 2000. */ #include #include #include #include #define NMAX 30 #define NTMAX 6 #define NBMAX 10 #define TMAX 4 #define TDT TMAX #define TDC NTMAX int main(void) { double bmean[NBMAX], c[NTMAX][NTMAX], ef[NTMAX], r[NMAX], table[4][5], tmean[NTMAX],y[NMAX]; double gmean; double tol; Integer irep[NTMAX], it[NMAX]; Integer irdf; Integer i, j, n; Integer nt, nblock; Integer tdc = TDC; Vprintf("g04bbc Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n] "); Vscanf("%ld%ld%ld%*[^\n] ",&n, &nt, &nblock); if (n <= NMAX) { for (i = 0; i < n; ++i) Vscanf("%lf",&y[i]); Vscanf("%*[^\n]"); for (i = 0; i < n; ++i) Vscanf("%ld",&it[i]); Vscanf("%*[^\n]"); tol = 5e-6; irdf = 0; g04bbc(n, y, Nag_SerialBlocks, nblock, nt, it, &gmean, bmean, tmean, &table[0][0], &c[0][0], tdc, irep, r, ef, tol, irdf, NAGERR_DEFAULT); Vprintf("\nANOVA table\n\n"); Vprintf(" Source df SS MS F" " Prob\n\n"); Vprintf(" Blocks "); for (j = 0; j < 5; ++j) Vprintf("%10.4f ",table[0][j]); Vprintf("\n"); Vprintf(" Treatments "); for (j = 0; j < 5; ++j) Vprintf("%10.4f ",table[1][j]); Vprintf("\n"); Vprintf(" Residual "); for (j = 0; j < 3; ++j) Vprintf("%10.4f ",table[2][j]); Vprintf("\n"); Vprintf(" Total "); for (j = 1; j <= 2; ++j) Vprintf("%10.4f ",table[3][j-1]); Vprintf("\n"); Vprintf("\nEfficiency Factors\n\n"); for (i = 0; i < nt; ++i) Vprintf("%10.5f",ef[i]); Vprintf("\n"); Vprintf("\n%s%10.5f\n"," Grand Mean",gmean); Vprintf("\nTreatment Means\n\n"); for (i = 1; i <= nt; ++i) Vprintf("%10.5f",tmean[i-1]); Vprintf("\n"); Vprintf("\nStandard errors of differences between means\n\n"); for (i = 1; i < nt; ++i) { for (j = 0; j < i; ++j) Vprintf("%10.5f",c[i][j]); Vprintf("\n"); } } else { Vprintf( "Incorrect input value of n.\n"); return EXIT_FAILURE; } return EXIT_SUCCESS; }