/* nag_prob_durbin_watson (g01epc) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; /* Scalars */ double d, pdl, pdu; Integer exit_status, ip, n; NagError fail; INIT_FAIL(fail); /* Check for command-line IO options */ fpin = nag_example_file_io(argc, argv, "-data", NULL); fpout = nag_example_file_io(argc, argv, "-results", NULL); exit_status = 0; fprintf(fpout, "nag_prob_durbin_watson (g01epc) Example Program Results\n"); /* Skip heading in data file */ fscanf(fpin, "%*[^\n] "); fscanf(fpin, "%ld%ld%lf%*[^\n] ", &n, &ip, &d); /* nag_prob_durbin_watson (g01epc). * Computes bounds for the significance of a Durbin-Watson * statistic */ nag_prob_durbin_watson(n, ip, d, &pdl, &pdu, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_prob_durbin_watson (g01epc).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "\n"); fprintf(fpout, " Durbin-Watson statistic %10.4f\n\n", d); fprintf(fpout, " Probability for the lower bound = %10.4f\n", pdl); fprintf(fpout, " Probability for the upper bound = %10.4f\n", pdu); END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }