/**************************************************************** * Utility program to read in matrix of prediction information * * used by the Bailey-Makeham estimation routines. * step. * ****************************************************************/ #include "ds.h" #include #include "inmat.h" /**************************************************************** * The following globals are used to store information from the * * dataset that contains the information from the maximization * * step. * ****************************************************************/ DOUBLE nobs; int modelid; Int2 actparm; Int2 nsp; Int2 ndv; Int2 vars; Int2 parms; Int2 n_extra_vals; char *spnames; char *dvnames; char *weightname; char *varnames; DOUBLE *means; DOUBLE *extra_vals; Int2 *actprm; unsigned char *fixed; DOUBLE *theta; DOUBLE *q; DOUBLE *a; DOUBLE *adiag; int error_flag; int result; DOUBLE weight; DOUBLE llr0; Int2 intype; char dsn1[64]; char format1[255]; int idcons = (-1); Int2 lreadv; Int2 labheads1; int nread=0; FILE *f; /************************************************************ * Input routines: Compatible with MATA (c) CRC * ************************************************************/ struct mtadf header; int inhdr(f) FILE *f; { fread(&header,sizeof(struct mtadf),1,f); if (header.s1!=MTASIG1 || header.s2!=MTASIG2 || header.s3!=MTASIG3) mxerror(23,"Not a valid output file."); } #include myalloc() { means = (DOUBLE *) malloc(sizeof(DOUBLE)*vars); actprm = (Int2 *) malloc(sizeof(Int2)*actparm); fixed = (unsigned char *) malloc(parms); theta = (DOUBLE *) malloc(sizeof(DOUBLE)*parms); spnames = (char *) malloc(nsp*9); varnames = (char *) malloc(vars*9); weightname = (char *) malloc(9); dvnames = (char *) malloc(ndv*9); extra_vals = (DOUBLE *) malloc(sizeof(DOUBLE)*n_extra_vals); adiag = (DOUBLE *) malloc(sizeof(DOUBLE)*actparm); ridbuf = (char *) malloc(lreadv); q = (DOUBLE *) malloc(sizeof(DOUBLE)*actparm); a = (DOUBLE *) malloc(sizeof(DOUBLE)*(actparm*(actparm+1))/2); if (!means || !actprm || !q || !a) mxerror(10,"Can't malloc"); } void ridpsetup() { int i; char *p; if (nread>0) return; /* a read has already been set up */ p = ridbuf; while (p-ridbuf