--- imach/src/imach.c 2003/02/05 12:40:38 1.70 +++ imach/src/imach.c 2003/06/05 15:17:23 1.79 @@ -1,4 +1,4 @@ -/* $Id: imach.c,v 1.70 2003/02/05 12:40:38 brouard Exp $ +/* $Id: imach.c,v 1.79 2003/06/05 15:17:23 brouard Exp $ Interpolated Markov Chain Short summary of the programme: @@ -48,7 +48,43 @@ It is copyrighted identically to a GNU software product, ie programme and software can be distributed freely for non commercial use. Latest version can be accessed at http://euroreves.ined.fr/imach . + + Help to debug: LD_PRELOAD=/usr/local/lib/libnjamd.so ./imach foo.imach + or better on gdb : set env LD_PRELOAD=/usr/local/lib/libnjamd.so + **********************************************************************/ +/* + main + read parameterfile + read datafile + concatwav + if (mle >= 1) + mlikeli + print results files + if mle==1 + computes hessian + read end of parameter file: agemin, agemax, bage, fage, estepm + begin-prev-date,... + open gnuplot file + open html file + stable prevalence + for age prevalim() + h Pij x + variance of p varprob + forecasting if prevfcast==1 prevforecast call prevalence() + health expectancies + Variance-covariance of DFLE + prevalence() + movingaverage() + varevsij() + if popbased==1 varevsij(,popbased) + total life expectancies + Variance of stable prevalence + end +*/ + + + #include #include @@ -83,7 +119,12 @@ #define ODIRSEPARATOR '\\' #endif -char version[80]="Imach version 0.92, February 2003, INED-EUROREVES "; +/* $Id: imach.c,v 1.79 2003/06/05 15:17:23 brouard Exp $ */ +/* $Log: imach.c,v $ + * Revision 1.79 2003/06/05 15:17:23 brouard + * *** empty log message *** + * */ +char version[80]="Imach version 0.95a1, June 2003, INED-EUROREVES "; int erreur; /* Error number */ int nvar; int cptcovn=0, cptcovage=0, cptcoveff=0,cptcov; @@ -105,7 +146,7 @@ double jmean; /* Mean space between 2 wa double **oldm, **newm, **savm; /* Working pointers to matrices */ double **oldms, **newms, **savms; /* Fixed working pointers to matrices */ FILE *fic,*ficpar, *ficparo,*ficres, *ficrespl, *ficrespij, *ficrest,*ficresf,*ficrespop; -FILE *ficlog; +FILE *ficlog, *ficrespow; FILE *ficgp,*ficresprob,*ficpop, *ficresprobcov, *ficresprobcor; FILE *ficresprobmorprev; FILE *fichtm; /* Html File */ @@ -188,15 +229,9 @@ static int split( char *path, char *dirc if ( ss == NULL ) { /* no directory, so use current */ /*if(strrchr(path, ODIRSEPARATOR )==NULL) printf("Warning you should use %s as a separator\n",DIRSEPARATOR);*/ -#if defined(__bsd__) /* get current working directory */ - extern char *getwd( ); - - if ( getwd( dirc ) == NULL ) { -#else - extern char *getcwd( ); - + /* get current working directory */ + /* extern char* getcwd ( char *buf , int len);*/ if ( getcwd( dirc, FILENAME_MAX ) == NULL ) { -#endif return( GLOCK_ERROR_GETCWD ); } strcpy( name, path ); /* we've got it */ @@ -297,6 +332,21 @@ void free_vector(double*v, int nl, int n } /************************ivector *******************************/ +char *cvector(long nl,long nh) +{ + char *v; + v=(char *) malloc((size_t)((nh-nl+1+NR_END)*sizeof(char))); + if (!v) nrerror("allocation failure in cvector"); + return v-nl+NR_END; +} + +/******************free ivector **************************/ +void free_cvector(char *v, long nl, long nh) +{ + free((FREE_ARG)(v+nl-NR_END)); +} + +/************************ivector *******************************/ int *ivector(long nl,long nh) { int *v; @@ -365,6 +415,8 @@ double **matrix(long nrl, long nrh, long for (i=nrl+1; i<=nrh; i++) m[i]=m[i-1]+ncol; return m; + /* print *(*(m+1)+70) ou print m[1][70]; print m+1 or print &(m[1]) + */ } /*************************free matrix ************************/ @@ -404,7 +456,10 @@ double ***ma3x(long nrl, long nrh, long for (j=ncl+1; j<=nch; j++) m[i][j]=m[i][j-1]+nlay; } - return m; + return m; + /* gdb: p *(m+1) <=> p m[1] and p (m+1) <=> p (m+1) <=> p &(m[1]) + &(m[i][j][k]) <=> *((*(m+i) + j)+k) + */ } /*************************free ma3x ************************/ @@ -612,11 +667,15 @@ void powell(double p[], double **xi, int del=0.0; printf("\nPowell iter=%d -2*LL=%.12f",*iter,*fret); fprintf(ficlog,"\nPowell iter=%d -2*LL=%.12f",*iter,*fret); - for (i=1;i<=n;i++) + fprintf(ficrespow,"%d %.12f",*iter,*fret); + for (i=1;i<=n;i++) { printf(" %d %.12f",i, p[i]); - fprintf(ficlog," %d %.12f",i, p[i]); + fprintf(ficlog," %d %.12lf",i, p[i]); + fprintf(ficrespow," %.12lf", p[i]); + } printf("\n"); fprintf(ficlog,"\n"); + fprintf(ficrespow,"\n"); for (i=1;i<=n;i++) { for (j=1;j<=n;j++) xit[j]=xi[j][i]; fptt=(*fret); @@ -972,11 +1031,38 @@ double func( double *x) * is higher than the multiple of stepm and negative otherwise. */ /* lli= (savm[s1][s2]>1.e-8 ?(1.+bbh)*log(out[s1][s2])- bbh*log(savm[s1][s2]):log((1.+bbh)*out[s1][s2]));*/ - lli= (savm[s1][s2]>(double)1.e-8 ?log((1.+bbh)*out[s1][s2]- bbh*(savm[s1][s2])):log((1.+bbh)*out[s1][s2])); /* linear interpolation */ + if( s2 > nlstate){ + /* i.e. if s2 is a death state and if the date of death is known then the contribution + to the likelihood is the probability to die between last step unit time and current + step unit time, which is also the differences between probability to die before dh + and probability to die before dh-stepm . + In version up to 0.92 likelihood was computed + as if date of death was unknown. Death was treated as any other + health state: the date of the interview describes the actual state + and not the date of a change in health state. The former idea was + to consider that at each interview the state was recorded + (healthy, disable or death) and IMaCh was corrected; but when we + introduced the exact date of death then we should have modified + the contribution of an exact death to the likelihood. This new + contribution is smaller and very dependent of the step unit + stepm. It is no more the probability to die between last interview + and month of death but the probability to survive from last + interview up to one month before death multiplied by the + probability to die within a month. Thanks to Chris + Jackson for correcting this bug. Former versions increased + mortality artificially. The bad side is that we add another loop + which slows down the processing. The difference can be up to 10% + lower mortality. + */ + lli=log(out[s1][s2] - savm[s1][s2]); + }else{ + lli= log((1.+bbh)*out[s1][s2]- bbh*savm[s1][s2]); /* linear interpolation */ + /* lli= (savm[s1][s2]>(double)1.e-8 ?log((1.+bbh)*out[s1][s2]- bbh*(savm[s1][s2])):log((1.+bbh)*out[s1][s2]));*/ /* linear interpolation */ + } /*lli=(1.+bbh)*log(out[s1][s2])- bbh*log(savm[s1][s2]);*/ /*if(lli ==000.0)*/ /*printf("bbh= %f lli=%f savm=%f out=%f %d\n",bbh,lli,savm[s1][s2], out[s[mw[mi][i]][i]][s[mw[mi+1][i]][i]],i); */ - ipmx +=1; + ipmx +=1; sw += weight[i]; ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; } /* end of wave */ @@ -1123,16 +1209,29 @@ double func( double *x) void mlikeli(FILE *ficres,double p[], int npar, int ncovmodel, int nlstate, double ftol, double (*func)(double [])) { int i,j, iter; - double **xi,*delti; + double **xi; double fret; + char filerespow[FILENAMELENGTH]; xi=matrix(1,npar,1,npar); for (i=1;i<=npar;i++) for (j=1;j<=npar;j++) xi[i][j]=(i==j ? 1.0 : 0.0); printf("Powell\n"); fprintf(ficlog,"Powell\n"); + strcpy(filerespow,"pow"); + strcat(filerespow,fileres); + if((ficrespow=fopen(filerespow,"w"))==NULL) { + printf("Problem with resultfile: %s\n", filerespow); + fprintf(ficlog,"Problem with resultfile: %s\n", filerespow); + } + fprintf(ficrespow,"# Powell\n# iter -2*LL"); + for (i=1;i<=nlstate;i++) + for(j=1;j<=nlstate+ndeath;j++) + if(j!=i)fprintf(ficrespow," p%1d%1d",i,j); + fprintf(ficrespow,"\n"); powell(p,xi,npar,ftol,&iter,&fret,func); - printf("\n#Number of iterations = %d, -2 Log likelihood = %.12f\n",iter,func(p)); + fclose(ficrespow); + printf("\n#Number of iterations = %d, -2 Log likelihood = %.12f\n",iter,func(p)); fprintf(ficlog,"\n#Number of iterations = %d, -2 Log likelihood = %.12f \n",iter,func(p)); fprintf(ficres,"#Number of iterations = %d, -2 Log likelihood = %.12f \n",iter,func(p)); @@ -1396,19 +1495,19 @@ void lubksb(double **a, int n, int *indx } /************ Frequencies ********************/ -void freqsummary(char fileres[], int agemin, int agemax, int **s, double **agev, int nlstate, int imx, int *Tvaraff, int **nbcode, int *ncodemax,double **mint,double **anint, double dateprev1,double dateprev2,double jprev1, double mprev1,double anprev1,double jprev2, double mprev2,double anprev2) +void freqsummary(char fileres[], int iagemin, int iagemax, int **s, double **agev, int nlstate, int imx, int *Tvaraff, int **nbcode, int *ncodemax,double **mint,double **anint, double dateprev1,double dateprev2,double jprev1, double mprev1,double anprev1,double jprev2, double mprev2,double anprev2) { /* Some frequencies */ int i, m, jk, k1,i1, j1, bool, z1,z2,j; int first; double ***freq; /* Frequencies */ - double *pp; - double pos, k2, dateintsum=0,k2cpt=0; + double *pp, **prop; + double pos,posprop, k2, dateintsum=0,k2cpt=0; FILE *ficresp; char fileresp[FILENAMELENGTH]; pp=vector(1,nlstate); - probs= ma3x(1,AGESUP,1,NCOVMAX, 1,NCOVMAX); + prop=matrix(1,nlstate,iagemin,iagemax+3); strcpy(fileresp,"p"); strcat(fileresp,fileres); if((ficresp=fopen(fileresp,"w"))==NULL) { @@ -1416,7 +1515,7 @@ void freqsummary(char fileres[], int ag fprintf(ficlog,"Problem with prevalence resultfile: %s\n", fileresp); exit(0); } - freq= ma3x(-1,nlstate+ndeath,-1,nlstate+ndeath,agemin,agemax+3); + freq= ma3x(-1,nlstate+ndeath,-1,nlstate+ndeath,iagemin,iagemax+3); j1=0; j=cptcoveff; @@ -1431,8 +1530,12 @@ void freqsummary(char fileres[], int ag scanf("%d", i);*/ for (i=-1; i<=nlstate+ndeath; i++) for (jk=-1; jk<=nlstate+ndeath; jk++) - for(m=agemin; m <= agemax+3; m++) + for(m=iagemin; m <= iagemax+3; m++) freq[i][jk][m]=0; + + for (i=1; i<=nlstate; i++) + for(m=iagemin; m <= iagemax+3; m++) + prop[i][m]=0; dateintsum=0; k2cpt=0; @@ -1447,14 +1550,15 @@ void freqsummary(char fileres[], int ag for(m=firstpass; m<=lastpass; m++){ k2=anint[m][i]+(mint[m][i]/12.); if ((k2>=dateprev1) && (k2<=dateprev2)) { - if(agev[m][i]==0) agev[m][i]=agemax+1; - if(agev[m][i]==1) agev[m][i]=agemax+2; + if(agev[m][i]==0) agev[m][i]=iagemax+1; + if(agev[m][i]==1) agev[m][i]=iagemax+2; + if (s[m][i]>0 && s[m][i]<=nlstate) prop[s[m][i]][(int)agev[m][i]] += weight[i]; if (m1) && (agev[m][i]< (agemax+3))) { + if ((agev[m][i]>1) && (agev[m][i]< (iagemax+3))) { dateintsum=dateintsum+k2; k2cpt++; } @@ -1474,8 +1578,8 @@ void freqsummary(char fileres[], int ag fprintf(ficresp, " Age Prev(%d) N(%d) N",i,i); fprintf(ficresp, "\n"); - for(i=(int)agemin; i <= (int)agemax+3; i++){ - if(i==(int)agemax+3){ + for(i=iagemin; i <= iagemax+3; i++){ + if(i==iagemax+3){ fprintf(ficlog,"Total"); }else{ if(first==1){ @@ -1506,10 +1610,11 @@ void freqsummary(char fileres[], int ag for(jk=1; jk <=nlstate ; jk++){ for(m=0, pp[jk]=0; m <=nlstate+ndeath; m++) pp[jk] += freq[jk][m][i]; - } - - for(jk=1,pos=0; jk <=nlstate ; jk++) + } + for(jk=1,pos=0,posprop=0; jk <=nlstate ; jk++){ pos += pp[jk]; + posprop += prop[jk][i]; + } for(jk=1; jk <=nlstate ; jk++){ if(pos>=1.e-5){ if(first==1) @@ -1520,14 +1625,14 @@ void freqsummary(char fileres[], int ag printf(" %d.=%.0f prev[%d]=NaNQ%%",jk,pp[jk],jk); fprintf(ficlog," %d.=%.0f prev[%d]=NaNQ%%",jk,pp[jk],jk); } - if( i <= (int) agemax){ + if( i <= iagemax){ if(pos>=1.e-5){ - fprintf(ficresp," %d %.5f %.0f %.0f",i,pp[jk]/pos, pp[jk],pos); + fprintf(ficresp," %d %.5f %.0f %.0f",i,prop[jk][i]/posprop, prop[jk][i],posprop); probs[i][jk][j1]= pp[jk]/pos; /*printf("\ni=%d jk=%d j1=%d %.5f %.0f %.0f %f",i,jk,j1,pp[jk]/pos, pp[jk],pos,probs[i][jk][j1]);*/ } else - fprintf(ficresp," %d NaNq %.0f %.0f",i,pp[jk],pos); + fprintf(ficresp," %d NaNq %.0f %.0f",i,prop[jk][i],posprop); } } @@ -1538,7 +1643,7 @@ void freqsummary(char fileres[], int ag printf(" %d%d=%.0f",jk,m,freq[jk][m][i]); fprintf(ficlog," %d%d=%.0f",jk,m,freq[jk][m][i]); } - if(i <= (int) agemax) + if(i <= iagemax) fprintf(ficresp,"\n"); if(first==1) printf("Others in log...\n"); @@ -1549,14 +1654,14 @@ void freqsummary(char fileres[], int ag dateintmean=dateintsum/k2cpt; fclose(ficresp); - free_ma3x(freq,-1,nlstate+ndeath,-1,nlstate+ndeath,(int) agemin,(int) agemax+3); + free_ma3x(freq,-1,nlstate+ndeath,-1,nlstate+ndeath, iagemin, iagemax+3); free_vector(pp,1,nlstate); - + free_matrix(prop,1,nlstate,iagemin, iagemax+3); /* End of Freq */ } /************ Prevalence ********************/ -void prevalence(int agemin, float agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax,double **mint,double **anint, double dateprev1,double dateprev2, int firstpass, int lastpass) +void prevalence(double agemin, double agemax, int **s, double **agev, int nlstate, int imx, int *Tvar, int **nbcode, int *ncodemax,double **mint,double **anint, double dateprev1,double dateprev2, int firstpass, int lastpass) { /* Compute observed prevalence between dateprev1 and dateprev2 by counting the number of people in each health status at the date of interview (if between dateprev1 and dateprev2). @@ -1565,13 +1670,16 @@ void prevalence(int agemin, float agemax int i, m, jk, k1, i1, j1, bool, z1,z2,j; double ***freq; /* Frequencies */ - double *pp; - double pos; + double *pp, **prop; + double pos,posprop; double y2; /* in fractional years */ + int iagemin, iagemax; - pp=vector(1,nlstate); - - freq=ma3x(-1,nlstate+ndeath,-1,nlstate+ndeath,agemin,agemax+3); + iagemin= (int) agemin; + iagemax= (int) agemax; + /*pp=vector(1,nlstate);*/ + prop=matrix(1,nlstate,iagemin,iagemax+3); + /* freq=ma3x(-1,nlstate+ndeath,-1,nlstate+ndeath,iagemin,iagemax+3);*/ j1=0; j=cptcoveff; @@ -1581,10 +1689,9 @@ void prevalence(int agemin, float agemax for(i1=1; i1<=ncodemax[k1];i1++){ j1++; - for (i=-1; i<=nlstate+ndeath; i++) - for (jk=-1; jk<=nlstate+ndeath; jk++) - for(m=agemin; m <= agemax+3; m++) - freq[i][jk][m]=0; + for (i=1; i<=nlstate; i++) + for(m=iagemin; m <= iagemax+3; m++) + prop[i][m]=0.0; for (i=1; i<=imx; i++) { /* Each individual */ bool=1; @@ -1597,49 +1704,39 @@ void prevalence(int agemin, float agemax for(m=firstpass; m<=lastpass; m++){/* Other selection (we can limit to certain interviews*/ y2=anint[m][i]+(mint[m][i]/12.); /* Fractional date in year */ if ((y2>=dateprev1) && (y2<=dateprev2)) { /* Here is the main selection (fractional years) */ - if(agev[m][i]==0) agev[m][i]=agemax+1; - if(agev[m][i]==1) agev[m][i]=agemax+2; - if (miagemax+3) printf("Error on individual =%d agev[m][i]=%f m=%d\n",i, agev[m][i],m); + if (s[m][i]>0 && s[m][i]<=nlstate) { + /*if(i>4620) printf(" i=%d m=%d s[m][i]=%d (int)agev[m][i]=%d weight[i]=%f prop=%f\n",i,m,s[m][i],(int)agev[m][m],weight[i],prop[s[m][i]][(int)agev[m][i]]);*/ + prop[s[m][i]][(int)agev[m][i]] += weight[i]; + prop[s[m][i]][iagemax+3] += weight[i]; + } } } /* end selection of waves */ } } - for(i=(int)agemin; i <= (int)agemax+3; i++){ - for(jk=1; jk <=nlstate ; jk++){ - for(m=-1, pp[jk]=0; m <=nlstate+ndeath ; m++) - pp[jk] += freq[jk][m][i]; - } - for(jk=1; jk <=nlstate ; jk++){ - for(m=-1, pos=0; m <=0 ; m++) - pos += freq[jk][m][i]; - } - - for(jk=1; jk <=nlstate ; jk++){ - for(m=0, pp[jk]=0; m <=nlstate+ndeath; m++) - pp[jk] += freq[jk][m][i]; - } - - for(jk=1,pos=0; jk <=nlstate ; jk++) pos += pp[jk]; + for(i=iagemin; i <= iagemax+3; i++){ - for(jk=1; jk <=nlstate ; jk++){ - if( i <= (int) agemax){ - if(pos>=1.e-5){ - probs[i][jk][j1]= pp[jk]/pos; - } - } - }/* end jk */ - }/* end i */ + for(jk=1,posprop=0; jk <=nlstate ; jk++) { + posprop += prop[jk][i]; + } + + for(jk=1; jk <=nlstate ; jk++){ + if( i <= iagemax){ + if(posprop>=1.e-5){ + probs[i][jk][j1]= prop[jk][i]/posprop; + } + } + }/* end jk */ + }/* end i */ } /* end i1 */ } /* end k1 */ - - - free_ma3x(freq,-1,nlstate+ndeath,-1,nlstate+ndeath,(int) agemin,(int) agemax+3); - free_vector(pp,1,nlstate); -} /* End of Freq */ + /* free_ma3x(freq,-1,nlstate+ndeath,-1,nlstate+ndeath, iagemin, iagemax+3);*/ + /*free_vector(pp,1,nlstate);*/ + free_matrix(prop,1,nlstate, iagemin,iagemax+3); +} /* End of prevalence */ /************* Waves Concatenation ***************/ @@ -1683,21 +1780,21 @@ void concatwav(int wav[], int **dh, int wav[i]=mi; if(mi==0){ if(first==0){ - printf("Warning, no any valid information for:%d line=%d and may be others, see log file\n",num[i],i); + printf("Warning! None valid information for:%d line=%d (skipped) and may be others, see log file\n",num[i],i); first=1; } if(first==1){ - fprintf(ficlog,"Warning, no any valid information for:%d line=%d\n",num[i],i); + fprintf(ficlog,"Warning! None valid information for:%d line=%d (skipped)\n",num[i],i); } } /* end mi==0 */ - } + } /* End individuals */ for(i=1; i<=imx; i++){ for(mi=1; mi nlstate) { + if (s[mw[mi+1][i]][i] > nlstate) { /* A death */ if (agedc[i] < 2*AGESUP) { j= rint(agedc[i]*12-agev[mw[mi][i]][i]*12); if(j==0) j=1; /* Survives at least one month after exam */ @@ -1705,8 +1802,9 @@ void concatwav(int wav[], int **dh, int if (j >= jmax) jmax=j; if (j <= jmin) jmin=j; sum=sum+j; - /*if (j<0) printf("j=%d num=%d \n",j,i); */ + /*if (j<0) printf("j=%d num=%d \n",j,i);*/ /* printf("%d %d %d %d\n", s[mw[mi][i]][i] ,s[mw[mi+1][i]][i],j,i);*/ + if(j<0)printf("Error! Negative delay (%d to death) between waves %d and %d of individual %d at line %d who is aged %.1f with statuses from %d to %d\n ",j,mw[mi][i],mw[mi+1][i],num[i], i,agev[mw[mi][i]][i],s[mw[mi][i]][i] ,s[mw[mi+1][i]][i]); } } else{ @@ -1716,6 +1814,8 @@ void concatwav(int wav[], int **dh, int if (j >= jmax) jmax=j; else if (j <= jmin)jmin=j; /* if (j<10) printf("j=%d jmin=%d num=%d ",j,jmin,i); */ + /*printf("%d %lf %d %d %d\n", i,agev[mw[mi][i]][i],j,s[mw[mi][i]][i] ,s[mw[mi+1][i]][i]);*/ + if(j<0)printf("Error! Negative delay (%d) between waves %d and %d of individual %d at line %d who is aged %.1f with statuses from %d to %d\n ",j,mw[mi][i],mw[mi+1][i],num[i], i,agev[mw[mi][i]][i],s[mw[mi][i]][i] ,s[mw[mi+1][i]][i]); sum=sum+j; } jk= j/stepm; @@ -1744,7 +1844,7 @@ void concatwav(int wav[], int **dh, int if(dh[mi][i]==0){ dh[mi][i]=1; /* At least one step */ bh[mi][i]=ju; /* At least one step */ - printf(" bh=%d ju=%d jl=%d dh=%d jk=%d stepm=%d %d\n",bh[mi][i],ju,jl,dh[mi][i],jk,stepm,i); + /* printf(" bh=%d ju=%d jl=%d dh=%d jk=%d stepm=%d %d\n",bh[mi][i],ju,jl,dh[mi][i],jk,stepm,i);*/ } } } /* end if mle */ @@ -1829,10 +1929,10 @@ void evsij(char fileres[], double ***eij double ***gradg, ***trgradg; int theta; - varhe=ma3x(1,nlstate*2,1,nlstate*2,(int) bage, (int) fage); + varhe=ma3x(1,nlstate*nlstate,1,nlstate*nlstate,(int) bage, (int) fage); xp=vector(1,npar); - dnewm=matrix(1,nlstate*2,1,npar); - doldm=matrix(1,nlstate*2,1,nlstate*2); + dnewm=matrix(1,nlstate*nlstate,1,npar); + doldm=matrix(1,nlstate*nlstate,1,nlstate*nlstate); fprintf(ficreseij,"# Health expectancies\n"); fprintf(ficreseij,"# Age"); @@ -1878,9 +1978,9 @@ void evsij(char fileres[], double ***eij /* if (stepm >= YEARM) hstepm=1;*/ nhstepm = nstepm/hstepm;/* Expressed in hstepm, typically nhstepm=40/4=10 */ p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); - gradg=ma3x(0,nhstepm,1,npar,1,nlstate*2); - gp=matrix(0,nhstepm,1,nlstate*2); - gm=matrix(0,nhstepm,1,nlstate*2); + gradg=ma3x(0,nhstepm,1,npar,1,nlstate*nlstate); + gp=matrix(0,nhstepm,1,nlstate*nlstate); + gm=matrix(0,nhstepm,1,nlstate*nlstate); /* Computed by stepm unit matrices, product of hstepm matrices, stored in an array of nhstepm length: nhstepm=10, hstepm=4, stepm=6 months */ @@ -1917,11 +2017,12 @@ void evsij(char fileres[], double ***eij for(i=1;i<=nlstate;i++){ cptj=cptj+1; for(h=0, gm[h][cptj]=0.; h<=nhstepm-1; h++){ + gm[h][cptj] = (p3mat[i][j][h]+p3mat[i][j][h+1])/2.; } } } - for(j=1; j<= nlstate*2; j++) + for(j=1; j<= nlstate*nlstate; j++) for(h=0; h<=nhstepm-1; h++){ gradg[h][theta][j]= (gp[h][j]-gm[h][j])/2./delti[theta]; } @@ -1929,26 +2030,26 @@ void evsij(char fileres[], double ***eij /* End theta */ - trgradg =ma3x(0,nhstepm,1,nlstate*2,1,npar); + trgradg =ma3x(0,nhstepm,1,nlstate*nlstate,1,npar); for(h=0; h<=nhstepm-1; h++) - for(j=1; j<=nlstate*2;j++) + for(j=1; j<=nlstate*nlstate;j++) for(theta=1; theta <=npar; theta++) trgradg[h][j][theta]=gradg[h][theta][j]; - for(i=1;i<=nlstate*2;i++) - for(j=1;j<=nlstate*2;j++) + for(i=1;i<=nlstate*nlstate;i++) + for(j=1;j<=nlstate*nlstate;j++) varhe[i][j][(int)age] =0.; printf("%d|",(int)age);fflush(stdout); fprintf(ficlog,"%d|",(int)age);fflush(ficlog); for(h=0;h<=nhstepm-1;h++){ for(k=0;k<=nhstepm-1;k++){ - matprod2(dnewm,trgradg[h],1,nlstate*2,1,npar,1,npar,matcov); - matprod2(doldm,dnewm,1,nlstate*2,1,npar,1,nlstate*2,gradg[k]); - for(i=1;i<=nlstate*2;i++) - for(j=1;j<=nlstate*2;j++) + matprod2(dnewm,trgradg[h],1,nlstate*nlstate,1,npar,1,npar,matcov); + matprod2(doldm,dnewm,1,nlstate*nlstate,1,npar,1,nlstate*nlstate,gradg[k]); + for(i=1;i<=nlstate*nlstate;i++) + for(j=1;j<=nlstate*nlstate;j++) varhe[i][j][(int)age] += doldm[i][j]*hf*hf; } } @@ -1971,19 +2072,19 @@ void evsij(char fileres[], double ***eij } fprintf(ficreseij,"\n"); - free_matrix(gm,0,nhstepm,1,nlstate*2); - free_matrix(gp,0,nhstepm,1,nlstate*2); - free_ma3x(gradg,0,nhstepm,1,npar,1,nlstate*2); - free_ma3x(trgradg,0,nhstepm,1,nlstate*2,1,npar); + free_matrix(gm,0,nhstepm,1,nlstate*nlstate); + free_matrix(gp,0,nhstepm,1,nlstate*nlstate); + free_ma3x(gradg,0,nhstepm,1,npar,1,nlstate*nlstate); + free_ma3x(trgradg,0,nhstepm,1,nlstate*nlstate,1,npar); free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); } printf("\n"); fprintf(ficlog,"\n"); free_vector(xp,1,npar); - free_matrix(dnewm,1,nlstate*2,1,npar); - free_matrix(doldm,1,nlstate*2,1,nlstate*2); - free_ma3x(varhe,1,nlstate*2,1,nlstate*2,(int) bage, (int)fage); + free_matrix(dnewm,1,nlstate*nlstate,1,npar); + free_matrix(doldm,1,nlstate*nlstate,1,nlstate*nlstate); + free_ma3x(varhe,1,nlstate*nlstate,1,nlstate*nlstate,(int) bage, (int)fage); } /************ Variance ******************/ @@ -2279,10 +2380,10 @@ void varevsij(char optionfilefiname[], d fprintf(ficgp,"\n replot \"%s\" u 1:(($3+1.96*$4)) t \"95\%% interval\" w l 2 ",fileresprobmorprev); fprintf(ficgp,"\n replot \"%s\" u 1:(($3-1.96*$4)) not w l 2 ",fileresprobmorprev); fprintf(fichtm,"\n
File (multiple files are possible if covariates are present): %s\n",fileresprobmorprev,fileresprobmorprev); - fprintf(fichtm,"\n
Probability is computed over estepm=%d months.

