|
|
| version 1.15, 2002/02/20 17:08:52 | version 1.16, 2002/02/20 17:12:32 |
|---|---|
| Line 85 double jmean; /* Mean space between 2 wa | Line 85 double jmean; /* Mean space between 2 wa |
| double **oldm, **newm, **savm; /* Working pointers to matrices */ | double **oldm, **newm, **savm; /* Working pointers to matrices */ |
| double **oldms, **newms, **savms; /* Fixed working pointers to matrices */ | double **oldms, **newms, **savms; /* Fixed working pointers to matrices */ |
| FILE *fic,*ficpar, *ficparo,*ficres, *ficrespl, *ficrespij, *ficrest,*ficresf; | FILE *fic,*ficpar, *ficparo,*ficres, *ficrespl, *ficrespij, *ficrest,*ficresf; |
| FILE *ficgp, *fichtm,*ficresprob; | FILE *ficgp, *fichtm,*ficresprob,*ficpop; |
| FILE *ficreseij; | FILE *ficreseij; |
| char filerese[FILENAMELENGTH]; | char filerese[FILENAMELENGTH]; |
| FILE *ficresvij; | FILE *ficresvij; |
| Line 1860 int main() | Line 1860 int main() |
| char fileres[FILENAMELENGTH], filerespij[FILENAMELENGTH], filereso[FILENAMELENGTH], fileresf[FILENAMELENGTH]; | char fileres[FILENAMELENGTH], filerespij[FILENAMELENGTH], filereso[FILENAMELENGTH], fileresf[FILENAMELENGTH]; |
| char filerest[FILENAMELENGTH]; | char filerest[FILENAMELENGTH]; |
| char fileregp[FILENAMELENGTH]; | char fileregp[FILENAMELENGTH]; |
| char popfile[FILENAMELENGTH]; | |
| char path[80],pathc[80],pathcd[80],pathtot[80],model[20]; | char path[80],pathc[80],pathcd[80],pathtot[80],model[20]; |
| int firstobs=1, lastobs=10; | int firstobs=1, lastobs=10; |
| int sdeb, sfin; /* Status at beginning and end */ | int sdeb, sfin; /* Status at beginning and end */ |
| Line 1867 int main() | Line 1868 int main() |
| int ju,jl, mi; | int ju,jl, mi; |
| int i1,j1, k1,k2,k3,jk,aa,bb, stepsize, ij; | int i1,j1, k1,k2,k3,jk,aa,bb, stepsize, ij; |
| int jnais,jdc,jint4,jint1,jint2,jint3,**outcome,**adl,*tab; | int jnais,jdc,jint4,jint1,jint2,jint3,**outcome,**adl,*tab; |
| int mobilav=0, fprev, lprev ,fprevfore=1, lprevfore=1,nforecast; | int mobilav=0, fprev, lprev ,fprevfore=1, lprevfore=1,nforecast,popforecast=0; |
| int hstepm, nhstepm; | int hstepm, nhstepm; |
| int *popage; | |
| double bage, fage, age, agelim, agebase; | double bage, fage, age, agelim, agebase; |
| double ftolpl=FTOL; | double ftolpl=FTOL; |
| Line 1882 int main() | Line 1884 int main() |
| double ***eij, ***vareij; | double ***eij, ***vareij; |
| double **varpl; /* Variances of prevalence limits by age */ | double **varpl; /* Variances of prevalence limits by age */ |
| double *epj, vepp; | double *epj, vepp; |
| double kk1; | double kk1, kk2; |
| double *popeffectif,*popcount; | |
| char version[80]="Imach version 64b, May 2001, INED-EUROREVES "; | char version[80]="Imach version 64b, May 2001, INED-EUROREVES "; |
| char *alph[]={"a","a","b","c","d","e"}, str[4]; | char *alph[]={"a","a","b","c","d","e"}, str[4]; |
| Line 1898 int main() | Line 1901 int main() |
| gettimeofday(&start_time, (struct timezone*)0); */ /* at first time */ | gettimeofday(&start_time, (struct timezone*)0); */ /* at first time */ |
| printf("\nIMACH, Version 0.64b"); | printf("\nIMACH, Version 0.7"); |
| printf("\nEnter the parameter file name: "); | printf("\nEnter the parameter file name: "); |
| #ifdef windows | #ifdef windows |
| Line 1955 while((c=getc(ficpar))=='#' && c!= EOF){ | Line 1958 while((c=getc(ficpar))=='#' && c!= EOF){ |
| ungetc(c,ficpar); | ungetc(c,ficpar); |
| fscanf(ficpar,"fprevalence=%d lprevalence=%d pop_based=%d\n",&fprev,&lprev,&popbased); | fscanf(ficpar,"fprevalence=%d lprevalence=%d pop_based=%d\n",&fprev,&lprev,&popbased); |
| fprintf(ficparo,"fprevalence=%d lprevalence=%d pop_based=%d\n",fprev,lprev,popbased); | |
| while((c=getc(ficpar))=='#' && c!= EOF){ | while((c=getc(ficpar))=='#' && c!= EOF){ |
| ungetc(c,ficpar); | ungetc(c,ficpar); |
| fgets(line, MAXLINE, ficpar); | fgets(line, MAXLINE, ficpar); |
| Line 1964 while((c=getc(ficpar))=='#' && c!= EOF){ | Line 1969 while((c=getc(ficpar))=='#' && c!= EOF){ |
| ungetc(c,ficpar); | ungetc(c,ficpar); |
| fscanf(ficpar,"fprevalence=%d lprevalence=%d nforecast=%d mob_average=%d\n",&fprevfore,&lprevfore,&nforecast,&mobilav); | fscanf(ficpar,"fprevalence=%d lprevalence=%d nforecast=%d mob_average=%d\n",&fprevfore,&lprevfore,&nforecast,&mobilav); |
| fprintf(ficparo,"fprevalence=%d lprevalence=%d nforecast=%d mob_average=%d\n",fprevfore,lprevfore,nforecast,mobilav); | |
| while((c=getc(ficpar))=='#' && c!= EOF){ | |
| ungetc(c,ficpar); | |
| fgets(line, MAXLINE, ficpar); | |
| puts(line); | |
| fputs(line,ficparo); | |
| } | |
| ungetc(c,ficpar); | |
| fscanf(ficpar,"popforecast=%d popfile=%s\n",&popforecast,popfile); | |
| covar=matrix(0,NCOVMAX,1,n); | covar=matrix(0,NCOVMAX,1,n); |
| cptcovn=0; | cptcovn=0; |
| Line 2335 printf("Total number of individuals= %d, | Line 2352 printf("Total number of individuals= %d, |
| } | } |
| /*--------- results files --------------*/ | /*--------- results files --------------*/ |
| fprintf(ficres,"\ntitle=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncov=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncov, nlstate, ndeath, maxwav, mle,weightopt,model); | fprintf(ficres,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncov=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncov, nlstate, ndeath, maxwav, mle,weightopt,model); |
| fprintf(ficres,"fprevalence=%d lprevalence=%d pop_based=%d\n",fprev,lprev,popbased); | |
| fprintf(ficres,"fprevalence=%d lprevalence=%d nforecast=%d mob_average=%d\n",fprevfore,lprevfore,nforecast,mobilav); | |
| jk=1; | jk=1; |
| fprintf(ficres,"# Parameters\n"); | fprintf(ficres,"# Parameters\n"); |
| printf("# Parameters\n"); | printf("# Parameters\n"); |
| Line 2618 chdir(path); | Line 2637 chdir(path); |
| printf("Problem with %s \n",optionfilehtm);goto end; | printf("Problem with %s \n",optionfilehtm);goto end; |
| } | } |
| fprintf(fichtm,"<body><ul> <font size=\"6\">Imach, Version 0.64b </font> <hr size=\"2\" color=\"#EC5E5E\"> | fprintf(fichtm,"<body><ul> <font size=\"6\">Imach, Version 0.7 </font> <hr size=\"2\" color=\"#EC5E5E\"> |
| Titre=%s <br>Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s<br> | Titre=%s <br>Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s<br> |
| Total number of observations=%d <br> | Total number of observations=%d <br> |
| Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf<br> | Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf<br> |
| Line 2813 fclose(fichtm); | Line 2832 fclose(fichtm); |
| agelim=AGESUP; | agelim=AGESUP; |
| hstepm=stepsize*YEARM; /* Every year of age */ | hstepm=stepsize*YEARM; /* Every year of age */ |
| hstepm=hstepm/stepm; /* Typically 2 years, = 2 years/6 months = 4 */ | hstepm=hstepm/stepm; /* Typically 2 years, = 2 years/6 months = 4 */ |
| if (popforecast==1) { | |
| if((ficpop=fopen(popfile,"r"))==NULL) { | |
| printf("Problem with population file : %s\n",popfile);goto end; | |
| } | |
| popage=ivector(0,AGESUP); | |
| popeffectif=vector(0,AGESUP); | |
| popcount=vector(0,AGESUP); | |
| i=1; | |
| while ((c=fscanf(ficpop,"%d %lf\n",&popage[i],&popcount[i])) != EOF) | |
| { | |
| i=i+1; | |
| } | |
| imx=i; | |
| for (i=1; i<imx;i++) popeffectif[popage[i]]=popcount[i]; | |
| } | |
| k=0; | |
| for(cptcov=1;cptcov<=i1;cptcov++){ | for(cptcov=1;cptcov<=i1;cptcov++){ |
| for(cptcod=1;cptcod<=ncodemax[cptcoveff];cptcod++){ | for(cptcod=1;cptcod<=ncodemax[cptcoveff];cptcod++){ |
| k=k+1; | k=k+1; |
| Line 2825 fclose(fichtm); | Line 2861 fclose(fichtm); |
| fprintf(ficresf,"******\n"); | fprintf(ficresf,"******\n"); |
| fprintf(ficresf,"# StartingAge FinalAge Horizon(in years)"); | fprintf(ficresf,"# StartingAge FinalAge Horizon(in years)"); |
| for(j=1; j<=nlstate+ndeath;j++) fprintf(ficresf," P.%d",j); | for(j=1; j<=nlstate+ndeath;j++) fprintf(ficresf," P.%d",j); |
| if (popforecast==1) fprintf(ficresf," [Population]"); | |
| for (agedeb=fage; agedeb>=bage; agedeb--){ | for (agedeb=fage; agedeb>=bage; agedeb--){ |
| fprintf(ficresf,"\n%d %.f %.f 0 ",k,agedeb, agedeb); | fprintf(ficresf,"\n%.f %.f 0",agedeb, agedeb); |
| if (mobilav==1) { | if (mobilav==1) { |
| for(j=1; j<=nlstate;j++) | for(j=1; j<=nlstate;j++) |
| fprintf(ficresf," %.5f ",mobaverage[(int)agedeb][j][cptcod]); | fprintf(ficresf," %.3f",mobaverage[(int)agedeb][j][cptcod]); |
| } | } |
| else { | else { |
| for(j=1; j<=nlstate;j++) | for(j=1; j<=nlstate;j++) |
| fprintf(ficresf," %.5f ",probs[(int)agedeb][j][cptcod]); | fprintf(ficresf," %.3f",probs[(int)agedeb][j][cptcod]); |
| } | } |
| for(j=1; j<=ndeath;j++) fprintf(ficresf," 0.00000"); | |
| for(j=1; j<=ndeath;j++) fprintf(ficresf," 0.00000"); | |
| if (popforecast==1) fprintf(ficresf," [%.f] ",popeffectif[(int)agedeb]); | |
| } | } |
| for (cpt=1; cpt<=nforecast;cpt++) | |
| for (cpt=1; cpt<=nforecast;cpt++) { | |
| fprintf(ficresf,"\n"); | |
| for (agedeb=fage; agedeb>=bage; agedeb--){ /* If stepm=6 months */ | for (agedeb=fage; agedeb>=bage; agedeb--){ /* If stepm=6 months */ |
| nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); | nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); |
| nhstepm = nhstepm/hstepm; | nhstepm = nhstepm/hstepm; |
| /*printf("agedeb=%.lf stepm=%d hstepm=%d nhstepm=%d \n",agedeb,stepm,hstepm,nhstepm);*/ | /*printf("agedeb=%.lf stepm=%d hstepm=%d nhstepm=%d \n",agedeb,stepm,hstepm,nhstepm);*/ |
| Line 2852 fclose(fichtm); | Line 2892 fclose(fichtm); |
| for (h=0; h<=nhstepm; h++){ | for (h=0; h<=nhstepm; h++){ |
| if (h*hstepm/YEARM*stepm==cpt) | if (h*hstepm/YEARM*stepm==cpt) |
| fprintf(ficresf,"\n%d %.f %.f %.f",k,agedeb, agedeb+ h*hstepm/YEARM*stepm, h*hstepm/YEARM*stepm); | fprintf(ficresf,"\n%.f %.f %.f",agedeb, agedeb+ h*hstepm/YEARM*stepm, h*hstepm/YEARM*stepm); |
| for(j=1; j<=nlstate+ndeath;j++) { | for(j=1; j<=nlstate+ndeath;j++) { |
| kk1=0.; | kk1=0.;kk2=0; |
| for(i=1; i<=nlstate;i++) { | for(i=1; i<=nlstate;i++) { |
| if (mobilav==1) | if (mobilav==1) |
| kk1=kk1+p3mat[i][j][h]*mobaverage[(int)agedeb][i][cptcod]; | kk1=kk1+p3mat[i][j][h]*mobaverage[(int)agedeb][i][cptcod]; |
| else kk1=kk1+p3mat[i][j][h]*probs[(int)agedeb][i][cptcod]; | else kk1=kk1+p3mat[i][j][h]*probs[(int)agedeb][i][cptcod]; |
| } | if (popforecast==1) kk2=kk1*popeffectif[(int)agedeb]; |
| if (h*hstepm/YEARM*stepm==cpt) fprintf(ficresf," %.5f ", kk1); | } |
| if (h*hstepm/YEARM*stepm==cpt) { | |
| fprintf(ficresf," %.3f", kk1); | |
| if (popforecast==1) fprintf(ficresf," [%.f]", kk2); | |
| } | |
| } | } |
| } | } |
| free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); | free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); |
| } | |
| } | } |
| } | } |
| } | } |
| if (mobilav==1) free_ma3x(mobaverage,1, AGESUP,1,NCOVMAX, 1,NCOVMAX); | if (mobilav==1) free_ma3x(mobaverage,1, AGESUP,1,NCOVMAX, 1,NCOVMAX); |
| if (popforecast==1) { | |
| free_ivector(popage,0,AGESUP); | |
| free_vector(popeffectif,0,AGESUP); | |
| free_vector(popcount,0,AGESUP); | |
| } | |
| free_imatrix(s,1,maxwav+1,1,n); | free_imatrix(s,1,maxwav+1,1,n); |
| free_vector(weight,1,n); | free_vector(weight,1,n); |
| fclose(ficresf); | fclose(ficresf); |