]> henry.ined.fr Git - .git/commitdiff
Summary: If 3 live state, convergence to period prevalence on same graph
authorN. Brouard <brouard@ined.fr>
Fri, 20 Jun 2014 16:45:46 +0000 (16:45 +0000)
committerN. Brouard <brouard@ined.fr>
Fri, 20 Jun 2014 16:45:46 +0000 (16:45 +0000)
Author: Brouard

src/imach.c

index 79a21b8e9d20c125ee05e3f3e4dd52e311defdb3..98bbc36dc87560861fb8168ab2e7f69a928d55db 100644 (file)
@@ -1,6 +1,9 @@
 /* $Id$
   $State$
   $Log$
+  Revision 1.152  2014/06/18 17:54:09  brouard
+  Summary: open browser, use gnuplot on same dir than imach if not found in the path
+
   Revision 1.151  2014/06/18 16:43:30  brouard
   *** empty log message ***
 
@@ -3987,6 +3990,7 @@ void printinggnuplot(char fileres[], char optionfilefiname[], double ageminpar,
   strcpy(dirfileres,optionfilefiname);
   strcpy(optfileres,"vpl");
  /* 1eme*/
+  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);
@@ -4014,7 +4018,7 @@ plot [%.f:%.f] \"%s\" every :::%d::%d u 1:2 \"\%%lf",ageminpar,fage,subdirf2(fil
    }
   }
   /*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);
@@ -4071,28 +4075,29 @@ plot [%.f:%.f] \"%s\" every :::%d::%d u 1:%d t \"e%d1\" w l",ageminpar,fage,subd
   }
   
   /* CV preval stable (period) */
-  for (k1=1; k1<= m ; k1 ++) { 
-    for (cpt=1; cpt<=nlstate ; cpt ++) {
+  for (k1=1; k1<= m ; k1 ++) { /* For each multivariate if any */
+    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);
+      l=(nlstate+ndeath)*(cpt-1)+1;
       fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\
 set ter png small size 320, 240\n\
 unset log y\n\
-plot [%.f:%.f] \"%s\" u ($1==%d ? ($3):1/0):($%d/($%d",ageminpar,agemaxpar,subdirf2(fileres,"pij"),k1,k+cpt+1,k+1);
-      
-      for (i=1; i< nlstate ; i ++)
-       fprintf(ficgp,"+$%d",k+i+1);
-      fprintf(ficgp,")) t\"prev(%d,%d)\" w l",cpt,cpt+1);
-      
-      l=3+(nlstate+ndeath)*cpt;
-      fprintf(ficgp,",\"%s\" u ($1==%d ? ($3):1/0):($%d/($%d",subdirf2(fileres,"pij"),k1,l+cpt+1,l+1);
-      for (i=1; i< nlstate ; i ++) {
-       l=3+(nlstate+ndeath)*cpt;
-       fprintf(ficgp,"+$%d",l+i+1);
-      }
-      fprintf(ficgp,")) t\"prev(%d,%d)\" w l\n",cpt+1,cpt+1);   
-    } 
-  }  
+plot [%.f:%.f]  ", ageminpar, agemaxpar);
+      for (i=1; i<= nlstate ; i ++){
+       if(i==1)
+         fprintf(ficgp,"\"%s\"",subdirf2(fileres,"pij"));
+       else
+         fprintf(ficgp,", '' ");
+       fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l,k+l);
+       for (j=1; j<= (nlstate-1) ; j ++)
+         fprintf(ficgp,"+$%d",k+l+j);
+       fprintf(ficgp,")) t \"prev(%d,%d)\" w l",i,cpt);
+      } /* nlstate */
+      fprintf(ficgp,"\n");
+    } /* end cpt state*/ 
+  } /* end covariate */  
   
   /* proba elementaires */
   for(i=1,jk=1; i <=nlstate; i++){
@@ -6670,11 +6675,11 @@ Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf<br>\n",\
   printf("Starting graphs with: %s\n",plotcmd);fflush(stdout);
 
   if((outcmd=system(plotcmd)) != 0){
-    printf("\n Problem with gnuplot command %s\n", plotcmd);
+    printf("\n Problem with gnuplot command %s, err=%d\n", plotcmd, outcmd);
     printf("\n Trying on same directory\n");
     sprintf(plotcmd,"%sgnuplot %s", pathimach, optionfilegnuplot);
     if((outcmd=system(plotcmd)) != 0)
-      printf("\n Still a problem with gnuplot command %s\n", plotcmd);
+      printf("\n Still a problem with gnuplot command %s, err=%d\n", plotcmd, outcmd);
   }
   printf(" Wait...");
   while (z[0] != 'q') {
@@ -6685,11 +6690,11 @@ Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf<br>\n",\
     if (z[0] == 'e') {
 #ifdef OSX
       sprintf(pplotcmd, "open %s", optionfilehtm);
-#elsedef
+#else
       sprintf(pplotcmd, "%s", optionfilehtm);
-#enddef
-      printf("Starting browser with: %s",plotcmd);fflush(stdout);
-      system(plotcmd);
+#endif
+      printf("Starting browser with: %s",pplotcmd);fflush(stdout);
+      system(pplotcmd);
     }
     else if (z[0] == 'g') system(plotcmd);
     else if (z[0] == 'q') exit(0);