--- imach/src/imach.c 2017/06/27 11:06:02 1.273 +++ imach/src/imach.c 2017/06/29 09:47:08 1.274 @@ -1,6 +1,9 @@ -/* $Id: imach.c,v 1.273 2017/06/27 11:06:02 brouard Exp $ +/* $Id: imach.c,v 1.274 2017/06/29 09:47:08 brouard Exp $ $State: Exp $ $Log: imach.c,v $ + Revision 1.274 2017/06/29 09:47:08 brouard + Summary: Version 0.99r14 + Revision 1.273 2017/06/27 11:06:02 brouard Summary: More documentation on projections @@ -1022,12 +1025,12 @@ typedef struct { #define ODIRSEPARATOR '\\' #endif -/* $Id: imach.c,v 1.273 2017/06/27 11:06:02 brouard Exp $ */ +/* $Id: imach.c,v 1.274 2017/06/29 09:47:08 brouard Exp $ */ /* $State: Exp $ */ #include "version.h" char version[]=__IMACH_VERSION__; char copyright[]="February 2016,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015-2018"; -char fullversion[]="$Revision: 1.273 $ $Date: 2017/06/27 11:06:02 $"; +char fullversion[]="$Revision: 1.274 $ $Date: 2017/06/29 09:47:08 $"; char strstart[80]; char optionfilext[10], optionfilefiname[FILENAMELENGTH]; int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ @@ -3854,7 +3857,7 @@ void likelione(FILE *ficres,double p[], else if(mle >=1) fprintf(fichtm,"\n
File of contributions to the likelihood computed with optimized parameters mle = %d.",mle); fprintf(fichtm," You should at least run with mle >= 1 to get starting values corresponding to the optimized parameters in order to visualize the real contribution of each individual/wave: %s
\n",subdirf(fileresilk),subdirf(fileresilk)); - + fprintf(fichtm,"\n
Equation of the model: model=1+age+%s
\n",model); for (k=1; k<= nlstate ; k++) { fprintf(fichtm,"
- Probability p%dj by origin %d and destination j. Dot's sizes are related to corresponding weight: %s-p%dj.png
\ @@ -6963,6 +6966,20 @@ void printinggnuplot(char fileresu[], ch /*#endif */ m=pow(2,cptcoveff); + /* diagram of the model */ + fprintf(ficgp,"\n#Diagram of the model \n"); + fprintf(ficgp,"\ndelta=0.03;delta2=0.07;unset arrow;\n"); + fprintf(ficgp,"yoff=(%d > 2? 0:1);\n",nlstate); + fprintf(ficgp,"\n#Peripheral arrows\nset for [i=1:%d] for [j=1:%d] arrow i*10+j from cos(pi*((1-(%d/2)*2./%d)/2+(i-1)*2./%d))-(i!=j?(i-j)/abs(i-j)*delta:0), yoff +sin(pi*((1-(%d/2)*2./%d)/2+(i-1)*2./%d)) + (i!=j?(i-j)/abs(i-j)*delta:0) rto -0.95*(cos(pi*((1-(%d/2)*2./%d)/2+(i-1)*2./%d))+(i!=j?(i-j)/abs(i-j)*delta:0) - cos(pi*((1-(%d/2)*2./%d)/2+(j-1)*2./%d)) + (i!=j?(i-j)/abs(i-j)*delta2:0)), -0.95*(sin(pi*((1-(%d/2)*2./%d)/2+(i-1)*2./%d)) + (i!=j?(i-j)/abs(i-j)*delta:0) - sin(pi*((1-(%d/2)*2./%d)/2+(j-1)*2./%d))+( i!=j?(i-j)/abs(i-j)*delta2:0)) ls (i < j? 1:2)\n",nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate); + + fprintf(ficgp,"\n#Centripete arrows (turning in other direction (1-i) instead of (i-1)) \nset for [i=1:%d] arrow (%d+1)*10+i from cos(pi*((1-(%d/2)*2./%d)/2+(1-i)*2./%d))-(i!=j?(i-j)/abs(i-j)*delta:0), yoff +sin(pi*((1-(%d/2)*2./%d)/2+(1-i)*2./%d)) + (i!=j?(i-j)/abs(i-j)*delta:0) rto -0.80*(cos(pi*((1-(%d/2)*2./%d)/2+(1-i)*2./%d))+(i!=j?(i-j)/abs(i-j)*delta:0) ), -0.80*(sin(pi*((1-(%d/2)*2./%d)/2+(1-i)*2./%d)) + (i!=j?(i-j)/abs(i-j)*delta:0) + yoff ) ls 4\n",nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate); + fprintf(ficgp,"\n#show arrow\nunset label\n"); + fprintf(ficgp,"\n#States labels, starting from 2 (2-i) instead of (1-i), was (i-1)\nset for [i=1:%d] label i sprintf(\"State %%d\",i) center at cos(pi*((1-(%d/2)*2./%d)/2+(2-i)*2./%d)), yoff+sin(pi*((1-(%d/2)*2./%d)/2+(2-i)*2./%d)) font \"helvetica, 16\" tc rgbcolor \"blue\"\n",nlstate,nlstate,nlstate,nlstate,nlstate,nlstate,nlstate); + fprintf(ficgp,"\nset label %d+1 sprintf(\"State %%d\",%d+1) center at 0.,0. font \"helvetica, 16\" tc rgbcolor \"red\"\n",nlstate,nlstate); + fprintf(ficgp,"\n#show label\nunset border;unset xtics; unset ytics;\n"); + fprintf(ficgp,"\n\nset ter svg size 640, 480;set out \"%s_.svg\" \n",subdirf2(optionfilefiname,"D_")); + fprintf(ficgp,"unset log y; plot [-1.2:1.2][yoff-1.2:1.2] 1/0 not; set out;reset;\n"); + /* Contribution to likelihood */ /* Plot the probability implied in the likelihood */ fprintf(ficgp,"\n# Contributions to the Likelihood, mle >=1. For mle=4 no interpolation, pure matrix products.\n#\n"); @@ -7122,7 +7139,7 @@ void printinggnuplot(char fileresu[], ch if (i==cpt) fprintf(ficgp," %%lf (%%lf)"); else fprintf(ficgp," %%*lf (%%*lf)"); } - fprintf(ficgp,"\" t\"\" w l lt 5"); + fprintf(ficgp,"\" t\"\" w l lt 4"); } /* end if backprojcast */ } /* end if backcast */ fprintf(ficgp,"\nset out ;unset label;\n"); @@ -10586,6 +10603,8 @@ int main(int argc, char *argv[]) int nres=0; int endishere=0; + int ncurrv=0; /* Temporary variable */ + char ca[32], cb[32]; /* FILE *fichtm; *//* Html File */ /* FILE *ficgp;*/ /*Gnuplot File */ @@ -11470,10 +11489,31 @@ Title=%s
Datafile=%s Firstpass=%d La firstpass, lastpass, stepm, weightopt, model); fprintf(fichtm,"\n"); - fprintf(fichtm,"
Total number of observations=%d
\n\ + fprintf(fichtm,"

Parameter line 2

\n", \ + nlstate, ndeath, maxwav, mle, weightopt); + + fprintf(fichtm,"

Diagram of states %s_.svg

\n\ +", subdirf2(optionfilefiname,"D_"),subdirf2(optionfilefiname,"D_"),subdirf2(optionfilefiname,"D_")); + + + fprintf(fichtm,"\n

Some descriptive statistics

\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",\ - imx,agemin,agemax,jmin,jmax,jmean); + imx,agemin,agemax,jmin,jmax,jmean); pmmij= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ oldms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ newms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */