NAG Library Manual, Mark 29.2
Interfaces:  FL   CL   CPP   AD 

NAG CL Interface Introduction
Example description
/* nag_stat_prob_durbin_watson (g01epc) Example Program.
 *
 * Copyright 2023 Numerical Algorithms Group.
 *
 * Mark 29.2, 2023.
 */

#include <nag.h>
#include <stdio.h>

int main(void) {

  /* Scalars */
  double d, pdl, pdu;
  Integer exit_status, ip, n;
  NagError fail;

  INIT_FAIL(fail);

  exit_status = 0;
  printf("nag_stat_prob_durbin_watson (g01epc) Example Program Results\n");

  /* Skip heading in data file */
  scanf("%*[^\n] ");
  scanf("%" NAG_IFMT "%" NAG_IFMT "%lf%*[^\n] ", &n, &ip, &d);

  /* nag_stat_prob_durbin_watson (g01epc).
   * Computes bounds for the significance of a Durbin-Watson
   * statistic
   */
  nag_stat_prob_durbin_watson(n, ip, d, &pdl, &pdu, &fail);
  if (fail.code != NE_NOERROR) {
    printf("Error from nag_stat_prob_durbin_watson (g01epc).\n%s\n",
           fail.message);
    exit_status = 1;
    goto END;
  }

  printf("\n");
  printf(" Durbin-Watson statistic %10.4f\n\n", d);
  printf(" Probability for the lower bound = %10.4f\n", pdl);
  printf(" Probability for the upper bound = %10.4f\n", pdu);
END:
  return exit_status;
}