/* nag_durbin_watson_stat (g02fcc) Example Program. * * Copyright 2002 Numerical Algorithms Group. * * Mark 7, 2002. */ #include #include #include #include int main(void) { /* Scalars */ double d, pdl, pdu; Integer exit_status, i, p, n; NagError fail; /* Arrays */ double *res=0; INIT_FAIL(fail); exit_status = 0; Vprintf("nag_durbin_watson_stat (g02fcc) Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n] "); Vscanf("%ld%*[^\n] ", &p); n = 10; /* Allocate memory */ if ( !(res = NAG_ALLOC(n, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } for (i = 1; i <= n; ++i) Vscanf("%lf", &res[i - 1]); Vscanf("%*[^\n] "); /* nag_durbin_watson_stat (g02fcc). * Computes Durbin-Watson test statistic */ nag_durbin_watson_stat(n, p, res, &d, &pdl, &pdu, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from nag_durbin_watson_stat (g02fcc).\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("\n"); Vprintf(" Durbin-Watson statistic %10.4f\n\n", d); Vprintf(" Lower and upper bound %10.4f%10.4f\n", pdl, pdu); END: if (res) NAG_FREE(res); return exit_status; }