/* nag_tsa_multi_inp_model_estim (g13bec) Example Program. * * Copyright 1991 Numerical Algorithms Group. * * Mark 2, 1991. * Mark 8 revised, 2004. */ #include #include #include #include #include static int ex1(void); static int ex2(void); int main(void) { Integer exit_status_ex1=0; Integer exit_status_ex2=0; /* Two examples are called, ex1() which uses the * default settings to solve the problem and * ex2() which solves the same problem with * some optional parameters set by the user. */ Vprintf("nag_tsa_multi_inp_model_estim (g13bec) Example Program Results\n"); Vscanf(" %*[^\n]"); /* Skip heading in data file */ exit_status_ex1 = ex1(); exit_status_ex2 = ex2(); return exit_status_ex1 == 0 && exit_status_ex2 == 0 ? 0 : 1; } #define XXY(I,J) xxy[(I)*tdxxy + J] static int ex1(void) { Integer exit_status=0, i, inser, j, npara, nseries, nxxy, tdxxy; NagError fail; Nag_ArimaOrder arimav; Nag_TransfOrder transfv; double df, objf, *para=0, rss, *sd=0, *xxy=0; INIT_FAIL(fail); Vprintf("\nnag_tsa_multi_inp_model_estim (g13bec) example 1: no option " "setting.\n\n"); /* Skip heading in data file */ Vscanf(" %*[^\n]"); Vscanf("%ld%ld", &nxxy, &nseries); if (nxxy>0 && nseries>0) { /* * Allocate memory to the arrays in structure transfv containing * the transfer function model orders of the input series. */ /* nag_tsa_transf_orders (g13byc). * Allocates memory to transfer function model orders */ nag_tsa_transf_orders(nseries, &transfv, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from nag_tsa_transf_orders (g13byc).\n%s\n", fail.message); exit_status = 1; goto END; } /* * Read the orders vector of the ARIMA model for the output noise * component into structure arimav. */ Vscanf("%ld%ld%ld%ld%ld" "%ld%ld", &arimav.p, &arimav.d, &arimav.q, &arimav.bigp, &arimav.bigd, &arimav.bigq, &arimav.s); /* * Read the transfer function model orders of the input series into * structure transfv. */ inser = nseries - 1; for (j=0; j=1) { if ( !( para = NAG_ALLOC(npara, double)) || !( sd = NAG_ALLOC(npara, double)) || !( xxy = NAG_ALLOC(nxxy*nseries, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } tdxxy = nseries; for (i=0; i0 && nseries>0) { /* * Set some specific option variables to the desired values. */ options.criteria = Nag_Marginal; options.print_level = Nag_Soln_Iter_Full; /* * Allocate memory to the arrays in structure transfv containing * the transfer function model orders of the input series. */ /* nag_tsa_transf_orders (g13byc), see above. */ nag_tsa_transf_orders(nseries, &transfv, NAGERR_DEFAULT); /* * Read the orders vector of the ARIMA model for the output noise * component into structure arimav. */ Vscanf("%ld%ld%ld%ld%ld" "%ld%ld", &arimav.p, &arimav.d, &arimav.q, &arimav.bigp, &arimav.bigd, &arimav.bigq, &arimav.s); /* * Read the transfer function model orders of the input series into * structure transfv. */ inser = nseries - 1; for (j=0; j=1) { if ( !( para = NAG_ALLOC(npara, double)) || !( sd = NAG_ALLOC(npara, double)) || !( xxy = NAG_ALLOC(nxxy*nseries, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } tdxxy = nseries; for (i=0; i