--- imach/src/imach.c 2015/09/03 07:14:39 1.198
+++ imach/src/imach.c 2015/09/07 14:09:23 1.199
@@ -1,6 +1,9 @@
-/* $Id: imach.c,v 1.198 2015/09/03 07:14:39 brouard Exp $
+/* $Id: imach.c,v 1.199 2015/09/07 14:09:23 brouard Exp $
$State: Exp $
$Log: imach.c,v $
+ Revision 1.199 2015/09/07 14:09:23 brouard
+ Summary: 0.98q6 changing default small png format for graph to vectorized svg.
+
Revision 1.198 2015/09/03 07:14:39 brouard
Summary: 0.98q5 Flavia
@@ -717,12 +720,12 @@ typedef struct {
#define ODIRSEPARATOR '\\'
#endif
-/* $Id: imach.c,v 1.198 2015/09/03 07:14:39 brouard Exp $ */
+/* $Id: imach.c,v 1.199 2015/09/07 14:09:23 brouard Exp $ */
/* $State: Exp $ */
#include "version.h"
char version[]=__IMACH_VERSION__;
char copyright[]="September 2015,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015";
-char fullversion[]="$Revision: 1.198 $ $Date: 2015/09/03 07:14:39 $";
+char fullversion[]="$Revision: 1.199 $ $Date: 2015/09/07 14:09:23 $";
char strstart[80];
char optionfilext[10], optionfilefiname[FILENAMELENGTH];
int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */
@@ -4051,7 +4054,8 @@ void varevsij(char optionfilefiname[], d
free_vector(gmp,nlstate+1,nlstate+ndeath);
free_matrix(gradgp,1,npar,nlstate+1,nlstate+ndeath);
free_matrix(trgradgp,nlstate+1,nlstate+ndeath,1,npar); /* mu or p point j*/
- fprintf(ficgp,"\nunset parametric;unset label; set ter png small size 320, 240");
+ /* fprintf(ficgp,"\nunset parametric;unset label; set ter png small size 320, 240"); */
+ fprintf(ficgp,"\nunset parametric;unset label; set ter svg size 640, 480");
/* for(j=nlstate+1; j<= nlstate+ndeath; j++){ *//* Only the first actually */
fprintf(ficgp,"\n set log y; unset log x;set xlabel \"Age\"; set ylabel \"Force of mortality (year-1)\";");
/* fprintf(ficgp,"\n plot \"%s\" u 1:($3*%6.3f) not w l 1 ",fileresprobmorprev,YEARM/estepm); */
@@ -4061,11 +4065,11 @@ void varevsij(char optionfilefiname[], d
fprintf(ficgp,"\n replot \"%s\" u 1:(($3+1.96*$4)) t \"95%% interval\" w l lt 2 ",subdirf(fileresprobmorprev));
fprintf(ficgp,"\n replot \"%s\" u 1:(($3-1.96*$4)) not w l lt 2 ",subdirf(fileresprobmorprev));
fprintf(fichtm,"\n
File (multiple files are possible if covariates are present): %s\n",subdirf(fileresprobmorprev),subdirf(fileresprobmorprev));
- fprintf(fichtm,"\n
Probability is computed over estepm=%d months.
\n", estepm,subdirf3(optionfilefiname,"varmuptjgr",digitp),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(fichtm,"\n
Probability is computed over estepm=%d months.
\n", estepm,subdirf3(optionfilefiname,"varmuptjgr",digitp),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%s.png\";replot;",digitp,optionfilefiname,digit); */
- fprintf(ficgp,"\nset out \"%s%s.png\";replot;\n",subdirf3(optionfilefiname,"varmuptjgr",digitp),digit);
+/* fprintf(ficgp,"\nset out \"varmuptjgr%s%s%s.svg\";replot;",digitp,optionfilefiname,digit); */
+ fprintf(ficgp,"\nset out \"%s%s.svg\";replot;\n",subdirf3(optionfilefiname,"varmuptjgr",digitp),digit);
free_vector(xp,1,npar);
free_matrix(doldm,1,nlstate,1,nlstate);
@@ -4450,15 +4454,15 @@ To be simple, these graphs help to under
first=0;
fprintf(ficgp,"\nset parametric;unset label");
fprintf(ficgp,"\nset log y;set log x; set xlabel \"p%1d%1d (year-1)\";set ylabel \"p%1d%1d (year-1)\"",k1,l1,k2,l2);
- fprintf(ficgp,"\nset ter png small size 320, 240");
+ fprintf(ficgp,"\nset ter svg size 640, 480");
fprintf(fichtmcov,"\n
Ellipsoids of confidence cov(p%1d%1d,p%1d%1d) expressed in year-1\
- :\
-%s%d%1d%1d-%1d%1d.png, ",k1,l1,k2,l2,\
+ :\
+%s%d%1d%1d-%1d%1d.svg, ",k1,l1,k2,l2,\
subdirf2(optionfilefiname,"varpijgr"), j1,k1,l1,k2,l2,\
subdirf2(optionfilefiname,"varpijgr"), j1,k1,l1,k2,l2);
- fprintf(fichtmcov,"\n
",subdirf2(optionfilefiname,"varpijgr"), j1,k1,l1,k2,l2);
+ fprintf(fichtmcov,"\n
",subdirf2(optionfilefiname,"varpijgr"), j1,k1,l1,k2,l2);
fprintf(fichtmcov,"\n
Correlation at age %d (%.3f),",(int) age, c12);
- fprintf(ficgp,"\nset out \"%s%d%1d%1d-%1d%1d.png\"",subdirf2(optionfilefiname,"varpijgr"), j1,k1,l1,k2,l2);
+ fprintf(ficgp,"\nset out \"%s%d%1d%1d-%1d%1d.svg\"",subdirf2(optionfilefiname,"varpijgr"), j1,k1,l1,k2,l2);
fprintf(ficgp,"\nset label \"%d\" at %11.3e,%11.3e center",(int) age, mu1,mu2);
fprintf(ficgp,"\n# Age %d, p%1d%1d - p%1d%1d",(int) age, k1,l1,k2,l2);
fprintf(ficgp,"\nplot [-pi:pi] %11.3e+ %.3f*(%11.3e*%11.3e*cos(t)+%11.3e*%11.3e*sin(t)), %11.3e +%.3f*(%11.3e*%11.3e*cos(t)+%11.3e*%11.3e*sin(t)) not",\
@@ -4475,7 +4479,7 @@ To be simple, these graphs help to under
}/* if first */
} /* age mod 5 */
} /* end loop age */
- fprintf(ficgp,"\nset out \"%s%d%1d%1d-%1d%1d.png\";replot;",subdirf2(optionfilefiname,"varpijgr"), j1,k1,l1,k2,l2);
+ fprintf(ficgp,"\nset out \"%s%d%1d%1d-%1d%1d.svg\";replot;",subdirf2(optionfilefiname,"varpijgr"), j1,k1,l1,k2,l2);
first=1;
} /*l12 */
} /* k12 */
@@ -4543,20 +4547,20 @@ 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: %s%d_1.png
\
-",stepm,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1);
+ fprintf(fichtm,"
- Pij or Conditional probabilities to be observed in state j being in state i, %d (stepm) months before: %s%d_1.svg
\
+",stepm,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),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: %s%d_2.png
\
-",stepm,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1);
+ before but expressed in per year i.e. quasi incidences if stepm is small and probabilities too: %s%d_2.svg
\
+",stepm,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1);
/* Period (stable) prevalence in each health state */
for(cpt=1; cpt<=nlstate;cpt++){
- fprintf(fichtm,"
- Convergence to period (stable) prevalence in state %d. Or probability to be in state %d being in state (1 to %d) at different ages. %s%d_%d.png
\
-", cpt, cpt, nlstate, subdirf2(optionfilefiname,"p"),cpt,jj1,subdirf2(optionfilefiname,"p"),cpt,jj1,subdirf2(optionfilefiname,"p"),cpt,jj1);
+ fprintf(fichtm,"
- Convergence to period (stable) prevalence in state %d. Or probability to be in state %d being in state (1 to %d) at different ages. %s%d_%d.svg
\
+", cpt, cpt, nlstate, subdirf2(optionfilefiname,"p"),cpt,jj1,subdirf2(optionfilefiname,"p"),cpt,jj1,subdirf2(optionfilefiname,"p"),cpt,jj1);
}
for(cpt=1; cpt<=nlstate;cpt++) {
- fprintf(fichtm,"\n
- Life expectancy by health state (%d) at initial age and its decomposition into health expectancies in each alive state (1 to %d) : %s%d%d.png
\
-",cpt,nlstate,subdirf2(optionfilefiname,"exp"),cpt,jj1,subdirf2(optionfilefiname,"exp"),cpt,jj1,subdirf2(optionfilefiname,"exp"),cpt,jj1);
+ fprintf(fichtm,"\n
- Life expectancy by health state (%d) at initial age and its decomposition into health expectancies in each alive state (1 to %d) : %s%d%d.svg
\
+",cpt,nlstate,subdirf2(optionfilefiname,"exp"),cpt,jj1,subdirf2(optionfilefiname,"exp"),cpt,jj1,subdirf2(optionfilefiname,"exp"),cpt,jj1);
}
/* } /\* end i1 *\/ */
}/* End k1 */
@@ -4625,15 +4629,15 @@ See page 'Matrix of variance-covariance
}
for(cpt=1; cpt<=nlstate;cpt++) {
fprintf(fichtm,"
- Observed (cross-sectional) and period (incidence based) \
-prevalence (with 95%% confidence interval) in state (%d): %s%d_%d.png
\
-",cpt,subdirf2(optionfilefiname,"v"),cpt,jj1,subdirf2(optionfilefiname,"v"),cpt,jj1);
+prevalence (with 95%% confidence interval) in state (%d): %s%d_%d.svg
\
+",cpt,subdirf2(optionfilefiname,"v"),cpt,jj1,subdirf2(optionfilefiname,"v"),cpt,jj1);
}
fprintf(fichtm,"\n
- Total life expectancy by age and \
health expectancies in states (1) and (2). If popbased=1 the smooth (due to the model) \
true period expectancies (those weighted with period prevalences are also\
drawn in addition to the population based expectancies computed using\
- observed and cahotic prevalences: %s%d.png
\
-",subdirf2(optionfilefiname,"e"),jj1,subdirf2(optionfilefiname,"e"),jj1);
+ observed and cahotic prevalences: %s%d.svg
\
+",subdirf2(optionfilefiname,"e"),jj1,subdirf2(optionfilefiname,"e"),jj1);
/* } /\* end i1 *\/ */
}/* End k1 */
fprintf(fichtm,"
");
@@ -4662,11 +4666,11 @@ void printinggnuplot(char fileres[], cha
fprintf(ficgp,"\n# 1st: Period (stable) prevalence with CI: 'vpl' files\n");
for (cpt=1; cpt<= nlstate ; cpt ++) {
for (k1=1; k1<= m ; k1 ++) { /* plot [100000000000000000000:-100000000000000000000] "mysbiaspar/vplrmysbiaspar.txt to check */
- fprintf(ficgp,"\nset out \"%s%d_%d.png\" \n",subdirf2(optionfilefiname,"v"),cpt,k1);
- fprintf(ficgp,"\n#set out \"v%s%d_%d.png\" \n",optionfilefiname,cpt,k1);
+ fprintf(ficgp,"\nset out \"%s%d_%d.svg\" \n",subdirf2(optionfilefiname,"v"),cpt,k1);
+ fprintf(ficgp,"\n#set out \"v%s%d_%d.svg\" \n",optionfilefiname,cpt,k1);
fprintf(ficgp,"set xlabel \"Age\" \n\
set ylabel \"Probability\" \n\
-set ter png small size 320, 240\n\
+set ter svg size 640, 480\n\
plot [%.f:%.f] \"%s\" every :::%d::%d u 1:2 \"%%lf",ageminpar,fage,subdirf2(fileres,"vpl"),k1-1,k1-1);
for (i=1; i<= nlstate ; i ++) {
@@ -4689,8 +4693,8 @@ plot [%.f:%.f] \"%s\" every :::%d::%d u
/*2 eme*/
fprintf(ficgp,"\n# 2nd: Total life expectancy with CI: 't' files\n");
for (k1=1; k1<= m ; k1 ++) {
- fprintf(ficgp,"\nset out \"%s%d.png\" \n",subdirf2(optionfilefiname,"e"),k1);
- fprintf(ficgp,"set ylabel \"Years\" \nset ter png small size 320, 240\nplot [%.f:%.f] ",ageminpar,fage);
+ fprintf(ficgp,"\nset out \"%s%d.svg\" \n",subdirf2(optionfilefiname,"e"),k1);
+ fprintf(ficgp,"set ylabel \"Years\" \nset ter svg size 640, 480\nplot [%.f:%.f] ",ageminpar,fage);
for (i=1; i<= nlstate+1 ; i ++) {
k=2*i;
@@ -4723,8 +4727,8 @@ plot [%.f:%.f] \"%s\" every :::%d::%d u
for (cpt=1; cpt<= nlstate ; cpt ++) {
/* k=2+nlstate*(2*cpt-2); */
k=2+(nlstate+1)*(cpt-1);
- fprintf(ficgp,"\nset out \"%s%d%d.png\" \n",subdirf2(optionfilefiname,"exp"),cpt,k1);
- fprintf(ficgp,"set ter png small size 320, 240\n\
+ fprintf(ficgp,"\nset out \"%s%d%d.svg\" \n",subdirf2(optionfilefiname,"exp"),cpt,k1);
+ fprintf(ficgp,"set ter svg size 640, 480\n\
plot [%.f:%.f] \"%s\" every :::%d::%d u 1:%d t \"e%d1\" w l",ageminpar,fage,subdirf2(fileres,"e"),k1-1,k1-1,k,cpt);
/*fprintf(ficgp,",\"e%s\" every :::%d::%d u 1:($%d-2*$%d) \"\%%lf ",fileres,k1-1,k1-1,k,k+1);
for (i=1; i<= nlstate*2 ; i ++) fprintf(ficgp,"\%%lf (\%%lf) ");
@@ -4748,9 +4752,9 @@ plot [%.f:%.f] \"%s\" every :::%d::%d u
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */
k=3;
fprintf(ficgp,"\n#\n#\n#CV preval stable (period): 'pij' files, cov=%d state=%d",k1, cpt);
- fprintf(ficgp,"\nset out \"%s%d_%d.png\" \n",subdirf2(optionfilefiname,"p"),cpt,k1);
+ fprintf(ficgp,"\nset out \"%s%d_%d.svg\" \n",subdirf2(optionfilefiname,"p"),cpt,k1);
fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\
-set ter png small size 320, 240\n\
+set ter svg size 640, 480\n\
unset log y\n\
plot [%.f:%.f] ", ageminpar, agemaxpar);
for (i=1; i<= nlstate ; i ++){
@@ -4805,12 +4809,12 @@ plot [%.f:%.f] ", ageminpar, agemaxpar)
fprintf(ficgp,"# jk=1 to 2^%d=%d\n",cptcoveff,m);
for(jk=1; jk <=m; jk++) {
fprintf(ficgp,"# jk=%d\n",jk);
- fprintf(ficgp,"\nset out \"%s%d_%d.png\" \n",subdirf2(optionfilefiname,"pe"),jk,ng);
+ fprintf(ficgp,"\nset out \"%s%d_%d.svg\" \n",subdirf2(optionfilefiname,"pe"),jk,ng);
if (ng==2)
fprintf(ficgp,"\nset ylabel \"Quasi-incidence per year\"\n");
else
fprintf(ficgp,"\nset title \"Probability\"\n");
- fprintf(ficgp,"\nset ter png small size 320, 240\nset log y\nplot [%.f:%.f] ",ageminpar,agemaxpar);
+ fprintf(ficgp,"\nset ter svg size 640, 480\nset log y\nplot [%.f:%.f] ",ageminpar,agemaxpar);
i=1;
for(k2=1; k2<=nlstate; k2++) {
k3=i;
@@ -5419,7 +5423,7 @@ void printinghtmlmort(char fileres[], ch
fprintf(fichtm," mu(age) =%lf*exp(%lf*(age-%d)) per year
",p[1],p[2],agegomp);
for (i=1;i<=2;i++)
fprintf(fichtm," p[%d] = %lf [%f ; %f]
\n",i,p[i],p[i]-2*sqrt(matcov[i][i]),p[i]+2*sqrt(matcov[i][i]));
- fprintf(fichtm,"
");
+ fprintf(fichtm,"
");
fprintf(fichtm,"");
fprintf(fichtm,"Life table
\n
");
@@ -5448,9 +5452,9 @@ void printinggnuplotmort(char fileres[],
strcpy(dirfileres,optionfilefiname);
strcpy(optfileres,"vpl");
- fprintf(ficgp,"set out \"graphmort.png\"\n ");
+ fprintf(ficgp,"set out \"graphmort.svg\"\n ");
fprintf(ficgp,"set xlabel \"Age\"\n set ylabel \"Force of mortality (per year)\" \n ");
- fprintf(ficgp, "set ter png small size 320, 240\n set log y\n");
+ fprintf(ficgp, "set ter svg size 640, 480\n set log y\n");
/* fprintf(ficgp, "set size 0.65,0.65\n"); */
fprintf(ficgp,"plot [%d:100] %lf*exp(%lf*(x-%d))",agegomp,p[1],p[2],agegomp);
@@ -6574,7 +6578,7 @@ int main(int argc, char *argv[])
}
strcpy(model,modeltemp);
}
- printf(" model=1+age%s modeltemp= %s, model=%s\n",model, modeltemp, model);fflush(stdout);
+ /* printf(" model=1+age%s modeltemp= %s, model=%s\n",model, modeltemp, model);fflush(stdout); */
}
/* fscanf(ficpar,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%lf stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d model=1+age+%s\n",title, datafile, &lastobs, &firstpass,&lastpass,&ftol, &stepm, &ncovcol, &nlstate,&ndeath, &maxwav, &mle, &weightopt,model); */
/* numlinepar=numlinepar+3; /\* In general *\/ */
@@ -7738,7 +7742,7 @@ Please run with mle=-1 to get a correct
for(vpopbased=0; vpopbased <= popbased; vpopbased++){ /* Done for vpopbased=0 and vpopbased=1 if popbased==1*/
- oldm=oldms;savm=savms; /* Segmentation fault */
+ oldm=oldms;savm=savms; /* ZZ Segmentation fault */
cptcod= 0; /* To be deleted */
varevsij(optionfilefiname, vareij, matcov, p, delti, nlstate, stepm, (int) bage, (int) fage, oldm, savm, prlim, ftolpl,k, estepm, cptcov,cptcod,vpopbased,mobilav, strstart); /* cptcod not initialized Intel */
fprintf(ficrest,"# Total life expectancy with std error and decomposition into time to be expected in each health state\n# (weighted average of eij where weights are ");
@@ -7749,10 +7753,10 @@ Please run with mle=-1 to get a correct
fprintf(ficrest,"# Age e.. (std) ");
for (i=1;i<=nlstate;i++) fprintf(ficrest,"e.%d (std) ",i);
fprintf(ficrest,"\n");
-
+ /* printf("Which p?\n"); for(i=1;i<=npar;i++)printf("p[i=%d]=%lf,",i,p[i]);printf("\n"); */
epj=vector(1,nlstate+1);
for(age=bage; age <=fage ;age++){
- prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k);
+ prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k); /*ZZ Is it the correct prevalim */
if (vpopbased==1) {
if(mobilav ==0){
for(i=1; i<=nlstate;i++)
@@ -7764,13 +7768,16 @@ Please run with mle=-1 to get a correct
}
fprintf(ficrest," %4.0f",age);
+ /* printf(" age %4.0f ",age); */
for(j=1, epj[nlstate+1]=0.;j <=nlstate;j++){
for(i=1, epj[j]=0.;i <=nlstate;i++) {
epj[j] += prlim[i][i]*eij[i][j][(int)age];
- /* printf("%lf %lf ", prlim[i][i] ,eij[i][j][(int)age]);*/
+ /*ZZZ printf("%lf %lf ", prlim[i][i] ,eij[i][j][(int)age]);*/
+ /* printf("%lf %lf ", prlim[i][i] ,eij[i][j][(int)age]); */
}
epj[nlstate+1] +=epj[j];
}
+ /* printf(" age %4.0f \n",age); */
for(i=1, vepp=0.;i <=nlstate;i++)
for(j=1;j <=nlstate;j++)