|
|
| version 1.212, 2015/11/21 12:47:24 | version 1.213, 2015/12/11 18:22:17 |
|---|---|
| Line 1 | Line 1 |
| /* $Id$ | /* $Id$ |
| $State$ | $State$ |
| $Log$ | $Log$ |
| Revision 1.213 2015/12/11 18:22:17 brouard | |
| Summary: 0.98r4 | |
| Revision 1.212 2015/11/21 12:47:24 brouard | Revision 1.212 2015/11/21 12:47:24 brouard |
| Summary: minor typo | Summary: minor typo |
| Line 824 double **matprod2(); /* test */ | Line 827 double **matprod2(); /* test */ |
| 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 ; */ /* Used in readdata only */ | /*FILE *fic ; */ /* Used in readdata only */ |
| FILE *ficpar, *ficparo,*ficres, *ficresp, *ficrespl, *ficrespij, *ficrest,*ficresf,*ficrespop; | FILE *ficpar, *ficparo,*ficres, *ficresp, *ficresphtm, *ficrespl, *ficrespij, *ficrest,*ficresf,*ficrespop; |
| FILE *ficlog, *ficrespow; | FILE *ficlog, *ficrespow; |
| int globpr=0; /* Global variable for printing or not */ | int globpr=0; /* Global variable for printing or not */ |
| double fretone; /* Only one call to likelihood */ | double fretone; /* Only one call to likelihood */ |
| Line 1386 char *subdirf3(char fileres[], char *pre | Line 1389 char *subdirf3(char fileres[], char *pre |
| strcat(tmpout,fileres); | strcat(tmpout,fileres); |
| return tmpout; | return tmpout; |
| } | } |
| /*************** function subdirfext ***********/ | |
| char *subdirfext(char fileres[], char *preop, char *postop) | |
| { | |
| strcpy(tmpout,preop); | |
| strcat(tmpout,fileres); | |
| strcat(tmpout,postop); | |
| return tmpout; | |
| } | |
| /*************** function subdirfext3 ***********/ | |
| char *subdirfext3(char fileres[], char *preop, char *postop) | |
| { | |
| /* Caution optionfilefiname is hidden */ | |
| strcpy(tmpout,optionfilefiname); | |
| strcat(tmpout,"/"); | |
| strcat(tmpout,preop); | |
| strcat(tmpout,fileres); | |
| strcat(tmpout,postop); | |
| return tmpout; | |
| } | |
| char *asc_diff_time(long time_sec, char ascdiff[]) | char *asc_diff_time(long time_sec, char ascdiff[]) |
| { | { |
| long sec_left, days, hours, minutes; | long sec_left, days, hours, minutes; |
| Line 3196 void freqsummary(char fileres[], int ia | Line 3222 void freqsummary(char fileres[], int ia |
| double ***freq; /* Frequencies */ | double ***freq; /* Frequencies */ |
| double *pp, **prop; | double *pp, **prop; |
| double pos,posprop, k2, dateintsum=0,k2cpt=0; | double pos,posprop, k2, dateintsum=0,k2cpt=0; |
| char fileresp[FILENAMELENGTH]; | char fileresp[FILENAMELENGTH], fileresphtm[FILENAMELENGTH]; |
| pp=vector(1,nlstate); | pp=vector(1,nlstate); |
| prop=matrix(1,nlstate,iagemin,iagemax+3); | prop=matrix(1,nlstate,iagemin,iagemax+3); |
| strcpy(fileresp,"P_"); | strcpy(fileresp,"P_"); |
| strcat(fileresp,fileresu); | strcat(fileresp,fileresu); |
| /*strcat(fileresphtm,fileresu);*/ | |
| if((ficresp=fopen(fileresp,"w"))==NULL) { | if((ficresp=fopen(fileresp,"w"))==NULL) { |
| printf("Problem with prevalence resultfile: %s\n", fileresp); | printf("Problem with prevalence resultfile: %s\n", fileresp); |
| fprintf(ficlog,"Problem with prevalence resultfile: %s\n", fileresp); | fprintf(ficlog,"Problem with prevalence resultfile: %s\n", fileresp); |
| exit(0); | exit(0); |
| } | } |
| printf("Problem with prevalence resultfile: %s\n", fileresp); | |
| strcpy(fileresphtm,subdirfext(optionfilefiname,"PHTM_",".htm")); | |
| if((ficresphtm=fopen(fileresphtm,"w"))==NULL) { | |
| printf("Problem with prevalence HTM resultfile '%s' with errno='%s'\n",fileresphtm,strerror(errno)); | |
| fprintf(ficlog,"Problem with prevalence HTM resultfile '%s' with errno='%s'\n",fileresphtm,strerror(errno)); | |
| fflush(ficlog); | |
| exit(70); | |
| } | |
| freq= ma3x(-5,nlstate+ndeath,-5,nlstate+ndeath,iagemin,iagemax+3); | freq= ma3x(-5,nlstate+ndeath,-5,nlstate+ndeath,iagemin,iagemax+3); |
| j1=0; | j1=0; |
| Line 3252 void freqsummary(char fileres[], int ia | Line 3287 void freqsummary(char fileres[], int ia |
| /*if ((k2>=dateprev1) && (k2<=dateprev2)) {*/ | /*if ((k2>=dateprev1) && (k2<=dateprev2)) {*/ |
| if(agev[m][i]==0) agev[m][i]=iagemax+1; | if(agev[m][i]==0) agev[m][i]=iagemax+1; |
| if(agev[m][i]==1) agev[m][i]=iagemax+2; | 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 (s[m][i]>0 && s[m][i]<=nlstate) |
| prop[s[m][i]][(int)agev[m][i]] += weight[i]; | |
| if (m<lastpass) { | if (m<lastpass) { |
| freq[s[m][i]][s[m+1][i]][(int)agev[m][i]] += weight[i]; | freq[s[m][i]][s[m+1][i]][(int)agev[m][i]] += weight[i]; |
| freq[s[m][i]][s[m+1][i]][iagemax+3] += weight[i]; | freq[s[m][i]][s[m+1][i]][iagemax+3] += weight[i]; |
| Line 3272 void freqsummary(char fileres[], int ia | Line 3308 void freqsummary(char fileres[], int ia |
| pstamp(ficresp); | pstamp(ficresp); |
| if (cptcovn>0) { | if (cptcovn>0) { |
| fprintf(ficresp, "\n#********** Variable "); | fprintf(ficresp, "\n#********** Variable "); |
| for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresp, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,z1)]); | fprintf(ficresphtm, "\n<h3>********** Variable "); |
| fprintf(ficresp, "**********\n#"); | for (z1=1; z1<=cptcoveff; z1++){ |
| fprintf(ficresp, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,z1)]); | |
| fprintf(ficresphtm, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,z1)]); | |
| } | |
| fprintf(ficresp, "**********\n#"); | |
| fprintf(ficresphtm, "**********</h3>\n#"); | |
| fprintf(ficlog, "\n#********** Variable "); | fprintf(ficlog, "\n#********** Variable "); |
| for (z1=1; z1<=cptcoveff; z1++) fprintf(ficlog, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,z1)]); | for (z1=1; z1<=cptcoveff; z1++) fprintf(ficlog, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,z1)]); |
| fprintf(ficlog, "**********\n#"); | fprintf(ficlog, "**********\n#"); |
| } | } |
| for(i=1; i<=nlstate;i++) | fprintf(ficresphtm,"<table style=\"text-align:center; border: 1px solid\"><th></th>"); |
| for(i=1; i<=nlstate;i++) { | |
| fprintf(ficresp, " Age Prev(%d) N(%d) N",i,i); | fprintf(ficresp, " Age Prev(%d) N(%d) N",i,i); |
| fprintf(ficresphtm, "<th>Age</th><th>Prev(%d)</th><th>N(%d)</th><th>N</th>",i,i); | |
| } | |
| fprintf(ficresp, "\n"); | fprintf(ficresp, "\n"); |
| fprintf(ficresphtm, "\n"); | |
| for(i=iagemin; i <= iagemax+3; i++){ | for(i=iagemin; i <= iagemax+3; i++){ |
| fprintf(ficresphtm,"<tr>"); | |
| if(i==iagemax+3){ | if(i==iagemax+3){ |
| fprintf(ficlog,"Total"); | fprintf(ficlog,"Total"); |
| }else{ | }else{ |
| Line 3332 void freqsummary(char fileres[], int ia | Line 3378 void freqsummary(char fileres[], int ia |
| if( i <= iagemax){ | if( i <= iagemax){ |
| if(pos>=1.e-5){ | if(pos>=1.e-5){ |
| fprintf(ficresp," %d %.5f %.0f %.0f",i,prop[jk][i]/posprop, prop[jk][i],posprop); | fprintf(ficresp," %d %.5f %.0f %.0f",i,prop[jk][i]/posprop, prop[jk][i],posprop); |
| fprintf(ficresphtm,"<th>%d</th><td>%.5f</td><td>%.0f</td><td>%.0f</td>",i,prop[jk][i]/posprop, prop[jk][i],posprop); | |
| /*probs[i][jk][j1]= pp[jk]/pos;*/ | /*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]);*/ | /*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 | else{ |
| fprintf(ficresp," %d NaNq %.0f %.0f",i,prop[jk][i],posprop); | fprintf(ficresp," %d NaNq %.0f %.0f",i,prop[jk][i],posprop); |
| fprintf(ficresphtm,"<th>%d</th><td>NaNq</td><td>%.0f</td><td>%.0f</td>",i, prop[jk][i],posprop); | |
| } | |
| } | } |
| } | } |
| Line 3347 void freqsummary(char fileres[], int ia | Line 3396 void freqsummary(char fileres[], int ia |
| printf(" %d%d=%.0f",jk,m,freq[jk][m][i]); | printf(" %d%d=%.0f",jk,m,freq[jk][m][i]); |
| fprintf(ficlog," %d%d=%.0f",jk,m,freq[jk][m][i]); | fprintf(ficlog," %d%d=%.0f",jk,m,freq[jk][m][i]); |
| } | } |
| if(i <= iagemax) | if(i <= iagemax){ |
| fprintf(ficresp,"\n"); | fprintf(ficresp,"\n"); |
| fprintf(ficresphtm,"</tr>\n"); | |
| } | |
| if(first==1) | if(first==1) |
| printf("Others in log...\n"); | printf("Others in log...\n"); |
| fprintf(ficlog,"\n"); | fprintf(ficlog,"\n"); |
| } /* end loop i */ | } /* end loop i */ |
| fprintf(ficresphtm,"</table>\n"); | |
| /*}*/ | /*}*/ |
| } /* end j1 */ | } /* end j1 */ |
| dateintmean=dateintsum/k2cpt; | dateintmean=dateintsum/k2cpt; |
| fclose(ficresp); | fclose(ficresp); |
| fclose(ficresphtm); | |
| free_ma3x(freq,-5,nlstate+ndeath,-5,nlstate+ndeath, iagemin, iagemax+3); | free_ma3x(freq,-5,nlstate+ndeath,-5,nlstate+ndeath, iagemin, iagemax+3); |
| free_vector(pp,1,nlstate); | free_vector(pp,1,nlstate); |
| free_matrix(prop,1,nlstate,iagemin, iagemax+3); | free_matrix(prop,1,nlstate,iagemin, iagemax+3); |
| Line 4815 void printinghtml(char fileresu[], char | Line 4868 void printinghtml(char fileresu[], char |
| int lastpass, int stepm, int weightopt, char model[],\ | int lastpass, int stepm, int weightopt, char model[],\ |
| int imx,int jmin, int jmax, double jmeanint,char rfileres[],\ | int imx,int jmin, int jmax, double jmeanint,char rfileres[],\ |
| int popforecast, int prevfcast, int estepm , \ | int popforecast, int prevfcast, int estepm , \ |
| double jprev1, double mprev1,double anprev1, \ | double jprev1, double mprev1,double anprev1, double dateprev1, \ |
| double jprev2, double mprev2,double anprev2){ | double jprev2, double mprev2,double anprev2, double dateprev2){ |
| int jj1, k1, i1, cpt; | int jj1, k1, i1, cpt; |
| fprintf(fichtm,"<ul><li><a href='#firstorder'>Result files (first order: no variance)</a>\n \ | fprintf(fichtm,"<ul><li><a href='#firstorder'>Result files (first order: no variance)</a>\n \ |
| <li><a href='#secondorder'>Result files (second order (variance)</a>\n \ | <li><a href='#secondorder'>Result files (second order (variance)</a>\n \ |
| </ul>"); | </ul>"); |
| fprintf(fichtm,"<ul><li><h4><a name='firstorder'>Result files (first order: no variance)</a></h4>\n \ | fprintf(fichtm,"<ul><li><h4><a name='firstorder'>Result files (first order: no variance)</a></h4>\n \ |
| - Observed prevalence in each state (during the period defined between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf): <a href=\"%s\">%s</a> <br>\n ", | - Observed prevalence in each state (during the period defined between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf): <a href=\"%s\">%s</a> (html file) ", |
| jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,subdirf2(fileresu,"P_"),subdirf2(fileresu,"P_")); | jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,subdirfext3(optionfilefiname,"PHTM_",".htm"),subdirfext3(optionfilefiname,"PHTM_",".htm")); |
| fprintf(fichtm,", <a href=\"%s\">%s</a> (text file) <br>\n",subdirf2(fileresu,"P_"),subdirf2(fileresu,"P_")); | |
| fprintf(fichtm,"\ | fprintf(fichtm,"\ |
| - Estimated transition probabilities over %d (stepm) months: <a href=\"%s\">%s</a><br>\n ", | - Estimated transition probabilities over %d (stepm) months: <a href=\"%s\">%s</a><br>\n ", |
| stepm,subdirf2(fileresu,"PIJ_"),subdirf2(fileresu,"PIJ_")); | stepm,subdirf2(fileresu,"PIJ_"),subdirf2(fileresu,"PIJ_")); |
| Line 4889 divided by h: <sub>h</sub>P<sub>ij</sub> | Line 4943 divided by h: <sub>h</sub>P<sub>ij</sub> |
| if(prevfcast==1){ | if(prevfcast==1){ |
| /* Projection of prevalence up to period (stable) prevalence in each health state */ | /* Projection of prevalence up to period (stable) prevalence in each health state */ |
| for(cpt=1; cpt<=nlstate;cpt++){ | for(cpt=1; cpt<=nlstate;cpt++){ |
| fprintf(fichtm,"<br>\n- Projection of prevalece up to period (stable) prevalence in state %d. Or probability to be in state %d being in state (1 to %d) at different ages. <a href=\"%s%d_%d.svg\">%s%d_%d.svg</a><br> \ | fprintf(fichtm,"<br>\n- Projection of cross-sectional prevalence (estimated with cases observed from %f to %f) up to period (stable) prevalence in state %d. Or probability to be in state %d being in state (1 to %d) at different ages. <a href=\"%s%d_%d.svg\">%s%d_%d.svg</a><br> \ |
| <img src=\"%s_%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"PROJ_"),cpt,jj1,subdirf2(optionfilefiname,"PROJ_"),cpt,jj1,subdirf2(optionfilefiname,"PROJ_"),cpt,jj1); | <img src=\"%s_%d-%d.svg\">", dateprev1, dateprev2, cpt, cpt, nlstate, subdirf2(optionfilefiname,"PROJ_"),cpt,jj1,subdirf2(optionfilefiname,"PROJ_"),cpt,jj1,subdirf2(optionfilefiname,"PROJ_"),cpt,jj1); |
| } | } |
| } | } |
| Line 7708 Title=%s <br>Datafile=%s Firstpass=%d La | Line 7762 Title=%s <br>Datafile=%s Firstpass=%d La |
| optionfilehtmcov,version,fullversion,title,datafile,firstpass,lastpass,stepm, weightopt, model); | optionfilehtmcov,version,fullversion,title,datafile,firstpass,lastpass,stepm, weightopt, model); |
| } | } |
| fprintf(fichtm,"<html><head>\n<head>\n<meta charset=\"utf-8\"/><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<title>IMaCh %s</title></head>\n <body><font size=\"7\"><a href=http:/euroreves.ined.fr/imach>IMaCh for Interpolated Markov Chain</a> </font><br>\n<font size=\"3\">Sponsored by Copyright (C) 2002-2015 <a href=http://www.ined.fr>INED</a>-EUROREVES-Institut de longévité-Japan Society for the Promotion of Sciences 日本学術振興会 (<a href=https://www.jsps.go.jp/english/e-grants/>Grant-in-Aid for Scientific Research 25293121</a>) - <a href=https://software.intel.com/en-us>Intel Software 2015</a></font><br> \ | fprintf(fichtm,"<html><head>\n<head>\n<meta charset=\"utf-8\"/><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<title>IMaCh %s</title></head>\n <body><font size=\"7\"><a href=http:/euroreves.ined.fr/imach>IMaCh for Interpolated Markov Chain</a> </font><br>\n<font size=\"3\">Sponsored by Copyright (C) 2002-2015 <a href=http://www.ined.fr>INED</a>-EUROREVES-Institut de longévité-2013-2016-Japan Society for the Promotion of Sciences 日本学術振興会 (<a href=https://www.jsps.go.jp/english/e-grants/>Grant-in-Aid for Scientific Research 25293121</a>) - <a href=https://software.intel.com/en-us>Intel Software 2015-2018</a></font><br> \ |
| <hr size=\"2\" color=\"#EC5E5E\"> \n\ | <hr size=\"2\" color=\"#EC5E5E\"> \n\ |
| <font size=\"2\">IMaCh-%s <br> %s</font> \ | <font size=\"2\">IMaCh-%s <br> %s</font> \ |
| <hr size=\"2\" color=\"#EC5E5E\"> \n\ | <hr size=\"2\" color=\"#EC5E5E\"> \n\ |
| Line 8269 Please run with mle=-1 to get a correct | Line 8323 Please run with mle=-1 to get a correct |
| printinghtml(fileresu,title,datafile, firstpass, lastpass, stepm, weightopt,\ | printinghtml(fileresu,title,datafile, firstpass, lastpass, stepm, weightopt,\ |
| model,imx,jmin,jmax,jmean,rfileres,popforecast,prevfcast,estepm, \ | model,imx,jmin,jmax,jmean,rfileres,popforecast,prevfcast,estepm, \ |
| jprev1,mprev1,anprev1,jprev2,mprev2,anprev2); | jprev1,mprev1,anprev1,dateprev1,jprev2,mprev2,anprev2,dateprev2); |
| /*------------ free_vector -------------*/ | /*------------ free_vector -------------*/ |
| /* chdir(path); */ | /* chdir(path); */ |