|
|
| version 1.274, 2017/06/29 09:47:08 | version 1.278, 2017/07/19 14:09:02 |
|---|---|
| Line 1 | Line 1 |
| /* $Id$ | /* $Id$ |
| $State$ | $State$ |
| $Log$ | $Log$ |
| Revision 1.278 2017/07/19 14:09:02 brouard | |
| Summary: Bug for mobil_average=0 and prevforecast fixed(?) | |
| Revision 1.277 2017/07/17 08:53:49 brouard | |
| Summary: BOM files can be read now | |
| Revision 1.276 2017/06/30 15:48:31 brouard | |
| Summary: Graphs improvements | |
| Revision 1.275 2017/06/30 13:39:33 brouard | |
| Summary: Saito's color | |
| Revision 1.274 2017/06/29 09:47:08 brouard | Revision 1.274 2017/06/29 09:47:08 brouard |
| Summary: Version 0.99r14 | Summary: Version 0.99r14 |
| Line 7049 void printinggnuplot(char fileresu[], ch | Line 7061 void printinggnuplot(char fileresu[], ch |
| fprintf(ficgp,"\nset out \"%s_%d-%d-%d.svg\" \n",subdirf2(optionfilefiname,"V_"),cpt,k1,nres); | fprintf(ficgp,"\nset out \"%s_%d-%d-%d.svg\" \n",subdirf2(optionfilefiname,"V_"),cpt,k1,nres); |
| fprintf(ficgp,"\n#set out \"V_%s_%d-%d-%d.svg\" \n",optionfilefiname,cpt,k1,nres); | fprintf(ficgp,"\n#set out \"V_%s_%d-%d-%d.svg\" \n",optionfilefiname,cpt,k1,nres); |
| fprintf(ficgp,"set label \"Alive state %d %s\" at graph 0.98,0.5 center rotate font \"Helvetica,12\"\n",cpt,gplotlabel); | /* fprintf(ficgp,"set label \"Alive state %d %s\" at graph 0.98,0.5 center rotate font \"Helvetica,12\"\n",cpt,gplotlabel); */ |
| fprintf(ficgp,"set title \"Alive state %d %s\" font \"Helvetica,12\"\n",cpt,gplotlabel); | |
| fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),nres-1,nres-1,nres); | fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),nres-1,nres-1,nres); |
| /* fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),k1-1,k1-1,nres); */ | /* fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),k1-1,k1-1,nres); */ |
| /* k1-1 error should be nres-1*/ | /* k1-1 error should be nres-1*/ |
| Line 7134 void printinggnuplot(char fileresu[], ch | Line 7147 void printinggnuplot(char fileresu[], ch |
| if (i==cpt) fprintf(ficgp," %%lf (%%lf)"); | if (i==cpt) fprintf(ficgp," %%lf (%%lf)"); |
| else fprintf(ficgp," %%*lf (%%*lf)"); | else fprintf(ficgp," %%*lf (%%*lf)"); |
| } | } |
| fprintf(ficgp,"\" t\"95%% CI\" w l lt 5,\"%s\" every :::%d::%d u 1:($2==%d ? $3-1.96*$4 : 1/0) \"%%lf %%lf",subdirf2(fileresu,"VBL_"),nres-1,nres-1,nres); | fprintf(ficgp,"\" t\"95%% CI\" w l lt 4,\"%s\" every :::%d::%d u 1:($2==%d ? $3-1.96*$4 : 1/0) \"%%lf %%lf",subdirf2(fileresu,"VBL_"),nres-1,nres-1,nres); |
| for (i=1; i<= nlstate ; i ++) { | for (i=1; i<= nlstate ; i ++) { |
| if (i==cpt) fprintf(ficgp," %%lf (%%lf)"); | if (i==cpt) fprintf(ficgp," %%lf (%%lf)"); |
| else fprintf(ficgp," %%*lf (%%*lf)"); | else fprintf(ficgp," %%*lf (%%*lf)"); |
| Line 7142 void printinggnuplot(char fileresu[], ch | Line 7155 void printinggnuplot(char fileresu[], ch |
| fprintf(ficgp,"\" t\"\" w l lt 4"); | fprintf(ficgp,"\" t\"\" w l lt 4"); |
| } /* end if backprojcast */ | } /* end if backprojcast */ |
| } /* end if backcast */ | } /* end if backcast */ |
| fprintf(ficgp,"\nset out ;unset label;\n"); | /* fprintf(ficgp,"\nset out ;unset label;\n"); */ |
| fprintf(ficgp,"\nset out ;unset title;\n"); | |
| } /* nres */ | } /* nres */ |
| } /* k1 */ | } /* k1 */ |
| } /* cpt */ | } /* cpt */ |
| Line 7756 set ter svg size 640, 480\nunset log y\n | Line 7770 set ter svg size 640, 480\nunset log y\n |
| continue; | continue; |
| fprintf(ficgp,"\n\n# Combination of dummy k1=%d which is ",k1); | fprintf(ficgp,"\n\n# Combination of dummy k1=%d which is ",k1); |
| strcpy(gplotlabel,"("); | strcpy(gplotlabel,"("); |
| sprintf(gplotlabel+strlen(gplotlabel)," Dummy combination %d ",k1); | /*sprintf(gplotlabel+strlen(gplotlabel)," Dummy combination %d ",k1);*/ |
| for (k=1; k<=cptcoveff; k++){ /* For each correspondig covariate value */ | for (k=1; k<=cptcoveff; k++){ /* For each correspondig covariate value */ |
| lv= decodtabm(k1,k,cptcoveff); /* Should be the covariate value corresponding to k1 combination and kth covariate */ | lv= decodtabm(k1,k,cptcoveff); /* Should be the covariate value corresponding to k1 combination and kth covariate */ |
| /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */ | /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */ |
| Line 7773 set ter svg size 640, 480\nunset log y\n | Line 7787 set ter svg size 640, 480\nunset log y\n |
| strcpy(gplotlabel+strlen(gplotlabel),")"); | strcpy(gplotlabel+strlen(gplotlabel),")"); |
| fprintf(ficgp,"\n#\n"); | fprintf(ficgp,"\n#\n"); |
| fprintf(ficgp,"\nset out \"%s_%d-%d-%d.svg\" ",subdirf2(optionfilefiname,"PE_"),k1,ng,nres); | fprintf(ficgp,"\nset out \"%s_%d-%d-%d.svg\" ",subdirf2(optionfilefiname,"PE_"),k1,ng,nres); |
| fprintf(ficgp,"\nset label \"%s\" at graph 0.98,0.5 center rotate font \"Helvetica,12\"\n",gplotlabel); | fprintf(ficgp,"\nset key outside "); |
| /* fprintf(ficgp,"\nset label \"%s\" at graph 1.2,0.5 center rotate font \"Helvetica,12\"\n",gplotlabel); */ | |
| fprintf(ficgp,"\nset title \"%s\" font \"Helvetica,12\"\n",gplotlabel); | |
| fprintf(ficgp,"\nset ter svg size 640, 480 "); | fprintf(ficgp,"\nset ter svg size 640, 480 "); |
| if (ng==1){ | if (ng==1){ |
| fprintf(ficgp,"\nset ylabel \"Value of the logit of the model\"\n"); /* exp(a12+b12*x) could be nice */ | fprintf(ficgp,"\nset ylabel \"Value of the logit of the model\"\n"); /* exp(a12+b12*x) could be nice */ |
| Line 7893 set ter svg size 640, 480\nunset log y\n | Line 7909 set ter svg size 640, 480\nunset log y\n |
| } | } |
| fprintf(ficgp,")"); | fprintf(ficgp,")"); |
| if(ng ==2) | if(ng ==2) |
| fprintf(ficgp," t \"p%d%d\" ", k2,k); | fprintf(ficgp," w l lw 2 lt (%d*%d+%d)%%%d+1 dt %d t \"p%d%d\" ", nlstate+ndeath, k2, k, nlstate+ndeath, k2, k2,k); |
| else /* ng= 3 */ | else /* ng= 3 */ |
| fprintf(ficgp," t \"i%d%d\" ", k2,k); | fprintf(ficgp," w l lw 2 lt (%d*%d+%d)%%%d+1 dt %d t \"i%d%d\" ", nlstate+ndeath, k2, k, nlstate+ndeath, k2, k2,k); |
| }else{ /* end ng <> 1 */ | }else{ /* end ng <> 1 */ |
| if( k !=k2) /* logit p11 is hard to draw */ | if( k !=k2) /* logit p11 is hard to draw */ |
| fprintf(ficgp," t \"logit(p%d%d)\" ", k2,k); | fprintf(ficgp," w l lw 2 lt (%d*%d+%d)%%%d+1 dt %d t \"logit(p%d%d)\" ", nlstate+ndeath, k2, k, nlstate+ndeath, k2, k2,k); |
| } | } |
| if ((k+k2)!= (nlstate*2+ndeath) && ng != 1) | if ((k+k2)!= (nlstate*2+ndeath) && ng != 1) |
| fprintf(ficgp,","); | fprintf(ficgp,","); |
| Line 7907 set ter svg size 640, 480\nunset log y\n | Line 7923 set ter svg size 640, 480\nunset log y\n |
| i=i+ncovmodel; | i=i+ncovmodel; |
| } /* end k */ | } /* end k */ |
| } /* end k2 */ | } /* end k2 */ |
| fprintf(ficgp,"\n set out; unset label;\n"); | /* fprintf(ficgp,"\n set out; unset label;set key default;\n"); */ |
| fprintf(ficgp,"\n set out; unset title;set key default;\n"); | |
| } /* end k1 */ | } /* end k1 */ |
| } /* end ng */ | } /* end ng */ |
| /* avoid: */ | /* avoid: */ |
| Line 7931 set ter svg size 640, 480\nunset log y\n | Line 7948 set ter svg size 640, 480\nunset log y\n |
| double *agemingoodr, *agemaxgoodr; | double *agemingoodr, *agemaxgoodr; |
| /* modcovmax=2*cptcoveff;/\* Max number of modalities. We suppose */ | /* modcovmax=2*cptcoveff; Max number of modalities. We suppose */ |
| /* a covariate has 2 modalities, should be equal to ncovcombmax *\/ */ | /* a covariate has 2 modalities, should be equal to ncovcombmax */ |
| sumnewp = vector(1,ncovcombmax); | sumnewp = vector(1,ncovcombmax); |
| sumnewm = vector(1,ncovcombmax); | sumnewm = vector(1,ncovcombmax); |
| Line 8256 set ter svg size 640, 480\nunset log y\n | Line 8273 set ter svg size 640, 480\nunset log y\n |
| for(j=1; j<=nlstate+ndeath;j++) { | for(j=1; j<=nlstate+ndeath;j++) { |
| ppij=0.; | ppij=0.; |
| for(i=1; i<=nlstate;i++) { | for(i=1; i<=nlstate;i++) { |
| /* if (mobilav>=1) */ | if (mobilav>=1) |
| ppij=ppij+p3mat[i][j][h]*prev[(int)agec][i][k]; | ppij=ppij+p3mat[i][j][h]*prev[(int)agec][i][k]; |
| /* else { */ /* even if mobilav==-1 we use mobaverage */ | else { /* even if mobilav==-1 we use mobaverage, probs may not sums to 1 */ |
| /* ppij=ppij+p3mat[i][j][h]*probs[(int)(agec)][i][k]; */ | ppij=ppij+p3mat[i][j][h]*probs[(int)(agec)][i][k]; |
| /* } */ | } |
| fprintf(ficresf," %.3f", p3mat[i][j][h]); | fprintf(ficresf," %.3f", p3mat[i][j][h]); |
| } /* end i */ | } /* end i */ |
| fprintf(ficresf," %.3f", ppij); | fprintf(ficresf," %.3f", ppij); |
| Line 10602 int main(int argc, char *argv[]) | Line 10619 int main(int argc, char *argv[]) |
| int vpopbased=0; | int vpopbased=0; |
| int nres=0; | int nres=0; |
| int endishere=0; | int endishere=0; |
| int noffset=0; | |
| int ncurrv=0; /* Temporary variable */ | int ncurrv=0; /* Temporary variable */ |
| char ca[32], cb[32]; | char ca[32], cb[32]; |
| Line 10828 int main(int argc, char *argv[]) | Line 10845 int main(int argc, char *argv[]) |
| fflush(ficlog); | fflush(ficlog); |
| goto end; | goto end; |
| } | } |
| /*-------- Rewriting parameter file ----------*/ | |
| strcpy(rfileres,"r"); /* "Rparameterfile */ | |
| strcat(rfileres,optionfilefiname); /* Parameter file first name */ | |
| strcat(rfileres,"."); /* */ | |
| strcat(rfileres,optionfilext); /* Other files have txt extension */ | |
| if((ficres =fopen(rfileres,"w"))==NULL) { | |
| printf("Problem writing new parameter file: %s\n", rfileres);goto end; | |
| fprintf(ficlog,"Problem writing new parameter file: %s\n", rfileres);goto end; | |
| fflush(ficlog); | |
| goto end; | |
| } | |
| fprintf(ficres,"#IMaCh %s\n",version); | |
| /* Reads comments: lines beginning with '#' */ | /* Reads comments: lines beginning with '#' */ |
| numlinepar=0; | numlinepar=0; |
| /* Is it a BOM UTF-8 Windows file? */ | |
| /* First parameter line */ | /* First parameter line */ |
| while(fgets(line, MAXLINE, ficpar)) { | while(fgets(line, MAXLINE, ficpar)) { |
| noffset=0; | |
| if( line[0] == (char)0xEF && line[1] == (char)0xBB) /* EF BB BF */ | |
| { | |
| noffset=noffset+3; | |
| printf("# File is an UTF8 Bom.\n"); // 0xBF | |
| } | |
| else if( line[0] == (char)0xFE && line[1] == (char)0xFF) | |
| { | |
| noffset=noffset+2; | |
| printf("# File is an UTF16BE BOM file\n"); | |
| } | |
| else if( line[0] == 0 && line[1] == 0) | |
| { | |
| if( line[2] == (char)0xFE && line[3] == (char)0xFF){ | |
| noffset=noffset+4; | |
| printf("# File is an UTF16BE BOM file\n"); | |
| } | |
| } else{ | |
| ;/*printf(" Not a BOM file\n");*/ | |
| } | |
| /* If line starts with a # it is a comment */ | /* If line starts with a # it is a comment */ |
| if (line[0] == '#') { | if (line[noffset] == '#') { |
| numlinepar++; | numlinepar++; |
| fputs(line,stdout); | fputs(line,stdout); |
| fputs(line,ficparo); | fputs(line,ficparo); |
| fputs(line,ficres); | |
| fputs(line,ficlog); | fputs(line,ficlog); |
| continue; | continue; |
| }else | }else |
| Line 10859 int main(int argc, char *argv[]) | Line 10911 int main(int argc, char *argv[]) |
| numlinepar++; | numlinepar++; |
| fputs(line,stdout); | fputs(line,stdout); |
| fputs(line,ficparo); | fputs(line,ficparo); |
| fputs(line,ficres); | |
| fputs(line,ficlog); | fputs(line,ficlog); |
| continue; | continue; |
| }else | }else |
| Line 10881 int main(int argc, char *argv[]) | Line 10934 int main(int argc, char *argv[]) |
| numlinepar++; | numlinepar++; |
| fputs(line,stdout); | fputs(line,stdout); |
| fputs(line,ficparo); | fputs(line,ficparo); |
| fputs(line,ficres); | |
| fputs(line,ficlog); | fputs(line,ficlog); |
| continue; | continue; |
| }else | }else |
| Line 11142 Please run with mle=-1 to get a correct | Line 11196 Please run with mle=-1 to get a correct |
| fflush(ficlog); | fflush(ficlog); |
| /*-------- Rewriting parameter file ----------*/ | |
| strcpy(rfileres,"r"); /* "Rparameterfile */ | |
| strcat(rfileres,optionfilefiname); /* Parameter file first name*/ | |
| strcat(rfileres,"."); /* */ | |
| strcat(rfileres,optionfilext); /* Other files have txt extension */ | |
| if((ficres =fopen(rfileres,"w"))==NULL) { | |
| printf("Problem writing new parameter file: %s\n", rfileres);goto end; | |
| fprintf(ficlog,"Problem writing new parameter file: %s\n", rfileres);goto end; | |
| } | |
| fprintf(ficres,"#%s\n",version); | |
| } /* End of mle != -3 */ | } /* End of mle != -3 */ |
| /* Main data | /* Main data |