--- imach/src/imach.c 2001/03/13 18:10:26 1.2 +++ imach/src/imach.c 2001/05/02 17:21:42 1.3 @@ -59,7 +59,7 @@ #define NLSTATEMAX 8 /* Maximum number of live states (for func) */ #define NDEATHMAX 8 /* Maximum number of dead states (for func) */ #define NCOVMAX 8 /* Maximum number of covariates */ -#define MAXN 80000 +#define MAXN 20000 #define YEARM 12. /* Number of months per year */ #define AGESUP 130 #define AGEBASE 40 @@ -168,9 +168,8 @@ void cutv(char *u,char *v, char*t, char { int i,lg,j,p; i=0; - if (t[0]== occ) p=0; for(j=0; j<=strlen(t)-1; j++) { - if((t[j]!= occ) && (t[j+1]==occ)) p=j+1; + if((t[j]!= occ) && (t[j+1]== occ)) p=j+1; } lg=strlen(t); @@ -184,7 +183,6 @@ void cutv(char *u,char *v, char*t, char } } - /********************** nrerror ********************/ void nrerror(char error_text[]) @@ -805,15 +803,14 @@ printf(" %d\n",s[4][i]); cov[1]=1.; cov[2]=agev[mw[mi][i]][i]+d*stepm/YEARM; if (cptcovn>0){ - for (k=1; k<=cptcovn;k++) { - cov[2+k]=covar[Tvar[k]][i]; - /* printf("k=%d cptcovn=%d %lf\n",k,cptcovn,covar[Tvar[k]][i]);*/ - } + for (k=1; k<=cptcovn;k++) cov[2+k]=covar[1+k-1][i]; } out=matprod2(newm,oldm,1,nlstate+ndeath,1,nlstate+ndeath, 1,nlstate+ndeath,pmij(pmmij,cov,ncovmodel,x,nlstate)); savm=oldm; oldm=newm; + + } /* end mult */ lli=log(out[s[mw[mi][i]][i]][s[mw[mi+1][i]][i]]); @@ -827,7 +824,6 @@ printf(" %d\n",s[4][i]); for(k=1,l=0.; k<=nlstate; k++) l += ll[k]; /* printf("l1=%f l2=%f ",ll[1],ll[2]); */ l= l*ipmx/sw; /* To get the same order of magnitude as if weight=1 for every body */ - return -l; } @@ -983,7 +979,8 @@ double hessii( double x[], double delta, } } delti[theta]=delts; - return res; + return res; + } double hessij( double x[], double delti[], int thetai,int thetaj) @@ -1252,8 +1249,6 @@ float sum=0.; } else{ j= rint( (agev[mw[mi+1][i]][i]*12 - agev[mw[mi][i]][i]*12)); - /*printf("i=%d agevi+1=%lf agevi=%lf j=%d\n", i,agev[mw[mi+1][i]][i],agev[mw[mi][i]][i],j);*/ - k=k+1; if (j >= jmax) jmax=j; else if (j <= jmin)jmin=j; @@ -1777,7 +1772,7 @@ int main() s=imatrix(1,maxwav+1,1,n); adl=imatrix(1,maxwav+1,1,n); tab=ivector(1,NCOVMAX); - ncodemax=ivector(1,NCOVMAX); + ncodemax=ivector(1,8); i=1; while (fgets(line, MAXLINE, fic) != NULL) { @@ -1802,17 +1797,15 @@ int main() } num[i]=atol(stra); - /* printf("%d %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]), (mint[3][i]), (anint[3][i]), (s[3][i]), (mint[4][i]), (anint[4][i]), (s[4][i]));*/ - - /*printf("%d %.lf %.lf %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]),(covar[3][i]), (covar[4][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]));*/ + /*printf("%d %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]), (mint[3][i]), (anint[3][i]), (s[3][i]), (mint[4][i]), (anint[4][i]), (s[4][i]), (mint[5][i]), (anint[5][i]), (s[5][i]), (mint[6][i]), (anint[6][i]), (s[6][i]));*/ i=i+1; } } - /*scanf("%d",i);*/ + /*scanf("%d",i);*/ imx=i-1; /* Number of individuals */ - + /* Calculation of the number of parameter from char model*/ Tvar=ivector(1,8); @@ -1820,7 +1813,7 @@ int main() j=0; j=nbocc(model,'+'); cptcovn=j+1; - + strcpy(modelsav,model); if (j==0) { cutv(stra,strb,modelsav,'V'); Tvar[1]=atoi(strb); @@ -1835,18 +1828,17 @@ int main() for (k=1; k<=lastobs;k++) covar[ncov+1][k]=covar[atoi(stre)][k]*covar[atoi(strc)][k]; } - else { - cutv(strd,strc,strb,'V'); - Tvar[i+1]=atoi(strc); + else {cutv(strd,strc,strb,'V'); + Tvar[i+1]=atoi(strc); } - strcpy(modelsav,stra); + strcpy(modelsav,stra); } - /*cutv(strd,strc,stra,'V');*/ + cutv(strd,strc,stra,'V'); Tvar[1]=atoi(strc); } } - /*printf("tvar=%d ",Tvar[1]);*/ - /*scanf("%d ",i);*/ + /*printf("tvar=%d ",Tvar[1]); + scanf("%d ",i);*/ fclose(fic); if (weightopt != 1) { /* Maximisation without weights*/ @@ -1858,7 +1850,6 @@ int main() for (i=1; i<=imx; i++) { agedc[i]=(moisdc[i]/12.+andc[i])-(moisnais[i]/12.+annais[i]); for(m=1; (m<= maxwav); m++){ - if (mint[m][i]==99 || anint[m][i]==9999) s[m][i]=-1; if(s[m][i] >0){ if (s[m][i] == nlstate+1) { if(agedc[i]>0) @@ -1871,10 +1862,8 @@ int main() } else if(s[m][i] !=9){ /* Should no more exist */ agev[m][i]=(mint[m][i]/12.+1./24.+anint[m][i])-(moisnais[i]/12.+1./24.+annais[i]); - if(mint[m][i]==99 || anint[m][i]==9999){ + if(mint[m][i]==99 || anint[m][i]==9999) agev[m][i]=1; - /* printf("i=%d m=%d agev=%lf \n",i,m, agev[m][i]); */ - } else if(agev[m][i] - Health life expectancies by age and initial health state (%d): exp%s%d%d.gif
-",cpt,strtok(optionfile, "."),cpt,j1,strtok(optionfile, "."),cpt,j1); +",cpt,strtok(optionfile, "."),cpt,j1,strtok(optionfile, "."),cpt,j1); } fprintf(fichtm,"\n
- Total life expectancy by age and health expectancies in states (1) and (2): e%s%d.gif
@@ -2461,7 +2456,7 @@ fclose(fichtm); fclose(ficrest); fclose(ficpar); free_vector(epj,1,nlstate+1); - /* scanf("%d ",i); */ + /*scanf("%d ",i); */ /*------- Variance limit prevalence------*/ @@ -2518,7 +2513,7 @@ strcpy(fileresvpl,"vpl"); #ifdef windows chdir(pathcd); #endif - system("wgnuplot ../gp37mgw/graph.plt"); + system("wgnuplot graph.plt"); #ifdef windows while (z[0] != 'q') {