/* nag_glm_binomial(g02gbc) Example Program. * * Copyright 1996 Numerical Algorithms Group. * * Mark 4, 1996. * */ #include #include #include #include #include static void set_enum(char linkc, Nag_Link *link, char meanc, Nag_IncludeMean *mean); #define NMAX 3 #define MMAX 2 #define TDX MMAX #define TDV MMAX+6 int main(void) { char linkc, meanc, weightc; Nag_Link link; Nag_IncludeMean mean; Integer i, j, m, n, nvar; Integer ivar[MMAX]; double beta[MMAX], binom[NMAX], v[NMAX][TDV], wt[NMAX], x[NMAX][MMAX], y[NMAX]; double *wtptr, *offsetptr=(double *)0; Integer max_iter, print_iter; double tol, eps; Integer rank; double df, dev, se[MMAX], cov[MMAX*(MMAX+1)/2]; static NagError fail; Vprintf("g02gbc Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vscanf(" %c %c %c %ld %ld %ld", &linkc, &meanc, &weightc, &n, &m, &print_iter); /* Check and set control parameters */ set_enum(linkc, &link, meanc, &mean); if (n<=NMAX && m0) nvar += 1; if (mean == Nag_MeanInclude) nvar += 1; /* Set other control parameters */ max_iter = 10; tol = 5e-5; eps = 1e-6; g02gbc(link, mean, n, &x[0][0], (Integer)TDX, m, ivar, nvar, y, binom, wtptr, offsetptr, &dev, &df, beta, &rank, se, cov,&v[0][0], (Integer)TDV, tol, max_iter, print_iter, "", eps, &fail); if (fail.code == NE_NOERROR || fail.code == NE_SVD_NOT_CONV || fail.code == NE_LSQ_ITER_NOT_CONV || fail.code == NE_RANK_CHANGED || fail.code == NE_ZERO_DOF_ERROR) { Vprintf("\nDeviance = %12.4e\n", dev); Vprintf("Degrees of freedom = %3.1f\n\n", df); Vprintf(" Estimate Standard error\n\n"); for (i=0; i