/**************************************************************** * Programs for conducting Bailey's Surface Analysis * * * * This program is placed in the public domain * ********************************* Bill Rogers *** 04/23/91 ****/ #include "surface.h" #include "ds.h" #include "inmat.h" #include char parmdsn[64]; char dsn[64]; char format[256]=""; FILE *f_parmdsn; DOUBLE sp[20], dv[20]; DOUBLE interval; int has_interval=0; int labheads=0; int debug=0; FILE *macopen(long *iddir, char *s); int main(argc,argv) int argc; char **argv; { int i; long iddir; #if defined(THINK_C) f_parmdsn = macopen(&iddir,"rb"); #else if (argv[1]) strcpy(parmdsn,argv[1]); f_parmdsn = fopen(parmdsn,"rb"); #endif if (!f_parmdsn) { printf("Unable to open dataset %s\n", parmdsn); exit(1); } inparmf(f_parmdsn); strcpy(dsn,dsn1); if (intype==RAW) { strcpy(format,format1); labheads = labheads1; i=raw_setup(dsn,format); if (labheads) headread(); } else i=stata_setup(dsn); if (i) mxerror(i,dsn); indv_setup(1); surface_run(); } /********************************************************************** * Evaluate likelihood function at +- 1 SE and +-2 SE * * * * +/- 2 SE is the confidence range for the parameter, allowing * * other parameters to vary. The likelihood needs to be compared * * with what we expect based on the quadratic approximation * **********************************************************************/ #include surface_run() { int i, j, k; DOUBLE *LL, *se, *lldiff; DOUBLE spsave; DOUBLE llsave; LL = (DOUBLE *) malloc(sizeof(DOUBLE)*parms*4); se = (DOUBLE *) malloc(sizeof(DOUBLE)*parms); lldiff = (DOUBLE *) malloc(sizeof(DOUBLE)*parms); for (j=0; j<4*parms; ++j) LL[j]=0.0; /* calculate the standard error distances */ for (j=0; j=0) d[idcons] = 1.0; /* Compute the structural parameters */ for (j=0; j=2) printf("llsave,2 = %10.4f\n", llsave); sp[j] += se[j*vars+i]*d[i]; LL[(j*vars+i)*4+3] += (llsave=LL_compute(dv,sp,(DOUBLE *)NULL, (DOUBLE *)NULL,(DOUBLE *)NULL, &weight,0)); if (debug>=2) printf("llsave,3 = %10.4f\n", llsave); sp[j] = spsave - se[j*vars+i]*d[i]; LL[(j*vars+i)*4+1] += LL_compute(dv,sp,(DOUBLE *)NULL, (DOUBLE *)NULL,(DOUBLE *)NULL, &weight,0); sp[j] -= se[j*vars+i]*d[i]; LL[(j*vars+i)*4+0] += LL_compute(dv,sp,(DOUBLE *)NULL, (DOUBLE *)NULL,(DOUBLE *)NULL, &weight,0); sp[j] = spsave; } } } printf("\n"); printf("Structural |\n"); printf("parameter Var. | -2 SE -1 SE +1 SE +2 SE\n"); printf("------------------+----------------------------------------------------------\n"); for (i=0; i missing from dataset\n", s); break; case 19: fprintf(f,"Dependent variable <%s> missing from dataset\n", s); break; case 20: fprintf(f,"Weighting variable <%s> missing from dataset\n", s); break; default: fprintf(f,"Unknown error %d, text: %s\n", i, s); break; } } void mxerror(i,s) int i; char *s; { mxerrors(stderr,i,s); /* mxerrors(logf,i,s); */ /* fclose(logf); */ exit(i); } int dupch(c,n) char c; int n; { while(n--) putchar(c); } char outbuf[132]; int spout21o() { char *p; for (p=outbuf;*p;++p) putchar(*p); }