\n", estepm,digitp,digit); + fprintf(fichtm,"\n
Probability is computed over estepm=%d months.

\n", estepm,digitp,optionfilefiname,digit); /* fprintf(fichtm,"\n
Probability is computed over estepm=%d months and then divided by estepm and multiplied by %.0f in order to have the probability to die over a year

\n", stepm,YEARM,digitp,digit); */ - fprintf(ficgp,"\nset out \"varmuptjgr%s%s.png\";replot;",digitp,digit); + fprintf(ficgp,"\nset out \"varmuptjgr%s%s%s.png\";replot;",digitp,optionfilefiname,digit); free_vector(xp,1,npar); free_matrix(doldm,1,nlstate,1,nlstate); @@ -2518,7 +2619,7 @@ void varprob(char optionfilefiname[], do for(theta=1; theta <=npar; theta++){ for(i=1; i<=npar; i++) - xp[i] = x[i] + (i==theta ?delti[theta]:0); + xp[i] = x[i] + (i==theta ?delti[theta]:(double)0); pmij(pmmij,cov,ncovmodel,xp,nlstate); @@ -2531,7 +2632,7 @@ void varprob(char optionfilefiname[], do } for(i=1; i<=npar; i++) - xp[i] = x[i] - (i==theta ?delti[theta]:0); + xp[i] = x[i] - (i==theta ?delti[theta]:(double)0); pmij(pmmij,cov,ncovmodel,xp,nlstate); k=0; @@ -2543,7 +2644,7 @@ void varprob(char optionfilefiname[], do } for(i=1; i<= (nlstate)*(nlstate+ndeath); i++) - gradg[theta][i]=(gp[i]-gm[i])/2./delti[theta]; + gradg[theta][i]=(gp[i]-gm[i])/(double)2./delti[theta]; } for(j=1; j<=(nlstate)*(nlstate+ndeath);j++) @@ -2730,7 +2831,7 @@ fprintf(fichtm," \n
  • Graphs fprintf(fichtm," ************\n
    "); } /* Pij */ - fprintf(fichtm,"
    - Pij or Conditional probabilities to be observed in state j being in state i %d (stepm) months before: pe%s%d1.png
    + fprintf(fichtm,"
    - Pij or Conditional probabilities to be observed in state j being in state i, %d (stepm) months before: pe%s%d1.png
    ",stepm,strtok(optionfile, "."),jj1,strtok(optionfile, "."),jj1); /* Quasi-incidences */ fprintf(fichtm,"
    - Pij or Conditional probabilities to be observed in state j being in state i %d (stepm) months before but expressed in per year i.e. quasi incidences if stepm is small and probabilities too: pe%s%d2.png
    @@ -2761,12 +2862,12 @@ health expectancies in states (1) and (2 - Health expectancies with their variances (no covariance): t%s
    \n - Standard deviation of stable prevalences: vpl%s
    \n",rfileres,rfileres,fileres,fileres,fileres,fileres,fileres,fileres, estepm, fileres,fileres,fileres,fileres,fileres,fileres); - if(popforecast==1) fprintf(fichtm,"\n - - Prevalences forecasting: f%s
    \n - - Population forecasting (if popforecast=1): pop%s
    \n -
    ",fileres,fileres,fileres,fileres); - else - fprintf(fichtm,"\n No population forecast: popforecast = %d (instead of 1) or stepm = %d (instead of 1) or model=%s (instead of .)

  • \n",popforecast, stepm, model); +/* if(popforecast==1) fprintf(fichtm,"\n */ +/* - Prevalences forecasting: f%s
    \n */ +/* - Population forecasting (if popforecast=1): pop%s
    \n */ +/*
    ",fileres,fileres,fileres,fileres); */ +/* else */ +/* fprintf(fichtm,"\n No population forecast: popforecast = %d (instead of 1) or stepm = %d (instead of 1) or model=%s (instead of .)

    \n",popforecast, stepm, model); */ fprintf(fichtm,"
    • Graphs
    • "); m=cptcoveff; @@ -2783,7 +2884,7 @@ fprintf(fichtm,"

      • Graphs"); } for(cpt=1; cpt<=nlstate;cpt++) { - fprintf(fichtm,"
        - Observed and stationary prevalence (with confident + fprintf(fichtm,"
        - Observed and period prevalence (with confident interval) in state (%d): v%s%d%d.png
        ",cpt,strtok(optionfile, "."),cpt,jj1,strtok(optionfile, "."),cpt,jj1); } @@ -2884,14 +2985,14 @@ m=pow(2,cptcoveff); } } - /* CV preval stat */ + /* CV preval stable (period) */ for (k1=1; k1<= m ; k1 ++) { - for (cpt=1; cpt=ageminpar; agec--){ + for (agec=fage; agec>=(ageminpar-1); agec--){ nhstepm=(int) rint((agelim-agec)*YEARM/stepm); nhstepm = nhstepm/hstepm; p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); @@ -3095,7 +3204,7 @@ prevforecast(char fileres[], double anpr hpxij(p3mat,nhstepm,agec,hstepm,p,nlstate,stepm,oldm,savm, k); for (h=0; h<=nhstepm; h++){ - if (h==(int) (YEARM*yearp)) { + if (h*hstepm/YEARM*stepm ==yearp) { fprintf(ficresf,"\n"); for(j=1;j<=cptcoveff;j++) fprintf(ficresf,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); @@ -3103,25 +3212,26 @@ prevforecast(char fileres[], double anpr } for(j=1; j<=nlstate+ndeath;j++) { ppij=0.; - for(i=1; i<=nlstate;i++) { + for(i=1; i<=nlstate;i++) { if (mobilav==1) - ppij=ppij+p3mat[i][j][h]*mobaverage[(int)agec+1][i][cptcod]; + ppij=ppij+p3mat[i][j][h]*mobaverage[(int)agec][i][cptcod]; else { - ppij=ppij+p3mat[i][j][h]*probs[(int)(agec+1)][i][cptcod]; + ppij=ppij+p3mat[i][j][h]*probs[(int)(agec)][i][cptcod]; } - if (h==(int)(YEARM*yearp)) + if (h*hstepm/YEARM*stepm== yearp) { fprintf(ficresf," %.3f", p3mat[i][j][h]); - } - if (h==(int)(YEARM*yearp)){ + } + } /* end i */ + if (h*hstepm/YEARM*stepm==yearp) { fprintf(ficresf," %.3f", ppij); } - } - } + }/* end j */ + } /* end h */ free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); - } - } - } - } + } /* end agec */ + } /* end yearp */ + } /* end cptcod */ + } /* end cptcov */ if (mobilav!=0) free_ma3x(mobaverage,1, AGESUP,1,NCOVMAX, 1,NCOVMAX); @@ -3295,7 +3405,7 @@ populforecast(char fileres[], double anp int main(int argc, char *argv[]) { int movingaverage(double ***probs, double bage,double fage, double ***mobaverage, int mobilav); - int i,j, k, n=MAXN,iter,m,size,cptcode, cptcod; + int i,j, k, n=MAXN,iter,m,size=100,cptcode, cptcod; double agedeb, agefin,hf; double ageminpar=1.e20,agemin=1.e20, agemaxpar=-1.e20, agemax=-1.e20; @@ -3317,7 +3427,8 @@ int main(int argc, char *argv[]) int mobilavproj=0 , prevfcast=0 ; /* moving average of prev, If prevfcast=1 prevalence projection */ int mobilav=0,popforecast=0; int hstepm, nhstepm; - double jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,jpyram, mpyram,anpyram,jpyram1, mpyram1,anpyram1; + double jprev1=1, mprev1=1,anprev1=2000,jprev2=1, mprev2=1,anprev2=2000; + double jpyram=1, mpyram=1,anpyram=2000,jpyram1=1, mpyram1=1,anpyram1=2000; double bage, fage, age, agelim, agebase; double ftolpl=FTOL; @@ -3332,7 +3443,7 @@ int main(int argc, char *argv[]) double **varpl; /* Variances of prevalence limits by age */ double *epj, vepp; double kk1, kk2; - double dateprev1, dateprev2,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2; + double dateprev1, dateprev2,jproj1=1,mproj1=1,anproj1=2000,jproj2=1,mproj2=1,anproj2=2000; char *alph[]={"a","a","b","c","d","e"}, str[4]; @@ -3479,7 +3590,7 @@ int main(int argc, char *argv[]) ungetc(c,ficpar); delti3= ma3x(1,nlstate,1,nlstate+ndeath-1,1,ncovmodel); - delti=vector(1,npar); /* Scale of each paramater (output from hesscov) */ + /* delti=vector(1,npar); *//* Scale of each paramater (output from hesscov) */ for(i=1; i <=nlstate; i++){ for(j=1; j <=nlstate+ndeath-1; j++){ fscanf(ficpar,"%1d%1d",&i1,&j1); @@ -3496,6 +3607,9 @@ int main(int argc, char *argv[]) } } delti=delti3[1][1]; + + + /* free_ma3x(delti3,1,nlstate,1,nlstate+ndeath-1,1,ncovmodel); */ /* Hasn't to to freed here otherwise delti is no more allocated */ /* Reads comments: lines beginning with '#' */ while((c=getc(ficpar))=='#' && c!= EOF){ @@ -3615,7 +3729,11 @@ int main(int argc, char *argv[]) if (s[4][i]==9) s[4][i]=-1; 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]));}*/ + for (i=1; i<=imx; i++) + /*if ((s[3][i]==3) || (s[4][i]==3)) weight[i]=0.08; + else weight[i]=1;*/ + /* Calculation of the number of parameter from char model*/ Tvar=ivector(1,15); /* stores the number n of the covariates in Vm+Vn at 1 and m at 2 */ Tprod=ivector(1,15); @@ -3707,25 +3825,34 @@ int main(int argc, char *argv[]) for (i=1; i<=imx; i++) { for(m=2; (m<= maxwav); m++) { - if ((mint[m][i]== 99) && (s[m][i] <= nlstate)){ + if (((int)mint[m][i]== 99) && (s[m][i] <= nlstate)){ anint[m][i]=9999; s[m][i]=-1; } - if(moisdc[i]==99 && andc[i]==9999 & s[m][i]>nlstate) s[m][i]=-1; + if((int)moisdc[i]==99 && (int)andc[i]==9999 && s[m][i]>nlstate){ + printf("Error! Date of death (month %2d and year %4d) of individual %d on line %d was unknown, you must set an arbitrary year of death or he/she is skipped and results are biased\n",(int)moisdc[i],(int)andc[i],num[i],i); + fprintf(ficlog,"Error! Date of death (month %2d and year %4d) of individual %d on line %d was unknown, you must set an arbitrary year of death or he/she is skipped and results are biased\n",(int)moisdc[i],(int)andc[i],num[i],i); + s[m][i]=-1; + } + if((int)moisdc[i]==99 && (int)andc[i]!=9999 && s[m][i]>nlstate){ + printf("Error! Month of death of individual %d on line %d was unknown %2d, you should set it otherwise the information on the death is skipped and results are biased.\n",num[i],i,(int)moisdc[i]); + fprintf(ficlog,"Error! Month of death of individual %d on line %d was unknown %f, you should set it otherwise the information on the death is skipped and results are biased.\n",num[i],i,moisdc[i]); + s[m][i]=-1; + } } } for (i=1; i<=imx; i++) { agedc[i]=(moisdc[i]/12.+andc[i])-(moisnais[i]/12.+annais[i]); - for(m=1; (m<= maxwav); m++){ + for(m=firstpass; (m<= lastpass); m++){ if(s[m][i] >0){ if (s[m][i] >= nlstate+1) { if(agedc[i]>0) - if(moisdc[i]!=99 && andc[i]!=9999) + if((int)moisdc[i]!=99 && (int)andc[i]!=9999) agev[m][i]=agedc[i]; /*if(moisdc[i]==99 && andc[i]==9999) s[m][i]=-1;*/ else { - if (andc[i]!=9999){ + if ((int)andc[i]!=9999){ printf("Warning negative age at death: %d line:%d\n",num[i],i); fprintf(ficlog,"Warning negative age at death: %d line:%d\n",num[i],i); agev[m][i]=-1; @@ -3736,7 +3863,7 @@ int main(int argc, char *argv[]) years but with the precision of a month */ 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((int)mint[m][i]==99 || (int)anint[m][i]==9999) agev[m][i]=1; else if(agev[m][i] (nlstate+ndeath)) { printf("Error: on wave %d of individual %d status %d > (nlstate+ndeath)=(%d+%d)=%d\n",m,i,s[m][i],nlstate, ndeath, nlstate+ndeath); fprintf(ficlog,"Error: on wave %d of individual %d status %d > (nlstate+ndeath)=(%d+%d)=%d\n",m,i,s[m][i],nlstate, ndeath, nlstate+ndeath); @@ -3769,6 +3896,13 @@ int main(int argc, char *argv[]) } } + /*for (i=1; i<=imx; i++){ + for (m=firstpass; (mDatafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s
        \n \n Total number of observations=%d
        \n +Youngest age at first (selected) pass %.2f, oldest age %.2f
        \n Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf
        \n
        • Parameter files

          \n - Copy of the parameter file: o%s
          \n - Log file of the run: %s
          \n - - Gnuplot file name: %s
        \n",version,title,datafile,firstpass,lastpass,stepm, weightopt,model,imx,jmin,jmax,jmean,fileres,fileres,filelog,filelog,optionfilegnuplot,optionfilegnuplot); - fclose(fichtm); + - Gnuplot file name: %s
      \n",version,title,datafile,firstpass,lastpass,stepm, weightopt,model,imx,agemin,agemax,jmin,jmax,jmean,fileres,fileres,filelog,filelog,optionfilegnuplot,optionfilegnuplot); + fclose(fichtm); printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,model,imx,jmin,jmax,jmean,rfileres,popforecast,estepm,jprev1,mprev1,anprev1,jprev2,mprev2,anprev2); @@ -4158,7 +4294,7 @@ Interval (in months) between two waves: } } - varprob(optionfilefiname, matcov, p, delti, nlstate, (int) bage, (int) fage,k,Tvar,nbcode, ncodemax); + varprob(optionfilefiname, matcov, p, delti, nlstate, bage, fage,k,Tvar,nbcode, ncodemax); fclose(ficrespij); @@ -4166,15 +4302,15 @@ Interval (in months) between two waves: /*---------- Forecasting ------------------*/ /*if((stepm == 1) && (strcmp(model,".")==0)){*/ if(prevfcast==1){ - if(stepm ==1){ + /* if(stepm ==1){*/ prevforecast(fileres, anproj1, mproj1, jproj1, agemin, agemax, dateprev1, dateprev2, mobilavproj, bage, fage, firstpass, lastpass, anproj2, p, cptcoveff); - if (popforecast==1) populforecast(fileres, anpyram,mpyram,jpyram, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anpyram1,p, i1); - } - else{ - erreur=108; - printf("Warning %d!! You can only forecast the prevalences if the optimization\n has been performed with stepm = 1 (month) instead of %d or model=. instead of '%s'\n", erreur, stepm, model); - fprintf(ficlog,"Warning %d!! You can only forecast the prevalences if the optimization\n has been performed with stepm = 1 (month) instead of %d or model=. instead of '%s'\n", erreur, stepm, model); - } + /* (popforecast==1) populforecast(fileres, anpyram,mpyram,jpyram, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anpyram1,p, i1);*/ +/* } */ +/* else{ */ +/* erreur=108; */ +/* printf("Warning %d!! You can only forecast the prevalences if the optimization\n has been performed with stepm = 1 (month) instead of %d or model=. instead of '%s'\n", erreur, stepm, model); */ +/* fprintf(ficlog,"Warning %d!! You can only forecast the prevalences if the optimization\n has been performed with stepm = 1 (month) instead of %d or model=. instead of '%s'\n", erreur, stepm, model); */ +/* } */ } @@ -4208,7 +4344,11 @@ Interval (in months) between two waves: printf("Computing Variance-covariance of DFLEs: file '%s' \n", fileresv); fprintf(ficlog,"Computing Variance-covariance of DFLEs: file '%s' \n", fileresv); - prevalence(ageminpar, agemax, s, agev, nlstate, imx, Tvar, nbcode, ncodemax, mint, anint, dateprev1, dateprev2, firstpass, lastpass); + /* Computes prevalence between agemin (i.e minimal age computed) and no more ageminpar */ + prevalence(agemin, agemax, s, agev, nlstate, imx, Tvar, nbcode, ncodemax, mint, anint, dateprev1, dateprev2, firstpass, lastpass); + /* printf("ageminpar=%f, agemax=%f, s[lastpass][imx]=%d, agev[lastpass][imx]=%f, nlstate=%d, imx=%d, mint[lastpass][imx]=%f, anint[lastpass][imx]=%f,dateprev1=%f, dateprev2=%f, firstpass=%d, lastpass=%d\n",\ +ageminpar, agemax, s[lastpass][imx], agev[lastpass][imx], nlstate, imx, mint[lastpass][imx],anint[lastpass][imx], dateprev1, dateprev2, firstpass, lastpass); + */ if (mobilav!=0) { mobaverage= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX); @@ -4335,10 +4475,13 @@ Interval (in months) between two waves: free_matrix(covar,0,NCOVMAX,1,n); free_matrix(matcov,1,npar,1,npar); - free_vector(delti,1,npar); + /*free_vector(delti,1,npar);*/ + free_ma3x(delti3,1,nlstate,1, nlstate+ndeath-1,1,ncovmodel); free_matrix(agev,1,maxwav,1,imx); free_ma3x(param,1,nlstate,1, nlstate+ndeath-1,1,ncovmodel); if (mobilav!=0) free_ma3x(mobaverage,1, AGESUP,1,NCOVMAX, 1,NCOVMAX); + free_ma3x(probs,1,AGESUP,1,NCOVMAX, 1,NCOVMAX); + free_ivector(ncodemax,1,8); free_ivector(Tvar,1,15); free_ivector(Tprod,1,15); @@ -4346,9 +4489,8 @@ Interval (in months) between two waves: free_ivector(Tage,1,15); free_ivector(Tcode,1,100); - fprintf(fichtm,"\n"); - fclose(fichtm); - fclose(ficgp); + /* fclose(fichtm);*/ + /* fclose(ficgp);*/ /* ALready done */ if(erreur >0){ @@ -4377,8 +4519,9 @@ Interval (in months) between two waves: strcpy(plotcmd,GNUPLOTPROGRAM); strcat(plotcmd," "); strcat(plotcmd,optionfilegnuplot); - printf("Starting: %s\n",plotcmd);fflush(stdout); + printf("Starting graphs with: %s",plotcmd);fflush(stdout); system(plotcmd); + printf(" Wait..."); /*#ifdef windows*/ while (z[0] != 'q') {