version 1.191, 2015/07/14 10:00:33
|
version 1.202, 2015/09/22 19:45:16
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.202 2015/09/22 19:45:16 brouard |
|
Summary: Adding some overall graph on contribution to likelihood. Might change |
|
|
|
Revision 1.201 2015/09/15 17:34:58 brouard |
|
Summary: 0.98r0 |
|
|
|
- Some new graphs like suvival functions |
|
- Some bugs fixed like model=1+age+V2. |
|
|
|
Revision 1.200 2015/09/09 16:53:55 brouard |
|
Summary: Big bug thanks to Flavia |
|
|
|
Even model=1+age+V2. did not work anymore |
|
|
|
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 |
|
|
|
Revision 1.197 2015/09/01 18:24:39 brouard |
|
*** empty log message *** |
|
|
|
Revision 1.196 2015/08/18 23:17:52 brouard |
|
Summary: 0.98q5 |
|
|
|
Revision 1.195 2015/08/18 16:28:39 brouard |
|
Summary: Adding a hack for testing purpose |
|
|
|
After reading the title, ftol and model lines, if the comment line has |
|
a q, starting with #q, the answer at the end of the run is quit. It |
|
permits to run test files in batch with ctest. The former workaround was |
|
$ echo q | imach foo.imach |
|
|
|
Revision 1.194 2015/08/18 13:32:00 brouard |
|
Summary: Adding error when the covariance matrix doesn't contain the exact number of lines required by the model line. |
|
|
|
Revision 1.193 2015/08/04 07:17:42 brouard |
|
Summary: 0.98q4 |
|
|
|
Revision 1.192 2015/07/16 16:49:02 brouard |
|
Summary: Fixing some outputs |
|
|
Revision 1.191 2015/07/14 10:00:33 brouard |
Revision 1.191 2015/07/14 10:00:33 brouard |
Summary: Some fixes |
Summary: Some fixes |
|
|
Line 604
|
Line 647
|
|
|
/* #define DEBUG */ |
/* #define DEBUG */ |
/* #define DEBUGBRENT */ |
/* #define DEBUGBRENT */ |
|
#define DEBUGLINMIN |
#define POWELL /* Instead of NLOPT */ |
#define POWELL /* Instead of NLOPT */ |
|
#define POWELLF1F3 /* Skip test */ |
/* #define POWELLORIGINAL /\* Don't use Directest to decide new direction but original Powell test *\/ */ |
/* #define POWELLORIGINAL /\* Don't use Directest to decide new direction but original Powell test *\/ */ |
/* #define MNBRAKORIGINAL /\* Don't use mnbrak fix *\/ */ |
/* #define MNBRAKORIGINAL /\* Don't use mnbrak fix *\/ */ |
|
|
Line 673 typedef struct {
|
Line 718 typedef struct {
|
#define NLSTATEMAX 8 /**< Maximum number of live states (for func) */ |
#define NLSTATEMAX 8 /**< Maximum number of live states (for func) */ |
#define NDEATHMAX 8 /**< Maximum number of dead states (for func) */ |
#define NDEATHMAX 8 /**< Maximum number of dead states (for func) */ |
#define NCOVMAX 20 /**< Maximum number of covariates, including generated covariates V1*V2 */ |
#define NCOVMAX 20 /**< Maximum number of covariates, including generated covariates V1*V2 */ |
#define codtabm(h,k) 1 & (h-1) >> (k-1) ; |
#define codtabm(h,k) (1 & (h-1) >> (k-1))+1 |
#define MAXN 20000 |
#define MAXN 20000 |
#define YEARM 12. /**< Number of months per year */ |
#define YEARM 12. /**< Number of months per year */ |
#define AGESUP 130 |
#define AGESUP 130 |
#define AGEBASE 40 |
#define AGEBASE 40 |
|
#define AGEOVERFLOW 1.e20 |
#define AGEGOMP 10 /**< Minimal age for Gompertz adjustment */ |
#define AGEGOMP 10 /**< Minimal age for Gompertz adjustment */ |
#ifdef _WIN32 |
#ifdef _WIN32 |
#define DIRSEPARATOR '\\' |
#define DIRSEPARATOR '\\' |
Line 691 typedef struct {
|
Line 737 typedef struct {
|
|
|
/* $Id$ */ |
/* $Id$ */ |
/* $State$ */ |
/* $State$ */ |
|
#include "version.h" |
char version[]="Imach version 0.98q2, April 2015,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015"; |
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$ $Date$"; |
char fullversion[]="$Revision$ $Date$"; |
char strstart[80]; |
char strstart[80]; |
char optionfilext[10], optionfilefiname[FILENAMELENGTH]; |
char optionfilext[10], optionfilefiname[FILENAMELENGTH]; |
Line 759 char command[FILENAMELENGTH];
|
Line 806 char command[FILENAMELENGTH];
|
int outcmd=0; |
int outcmd=0; |
|
|
char fileres[FILENAMELENGTH], filerespij[FILENAMELENGTH], filereso[FILENAMELENGTH], rfileres[FILENAMELENGTH]; |
char fileres[FILENAMELENGTH], filerespij[FILENAMELENGTH], filereso[FILENAMELENGTH], rfileres[FILENAMELENGTH]; |
|
char fileresu[FILENAMELENGTH]; /* fileres without r in front */ |
char filelog[FILENAMELENGTH]; /* Log file */ |
char filelog[FILENAMELENGTH]; /* Log file */ |
char filerest[FILENAMELENGTH]; |
char filerest[FILENAMELENGTH]; |
char fileregp[FILENAMELENGTH]; |
char fileregp[FILENAMELENGTH]; |
Line 827 int estepm;
|
Line 874 int estepm;
|
|
|
int m,nb; |
int m,nb; |
long *num; |
long *num; |
int firstpass=0, lastpass=4,*cod, *ncodemax, *Tage,*cens; |
int firstpass=0, lastpass=4,*cod, *cens; |
|
int *ncodemax; /* ncodemax[j]= Number of modalities of the j th |
|
covariate for which somebody answered excluding |
|
undefined. Usually 2: 0 and 1. */ |
|
int *ncodemaxwundef; /* ncodemax[j]= Number of modalities of the j th |
|
covariate for which somebody answered including |
|
undefined. Usually 3: -1, 0 and 1. */ |
double **agev,*moisnais, *annais, *moisdc, *andc,**mint, **anint; |
double **agev,*moisnais, *annais, *moisdc, *andc,**mint, **anint; |
double **pmmij, ***probs; |
double **pmmij, ***probs; |
double *ageexmed,*agecens; |
double *ageexmed,*agecens; |
Line 841 double **covar; /**< covar[j,i], value
|
Line 894 double **covar; /**< covar[j,i], value
|
* cov[Tage[kk]+2]=covar[Tvar[Tage[kk]]][i]*age; */ |
* cov[Tage[kk]+2]=covar[Tvar[Tage[kk]]][i]*age; */ |
double idx; |
double idx; |
int **nbcode, *Tvar; /**< model=V2 => Tvar[1]= 2 */ |
int **nbcode, *Tvar; /**< model=V2 => Tvar[1]= 2 */ |
|
int *Tage; |
int *Ndum; /** Freq of modality (tricode */ |
int *Ndum; /** Freq of modality (tricode */ |
int **codtab; /**< codtab=imatrix(1,100,1,10); */ |
/* int **codtab;*/ /**< codtab=imatrix(1,100,1,10); */ |
int **Tvard, *Tprod, cptcovprod, *Tvaraff; |
int **Tvard, *Tprod, cptcovprod, *Tvaraff; |
double *lsurv, *lpop, *tpop; |
double *lsurv, *lpop, *tpop; |
|
|
Line 1556 void linmin(double p[], double xi[], int
|
Line 1610 void linmin(double p[], double xi[], int
|
nrfunc=func; |
nrfunc=func; |
for (j=1;j<=n;j++) { |
for (j=1;j<=n;j++) { |
pcom[j]=p[j]; |
pcom[j]=p[j]; |
xicom[j]=xi[j]; |
xicom[j]=xi[j]; /* Former scale xi[j] of currrent direction i */ |
} |
} |
|
|
axs=0.0; |
/* axs=0.0; */ |
xxss=1; /* 1 and using scale */ |
/* xxss=1; /\* 1 and using scale *\/ */ |
xxs=1; |
xxs=1; |
do{ |
/* do{ */ |
ax=0.; |
ax=0.; |
xx= xxs; |
xx= xxs; |
mnbrak(&ax,&xx,&bx,&fa,&fx,&fb,f1dim); /* Outputs: xtx[j]=pcom[j]+(*xx)*xicom[j]; fx=f(xtx[j]) */ |
mnbrak(&ax,&xx,&bx,&fa,&fx,&fb,f1dim); /* Outputs: xtx[j]=pcom[j]+(*xx)*xicom[j]; fx=f(xtx[j]) */ |
Line 1572 void linmin(double p[], double xi[], int
|
Line 1626 void linmin(double p[], double xi[], int
|
/* Given input ax=axs and xx=xxs, xx might be too far from ax to get a finite f(xx) */ |
/* Given input ax=axs and xx=xxs, xx might be too far from ax to get a finite f(xx) */ |
/* Searches on line, outputs (ax, xx, bx) such that fx < min(fa and fb) */ |
/* Searches on line, outputs (ax, xx, bx) such that fx < min(fa and fb) */ |
/* Find a bracket a,x,b in direction n=xi ie xicom, order may change. Scale is [0:xxs*xi[j]] et non plus [0:xi[j]]*/ |
/* Find a bracket a,x,b in direction n=xi ie xicom, order may change. Scale is [0:xxs*xi[j]] et non plus [0:xi[j]]*/ |
if (fx != fx){ |
/* if (fx != fx){ */ |
xxs=xxs/scale; /* Trying a smaller xx, closer to initial ax=0 */ |
/* xxs=xxs/scale; /\* Trying a smaller xx, closer to initial ax=0 *\/ */ |
printf("\nLinmin NAN : input [axs=%lf:xxs=%lf], mnbrak outputs fx=%lf <(fb=%lf and fa=%lf) with xx=%lf in [ax=%lf:bx=%lf] \n", axs, xxs, fx,fb, fa, xx, ax, bx); |
/* printf("\nLinmin NAN : input [axs=%lf:xxs=%lf], mnbrak outputs fx=%lf <(fb=%lf and fa=%lf) with xx=%lf in [ax=%lf:bx=%lf] \n", axs, xxs, fx,fb, fa, xx, ax, bx); */ |
} |
/* } */ |
}while(fx != fx); |
/* }while(fx != fx); */ |
|
|
#ifdef DEBUGLINMIN |
#ifdef DEBUGLINMIN |
printf("\nLinmin after mnbrak: ax=%12.7f xx=%12.7f bx=%12.7f fa=%12.2f fx=%12.2f fb=%12.2f\n", ax,xx,bx,fa,fx,fb); |
printf("\nLinmin after mnbrak: ax=%12.7f xx=%12.7f bx=%12.7f fa=%12.2f fx=%12.2f fb=%12.2f\n", ax,xx,bx,fa,fx,fb); |
|
fprintf(ficlog,"\nLinmin after mnbrak: ax=%12.7f xx=%12.7f bx=%12.7f fa=%12.2f fx=%12.2f fb=%12.2f\n", ax,xx,bx,fa,fx,fb); |
#endif |
#endif |
*fret=brent(ax,xx,bx,f1dim,TOL,&xmin); /* Giving a bracketting triplet (ax, xx, bx), find a minimum, xmin, according to f1dim, *fret(xmin),*/ |
*fret=brent(ax,xx,bx,f1dim,TOL,&xmin); /* Giving a bracketting triplet (ax, xx, bx), find a minimum, xmin, according to f1dim, *fret(xmin),*/ |
/* fa = f(p[j] + ax * xi[j]), fx = f(p[j] + xx * xi[j]), fb = f(p[j] + bx * xi[j]) */ |
/* fa = f(p[j] + ax * xi[j]), fx = f(p[j] + xx * xi[j]), fb = f(p[j] + bx * xi[j]) */ |
Line 1592 void linmin(double p[], double xi[], int
|
Line 1647 void linmin(double p[], double xi[], int
|
#endif |
#endif |
#ifdef DEBUGLINMIN |
#ifdef DEBUGLINMIN |
printf("linmin end "); |
printf("linmin end "); |
|
fprintf(ficlog,"linmin end "); |
#endif |
#endif |
for (j=1;j<=n;j++) { |
for (j=1;j<=n;j++) { |
/* printf(" before xi[%d]=%12.8f", j,xi[j]); */ |
/* printf(" before xi[%d]=%12.8f", j,xi[j]); */ |
Line 1603 void linmin(double p[], double xi[], int
|
Line 1659 void linmin(double p[], double xi[], int
|
/* printf("\n"); */ |
/* printf("\n"); */ |
#ifdef DEBUGLINMIN |
#ifdef DEBUGLINMIN |
printf("Comparing last *frec(xmin=%12.8f)=%12.8f from Brent and frec(0.)=%12.8f \n", xmin, *fret, (*func)(p)); |
printf("Comparing last *frec(xmin=%12.8f)=%12.8f from Brent and frec(0.)=%12.8f \n", xmin, *fret, (*func)(p)); |
|
fprintf(ficlog,"Comparing last *frec(xmin=%12.8f)=%12.8f from Brent and frec(0.)=%12.8f \n", xmin, *fret, (*func)(p)); |
for (j=1;j<=n;j++) { |
for (j=1;j<=n;j++) { |
printf(" xi[%d]= %12.7f p[%d]= %12.7f",j,xi[j],j,p[j]); |
printf(" xi[%d]= %14.10f p[%d]= %12.7f",j,xi[j],j,p[j]); |
if(j % ncovmodel == 0) |
fprintf(ficlog," xi[%d]= %14.10f p[%d]= %12.7f",j,xi[j],j,p[j]); |
|
if(j % ncovmodel == 0){ |
printf("\n"); |
printf("\n"); |
|
fprintf(ficlog,"\n"); |
|
} |
} |
} |
#endif |
#endif |
free_vector(xicom,1,n); |
free_vector(xicom,1,n); |
Line 1641 void powell(double p[], double **xi, int
|
Line 1701 void powell(double p[], double **xi, int
|
xits=vector(1,n); |
xits=vector(1,n); |
*fret=(*func)(p); |
*fret=(*func)(p); |
for (j=1;j<=n;j++) pt[j]=p[j]; |
for (j=1;j<=n;j++) pt[j]=p[j]; |
rcurr_time = time(NULL); |
rcurr_time = time(NULL); |
for (*iter=1;;++(*iter)) { |
for (*iter=1;;++(*iter)) { |
fp=(*fret); /* From former iteration or initial value */ |
fp=(*fret); /* From former iteration or initial value */ |
ibig=0; |
ibig=0; |
Line 1653 void powell(double p[], double **xi, int
|
Line 1713 void powell(double p[], double **xi, int
|
printf("\nPowell iter=%d -2*LL=%.12f %ld sec. %ld sec.",*iter,*fret, rcurr_time-rlast_time, rcurr_time-rstart_time);fflush(stdout); |
printf("\nPowell iter=%d -2*LL=%.12f %ld sec. %ld sec.",*iter,*fret, rcurr_time-rlast_time, rcurr_time-rstart_time);fflush(stdout); |
fprintf(ficlog,"\nPowell iter=%d -2*LL=%.12f %ld sec. %ld sec.",*iter,*fret,rcurr_time-rlast_time, rcurr_time-rstart_time); fflush(ficlog); |
fprintf(ficlog,"\nPowell iter=%d -2*LL=%.12f %ld sec. %ld sec.",*iter,*fret,rcurr_time-rlast_time, rcurr_time-rstart_time); fflush(ficlog); |
/* fprintf(ficrespow,"%d %.12f %ld",*iter,*fret,curr_time.tm_sec-start_time.tm_sec); */ |
/* fprintf(ficrespow,"%d %.12f %ld",*iter,*fret,curr_time.tm_sec-start_time.tm_sec); */ |
for (i=1;i<=n;i++) { |
for (i=1;i<=n;i++) { |
printf(" %d %.12f",i, p[i]); |
printf(" %d %.12f",i, p[i]); |
fprintf(ficlog," %d %.12lf",i, p[i]); |
fprintf(ficlog," %d %.12lf",i, p[i]); |
fprintf(ficrespow," %.12lf", p[i]); |
fprintf(ficrespow," %.12lf", p[i]); |
Line 1761 void powell(double p[], double **xi, int
|
Line 1821 void powell(double p[], double **xi, int
|
free_vector(ptt,1,n); |
free_vector(ptt,1,n); |
free_vector(pt,1,n); |
free_vector(pt,1,n); |
return; |
return; |
} |
} /* enough precision */ |
if (*iter == ITMAX) nrerror("powell exceeding maximum iterations."); |
if (*iter == ITMAX) nrerror("powell exceeding maximum iterations."); |
for (j=1;j<=n;j++) { /* Computes the extrapolated point P_0 + 2 (P_n-P_0) */ |
for (j=1;j<=n;j++) { /* Computes the extrapolated point P_0 + 2 (P_n-P_0) */ |
ptt[j]=2.0*p[j]-pt[j]; |
ptt[j]=2.0*p[j]-pt[j]; |
Line 1769 void powell(double p[], double **xi, int
|
Line 1829 void powell(double p[], double **xi, int
|
pt[j]=p[j]; |
pt[j]=p[j]; |
} |
} |
fptt=(*func)(ptt); /* f_3 */ |
fptt=(*func)(ptt); /* f_3 */ |
|
#ifdef POWELLF1F3 |
|
#else |
if (fptt < fp) { /* If extrapolated point is better, decide if we keep that new direction or not */ |
if (fptt < fp) { /* If extrapolated point is better, decide if we keep that new direction or not */ |
|
#endif |
/* (x1 f1=fp), (x2 f2=*fret), (x3 f3=fptt), (xm fm) */ |
/* (x1 f1=fp), (x2 f2=*fret), (x3 f3=fptt), (xm fm) */ |
/* From x1 (P0) distance of x2 is at h and x3 is 2h */ |
/* From x1 (P0) distance of x2 is at h and x3 is 2h */ |
/* Let f"(x2) be the 2nd derivative equal everywhere. */ |
/* Let f"(x2) be the 2nd derivative equal everywhere. */ |
Line 1783 void powell(double p[], double **xi, int
|
Line 1846 void powell(double p[], double **xi, int
|
t=2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del); /* Intel compiler doesn't work on one line; bug reported */ |
t=2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del); /* Intel compiler doesn't work on one line; bug reported */ |
t= t- del*SQR(fp-fptt); |
t= t- del*SQR(fp-fptt); |
#endif |
#endif |
directest = fp-2.0*(*fret)+fptt - 2.0 * del; /* If del was big enough we change it for a new direction */ |
directest = fp-2.0*(*fret)+fptt - 2.0 * del; /* If delta was big enough we change it for a new direction */ |
#ifdef DEBUG |
#ifdef DEBUG |
printf("t1= %.12lf, t2= %.12lf, t=%.12lf directest=%.12lf\n", 2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del),del*SQR(fp-fptt),t,directest); |
printf("t1= %.12lf, t2= %.12lf, t=%.12lf directest=%.12lf\n", 2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del),del*SQR(fp-fptt),t,directest); |
fprintf(ficlog,"t1= %.12lf, t2= %.12lf, t=%.12lf directest=%.12lf\n", 2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del),del*SQR(fp-fptt),t,directest); |
fprintf(ficlog,"t1= %.12lf, t2= %.12lf, t=%.12lf directest=%.12lf\n", 2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del),del*SQR(fp-fptt),t,directest); |
Line 1798 void powell(double p[], double **xi, int
|
Line 1861 void powell(double p[], double **xi, int
|
if (t < 0.0) { /* Then we use it for new direction */ |
if (t < 0.0) { /* Then we use it for new direction */ |
#else |
#else |
if (directest*t < 0.0) { /* Contradiction between both tests */ |
if (directest*t < 0.0) { /* Contradiction between both tests */ |
printf("directest= %.12lf, t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt,del); |
printf("directest= %.12lf (if <0 we include P0 Pn as new direction), t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt,del); |
printf("f1-2f2+f3= %.12lf, f1-f2-del= %.12lf, f1-f3= %.12lf\n",fp-2.0*(*fret)+fptt, fp -(*fret) -del, fp-fptt); |
printf("f1-2f2+f3= %.12lf, f1-f2-del= %.12lf, f1-f3= %.12lf\n",fp-2.0*(*fret)+fptt, fp -(*fret) -del, fp-fptt); |
fprintf(ficlog,"directest= %.12lf, t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt, del); |
fprintf(ficlog,"directest= %.12lf (if <0 we include P0 Pn as new direction), t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt, del); |
fprintf(ficlog,"f1-2f2+f3= %.12lf, f1-f2-del= %.12lf, f1-f3= %.12lf\n",fp-2.0*(*fret)+fptt, fp -(*fret) -del, fp-fptt); |
fprintf(ficlog,"f1-2f2+f3= %.12lf, f1-f2-del= %.12lf, f1-f3= %.12lf\n",fp-2.0*(*fret)+fptt, fp -(*fret) -del, fp-fptt); |
} |
} |
if (directest < 0.0) { /* Then we use it for new direction */ |
if (directest < 0.0) { /* Then we use it for new direction */ |
#endif |
#endif |
#ifdef DEBUGLINMIN |
#ifdef DEBUGLINMIN |
printf("Before linmin in direction P%d-P0\n",n); |
printf("Before linmin in direction P%d-P0\n",n); |
for (j=1;j<=n;j++) { |
for (j=1;j<=n;j++) { |
printf("Before xit[%d]= %12.7f p[%d]= %12.7f",j,xit[j],j,p[j]); |
printf(" Before xit[%d]= %12.7f p[%d]= %12.7f",j,xit[j],j,p[j]); |
if(j % ncovmodel == 0) |
fprintf(ficlog," Before xit[%d]= %12.7f p[%d]= %12.7f",j,xit[j],j,p[j]); |
|
if(j % ncovmodel == 0){ |
printf("\n"); |
printf("\n"); |
|
fprintf(ficlog,"\n"); |
|
} |
} |
} |
#endif |
#endif |
linmin(p,xit,n,fret,func); /* computes minimum on the extrapolated direction: changes p and rescales xit.*/ |
linmin(p,xit,n,fret,func); /* computes minimum on the extrapolated direction: changes p and rescales xit.*/ |
#ifdef DEBUGLINMIN |
#ifdef DEBUGLINMIN |
for (j=1;j<=n;j++) { |
for (j=1;j<=n;j++) { |
printf("After xit[%d]= %12.7f p[%d]= %12.7f",j,xit[j],j,p[j]); |
printf("After xit[%d]= %12.7f p[%d]= %12.7f",j,xit[j],j,p[j]); |
if(j % ncovmodel == 0) |
fprintf(ficlog,"After xit[%d]= %12.7f p[%d]= %12.7f",j,xit[j],j,p[j]); |
|
if(j % ncovmodel == 0){ |
printf("\n"); |
printf("\n"); |
|
fprintf(ficlog,"\n"); |
|
} |
} |
} |
#endif |
#endif |
for (j=1;j<=n;j++) { |
for (j=1;j<=n;j++) { |
Line 1838 void powell(double p[], double **xi, int
|
Line 1907 void powell(double p[], double **xi, int
|
printf("\n"); |
printf("\n"); |
fprintf(ficlog,"\n"); |
fprintf(ficlog,"\n"); |
#endif |
#endif |
} /* end of t negative */ |
} /* end of t or directest negative */ |
|
#ifdef POWELLF1F3 |
|
#else |
} /* end if (fptt < fp) */ |
} /* end if (fptt < fp) */ |
} |
#endif |
|
} /* loop iteration */ |
} |
} |
|
|
/**** Prevalence limit (stable or period prevalence) ****************/ |
/**** Prevalence limit (stable or period prevalence) ****************/ |
Line 1855 double **prevalim(double **prlim, int nl
|
Line 1927 double **prevalim(double **prlim, int nl
|
/* double **matprod2(); */ /* test */ |
/* double **matprod2(); */ /* test */ |
double **out, cov[NCOVMAX+1], **pmij(); |
double **out, cov[NCOVMAX+1], **pmij(); |
double **newm; |
double **newm; |
double agefin, delaymax=50 ; /* Max number of years to converge */ |
double agefin, delaymax=100 ; /* Max number of years to converge */ |
|
long int ncvyear=0, ncvloop=0; |
|
|
for (ii=1;ii<=nlstate+ndeath;ii++) |
for (ii=1;ii<=nlstate+ndeath;ii++) |
for (j=1;j<=nlstate+ndeath;j++){ |
for (j=1;j<=nlstate+ndeath;j++){ |
Line 1865 double **prevalim(double **prlim, int nl
|
Line 1938 double **prevalim(double **prlim, int nl
|
cov[1]=1.; |
cov[1]=1.; |
|
|
/* Even if hstepm = 1, at least one multiplication by the unit matrix */ |
/* Even if hstepm = 1, at least one multiplication by the unit matrix */ |
|
/* Start at agefin= age, computes the matrix of passage and loops decreasing agefin until convergence is reached */ |
for(agefin=age-stepm/YEARM; agefin>=age-delaymax; agefin=agefin-stepm/YEARM){ |
for(agefin=age-stepm/YEARM; agefin>=age-delaymax; agefin=agefin-stepm/YEARM){ |
|
ncvloop++; |
newm=savm; |
newm=savm; |
/* Covariates have to be included here again */ |
/* Covariates have to be included here again */ |
cov[2]=agefin; |
cov[2]=agefin; |
if(nagesqr==1) |
if(nagesqr==1) |
cov[3]= agefin*agefin;; |
cov[3]= agefin*agefin;; |
for (k=1; k<=cptcovn;k++) { |
for (k=1; k<=cptcovn;k++) { |
cov[2+nagesqr+k]=nbcode[Tvar[k]][codtab[ij][Tvar[k]]]; |
/* cov[2+nagesqr+k]=nbcode[Tvar[k]][codtabm(ij,Tvar[k])]; */ |
/*printf("prevalim ij=%d k=%d Tvar[%d]=%d nbcode=%d cov=%lf codtab[%d][Tvar[%d]]=%d \n",ij,k, k, Tvar[k],nbcode[Tvar[k]][codtab[ij][Tvar[k]]],cov[2+k], ij, k, codtab[ij][Tvar[k]]);*/ |
cov[2+nagesqr+k]=nbcode[Tvar[k]][codtabm(ij,k)]; |
|
/* printf("prevalim ij=%d k=%d Tvar[%d]=%d nbcode=%d cov=%lf codtabm(%d,Tvar[%d])=%d \n",ij,k, k, Tvar[k],nbcode[Tvar[k]][codtabm(ij,Tvar[k])],cov[2+k], ij, k, codtabm(ij,Tvar[k])]); */ |
} |
} |
/*wrong? for (k=1; k<=cptcovage;k++) cov[2+Tage[k]]=cov[2+Tage[k]]*cov[2]; */ |
/*wrong? for (k=1; k<=cptcovage;k++) cov[2+Tage[k]]=cov[2+Tage[k]]*cov[2]; */ |
for (k=1; k<=cptcovage;k++) cov[2+nagesqr+Tage[k]]=nbcode[Tvar[k]][codtab[ij][Tvar[k]]]*cov[2]; |
/* for (k=1; k<=cptcovage;k++) cov[2+nagesqr+Tage[k]]=nbcode[Tvar[k]][codtabm(ij,Tvar[k])]*cov[2]; */ |
|
for (k=1; k<=cptcovage;k++) cov[2+nagesqr+Tage[k]]=nbcode[Tvar[k]][codtabm(ij,k)]*cov[2]; |
for (k=1; k<=cptcovprod;k++) /* Useless */ |
for (k=1; k<=cptcovprod;k++) /* Useless */ |
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtab[ij][Tvard[k][1]]] * nbcode[Tvard[k][2]][codtab[ij][Tvard[k][2]]]; |
/* cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,Tvard[k][1])] * nbcode[Tvard[k][2]][codtabm(ij,Tvard[k][2])]; */ |
|
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)] * nbcode[Tvard[k][2]][codtabm(ij,k)]; |
|
|
/*printf("ij=%d cptcovprod=%d tvar=%d ", ij, cptcovprod, Tvar[1]);*/ |
/*printf("ij=%d cptcovprod=%d tvar=%d ", ij, cptcovprod, Tvar[1]);*/ |
/*printf("ij=%d cov[3]=%lf cov[4]=%lf \n",ij, cov[3],cov[4]);*/ |
/*printf("ij=%d cov[3]=%lf cov[4]=%lf \n",ij, cov[3],cov[4]);*/ |
Line 1897 double **prevalim(double **prlim, int nl
|
Line 1975 double **prevalim(double **prlim, int nl
|
sumnew=0; |
sumnew=0; |
for(k=1; k<=ndeath; k++) sumnew+=newm[i][nlstate+k]; |
for(k=1; k<=ndeath; k++) sumnew+=newm[i][nlstate+k]; |
prlim[i][j]= newm[i][j]/(1-sumnew); |
prlim[i][j]= newm[i][j]/(1-sumnew); |
/*printf(" prevalim i=%d, j=%d, prmlim[%d][%d]=%f, agefin=%d \n", i, j, i, j, prlim[i][j],(int)agefin);*/ |
|
max=FMAX(max,prlim[i][j]); |
max=FMAX(max,prlim[i][j]); |
min=FMIN(min,prlim[i][j]); |
min=FMIN(min,prlim[i][j]); |
|
/* printf(" age= %d prevalim i=%d, j=%d, prmlim[%d][%d]=%f, agefin=%d max=%f min=%f\n", (int)age, i, j, i, j, prlim[i][j],(int)agefin, max, min); */ |
} |
} |
maxmin=max-min; |
maxmin=max-min; |
maxmax=FMAX(maxmax,maxmin); |
maxmax=FMAX(maxmax,maxmin); |
} /* j loop */ |
} /* j loop */ |
if(maxmax < ftolpl){ |
if(maxmax < ftolpl){ |
|
/* printf("maxmax=%lf maxmin=%lf ncvloop=%ld, ncvyear=%d \n", maxmax, maxmin, ncvloop, (int)age-(int)agefin); */ |
return prlim; |
return prlim; |
} |
} |
} /* age loop */ |
} /* age loop */ |
|
printf("Warning: the stable prevalence did not converge with the required precision ftolpl=6*10^5*ftol=%g. \n\ |
|
Earliest age to start was %d-%d=%d, ncvloop=%ld, ncvyear=%d\n\ |
|
Try to lower 'ftol', for example from 1.e-8 to 6.e-9.\n", ftolpl, (int)age, (int)delaymax, (int)agefin, ncvloop, (int)age-(int)agefin); |
return prlim; /* should not reach here */ |
return prlim; /* should not reach here */ |
} |
} |
|
|
Line 2051 double ***hpxij(double ***po, int nhstep
|
Line 2133 double ***hpxij(double ***po, int nhstep
|
if(nagesqr==1) |
if(nagesqr==1) |
cov[3]= agexact*agexact; |
cov[3]= agexact*agexact; |
for (k=1; k<=cptcovn;k++) |
for (k=1; k<=cptcovn;k++) |
cov[2+nagesqr+k]=nbcode[Tvar[k]][codtab[ij][Tvar[k]]]; |
cov[2+nagesqr+k]=nbcode[Tvar[k]][codtabm(ij,k)]; |
|
/* cov[2+nagesqr+k]=nbcode[Tvar[k]][codtabm(ij,Tvar[k])]; */ |
for (k=1; k<=cptcovage;k++) /* Should start at cptcovn+1 */ |
for (k=1; k<=cptcovage;k++) /* Should start at cptcovn+1 */ |
/* cov[2+Tage[k]]=cov[2+Tage[k]]*cov[2]; */ |
/* cov[2+Tage[k]]=cov[2+Tage[k]]*cov[2]; */ |
cov[2+nagesqr+Tage[k]]=nbcode[Tvar[Tage[k]]][codtab[ij][Tvar[Tage[k]]]]*cov[2]; |
cov[2+nagesqr+Tage[k]]=nbcode[Tvar[Tage[k]]][codtabm(ij,k)]*cov[2]; |
|
/* cov[2+nagesqr+Tage[k]]=nbcode[Tvar[Tage[k]]][codtabm(ij,Tvar[Tage[k]])]*cov[2]; */ |
for (k=1; k<=cptcovprod;k++) /* Useless because included in cptcovn */ |
for (k=1; k<=cptcovprod;k++) /* Useless because included in cptcovn */ |
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtab[ij][Tvard[k][1]]]*nbcode[Tvard[k][2]][codtab[ij][Tvard[k][2]]]; |
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)]*nbcode[Tvard[k][2]][codtabm(ij,k)]; |
|
/* cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,Tvard[k][1])]*nbcode[Tvard[k][2]][codtabm(ij,Tvard[k][2])]; */ |
|
|
|
|
/*printf("hxi cptcov=%d cptcode=%d\n",cptcov,cptcode);*/ |
/*printf("hxi cptcov=%d cptcode=%d\n",cptcov,cptcode);*/ |
Line 2480 double funcone( double *x)
|
Line 2565 double funcone( double *x)
|
ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; |
ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; |
/*printf("i=%6d s1=%1d s2=%1d mi=%1d mw=%1d dh=%3d prob=%10.6f w=%6.4f out=%10.6f sav=%10.6f\n",i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],out[s1][s2],savm[s1][s2]); */ |
/*printf("i=%6d s1=%1d s2=%1d mi=%1d mw=%1d dh=%3d prob=%10.6f w=%6.4f out=%10.6f sav=%10.6f\n",i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],out[s1][s2],savm[s1][s2]); */ |
if(globpr){ |
if(globpr){ |
fprintf(ficresilk,"%9ld %6d %2d %2d %1d %1d %3d %11.6f %8.4f\ |
fprintf(ficresilk,"%9ld %6.1f %6d %2d %2d %2d %2d %3d %11.6f %8.4f\ |
%11.6f %11.6f %11.6f ", \ |
%11.6f %11.6f %11.6f ", \ |
num[i],i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i], |
num[i], agexact, i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i], |
2*weight[i]*lli,out[s1][s2],savm[s1][s2]); |
2*weight[i]*lli,out[s1][s2],savm[s1][s2]); |
for(k=1,llt=0.,l=0.; k<=nlstate; k++){ |
for(k=1,llt=0.,l=0.; k<=nlstate; k++){ |
llt +=ll[k]*gipmx/gsw; |
llt +=ll[k]*gipmx/gsw; |
Line 2514 void likelione(FILE *ficres,double p[],
|
Line 2599 void likelione(FILE *ficres,double p[],
|
int k; |
int k; |
|
|
if(*globpri !=0){ /* Just counts and sums, no printings */ |
if(*globpri !=0){ /* Just counts and sums, no printings */ |
strcpy(fileresilk,"ilk"); |
strcpy(fileresilk,"ILK_"); |
strcat(fileresilk,fileres); |
strcat(fileresilk,fileresu); |
if((ficresilk=fopen(fileresilk,"w"))==NULL) { |
if((ficresilk=fopen(fileresilk,"w"))==NULL) { |
printf("Problem with resultfile: %s\n", fileresilk); |
printf("Problem with resultfile: %s\n", fileresilk); |
fprintf(ficlog,"Problem with resultfile: %s\n", fileresilk); |
fprintf(ficlog,"Problem with resultfile: %s\n", fileresilk); |
} |
} |
fprintf(ficresilk, "#individual(line's_record) s1 s2 wave# effective_wave# number_of_matrices_product pij weight -2ln(pij)*weight 0pij_x 0pij_(x-stepm) cumulating_loglikeli_by_health_state(reweighted=-2ll*weightXnumber_of_contribs/sum_of_weights) and_total\n"); |
fprintf(ficresilk, "#individual(line's_record) s1 s2 wave# effective_wave# number_of_matrices_product pij weight -2ln(pij)*weight 0pij_x 0pij_(x-stepm) cumulating_loglikeli_by_health_state(reweighted=-2ll*weightXnumber_of_contribs/sum_of_weights) and_total\n"); |
fprintf(ficresilk, "#num_i i s1 s2 mi mw dh likeli weight 2wlli out sav "); |
fprintf(ficresilk, "#num_i age i s1 s2 mi mw dh likeli weight 2wlli out sav "); |
/* i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],2*weight[i]*lli,out[s1][s2],savm[s1][s2]); */ |
/* i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],2*weight[i]*lli,out[s1][s2],savm[s1][s2]); */ |
for(k=1; k<=nlstate; k++) |
for(k=1; k<=nlstate; k++) |
fprintf(ficresilk," -2*gipw/gsw*weight*ll[%d]++",k); |
fprintf(ficresilk," -2*gipw/gsw*weight*ll[%d]++",k); |
Line 2531 void likelione(FILE *ficres,double p[],
|
Line 2616 void likelione(FILE *ficres,double p[],
|
*fretone=(*funcone)(p); |
*fretone=(*funcone)(p); |
if(*globpri !=0){ |
if(*globpri !=0){ |
fclose(ficresilk); |
fclose(ficresilk); |
fprintf(fichtm,"\n<br>File of contributions to the likelihood: <a href=\"%s\">%s</a><br>\n",subdirf(fileresilk),subdirf(fileresilk)); |
fprintf(fichtm,"\n<br>File of contributions to the likelihood computed with initial parameters and mle >= 1. You should at least run with mle >= 1 and starting values corresponding to the optimized parameters in order to visualize the real contribution of each individual/wave: <a href=\"%s\">%s</a><br>\n",subdirf(fileresilk),subdirf(fileresilk)); |
fflush(fichtm); |
fprintf(fichtm,"<br>- The first 3 individuals are drawn with lines. The function drawn is -2Log(L) in log scale: <a href=\"%s.png\">%s.png</a><br> \ |
|
<img src=\"%s.png\">",subdirf2(optionfilefiname,"ILK_"),subdirf2(optionfilefiname,"ILK_"),subdirf2(optionfilefiname,"ILK_")); |
|
fflush(fichtm); |
} |
} |
return; |
return; |
} |
} |
Line 2564 void mlikeli(FILE *ficres,double p[], in
|
Line 2651 void mlikeli(FILE *ficres,double p[], in
|
for (j=1;j<=npar;j++) |
for (j=1;j<=npar;j++) |
xi[i][j]=(i==j ? 1.0 : 0.0); |
xi[i][j]=(i==j ? 1.0 : 0.0); |
printf("Powell\n"); fprintf(ficlog,"Powell\n"); |
printf("Powell\n"); fprintf(ficlog,"Powell\n"); |
strcpy(filerespow,"pow"); |
strcpy(filerespow,"POW_"); |
strcat(filerespow,fileres); |
strcat(filerespow,fileres); |
if((ficrespow=fopen(filerespow,"w"))==NULL) { |
if((ficrespow=fopen(filerespow,"w"))==NULL) { |
printf("Problem with resultfile: %s\n", filerespow); |
printf("Problem with resultfile: %s\n", filerespow); |
Line 2875 void lubksb(double **a, int n, int *indx
|
Line 2962 void lubksb(double **a, int n, int *indx
|
|
|
void pstamp(FILE *fichier) |
void pstamp(FILE *fichier) |
{ |
{ |
fprintf(fichier,"# %s.%s\n#%s\n#%s\n# %s", optionfilefiname,optionfilext,version,fullversion,strstart); |
fprintf(fichier,"# %s.%s\n#IMaCh version %s, %s\n#%s\n# %s", optionfilefiname,optionfilext,version,copyright, fullversion, strstart); |
} |
} |
|
|
/************ Frequencies ********************/ |
/************ Frequencies ********************/ |
Line 2891 void freqsummary(char fileres[], int ia
|
Line 2978 void freqsummary(char fileres[], int ia
|
|
|
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,fileres); |
strcat(fileresp,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); |
Line 2927 void freqsummary(char fileres[], int ia
|
Line 3014 void freqsummary(char fileres[], int ia
|
bool=1; |
bool=1; |
if (cptcovn>0) { /* Filter is here: Must be looked at for model=V1+V2+V3+V4 */ |
if (cptcovn>0) { /* Filter is here: Must be looked at for model=V1+V2+V3+V4 */ |
for (z1=1; z1<=cptcoveff; z1++) |
for (z1=1; z1<=cptcoveff; z1++) |
if (covar[Tvaraff[z1]][i]!= nbcode[Tvaraff[z1]][codtab[j1][z1]]){ |
if (covar[Tvaraff[z1]][i]!= nbcode[Tvaraff[z1]][codtabm(j1,z1)]){ |
/* Tests if the value of each of the covariates of i is equal to filter j1 */ |
/* Tests if the value of each of the covariates of i is equal to filter j1 */ |
bool=0; |
bool=0; |
/* printf("bool=%d i=%d, z1=%d, Tvaraff[%d]=%d, covar[Tvarff][%d]=%2f, codtab[%d][%d]=%d, nbcode[Tvaraff][codtab[%d][%d]=%d, j1=%d\n", |
/* printf("bool=%d i=%d, z1=%d, Tvaraff[%d]=%d, covar[Tvarff][%d]=%2f, codtabm(%d,%d)=%d, nbcode[Tvaraff][codtabm(%d,%d)=%d, j1=%d\n", |
bool,i,z1, z1, Tvaraff[z1],i,covar[Tvaraff[z1]][i],j1,z1,codtab[j1][z1], |
bool,i,z1, z1, Tvaraff[z1],i,covar[Tvaraff[z1]][i],j1,z1,codtabm(j1,z1), |
j1,z1,nbcode[Tvaraff[z1]][codtab[j1][z1]],j1);*/ |
j1,z1,nbcode[Tvaraff[z1]][codtabm(j1,z1)],j1);*/ |
/* For j1=7 in V1+V2+V3+V4 = 0 1 1 0 and codtab[7][3]=1 and nbcde[3][?]=1*/ |
/* For j1=7 in V1+V2+V3+V4 = 0 1 1 0 and codtabm(7,3)=1 and nbcde[3][?]=1*/ |
} |
} |
} |
} |
|
|
Line 2962 void freqsummary(char fileres[], int ia
|
Line 3049 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]][codtab[j1][z1]]); |
for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresp, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,z1)]); |
fprintf(ficresp, "**********\n#"); |
fprintf(ficresp, "**********\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]][codtab[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++) |
for(i=1; i<=nlstate;i++) |
Line 3093 void prevalence(double ***probs, double
|
Line 3180 void prevalence(double ***probs, double
|
bool=1; |
bool=1; |
if (cptcovn>0) { |
if (cptcovn>0) { |
for (z1=1; z1<=cptcoveff; z1++) |
for (z1=1; z1<=cptcoveff; z1++) |
if (covar[Tvaraff[z1]][i]!= nbcode[Tvaraff[z1]][codtab[j1][z1]]) |
if (covar[Tvaraff[z1]][i]!= nbcode[Tvaraff[z1]][codtabm(j1,z1)]) |
bool=0; |
bool=0; |
} |
} |
if (bool==1) { |
if (bool==1) { |
Line 3298 void tricode(int *Tvar, int **nbcode, in
|
Line 3385 void tricode(int *Tvar, int **nbcode, in
|
|
|
cptcoveff=0; |
cptcoveff=0; |
|
|
for (k=-1; k < maxncov; k++) Ndum[k]=0; |
|
for (k=1; k <= maxncov; k++) ncodemax[k]=0; /* Horrible constant again replaced by NCOVMAX */ |
for (k=1; k <= maxncov; k++) ncodemax[k]=0; /* Horrible constant again replaced by NCOVMAX */ |
|
|
/* Loop on covariates without age and products */ |
/* Loop on covariates without age and products */ |
for (j=1; j<=(cptcovs); j++) { /* From model V1 + V2*age+ V3 + V3*V4 keeps V1 + V3 = 2 only */ |
for (j=1; j<=(cptcovs); j++) { /* From model V1 + V2*age+ V3 + V3*V4 keeps V1 + V3 = 2 only */ |
|
for (k=-1; k < maxncov; k++) Ndum[k]=0; |
for (i=1; i<=imx; i++) { /* Loop on individuals: reads the data file to get the maximum value of the |
for (i=1; i<=imx; i++) { /* Loop on individuals: reads the data file to get the maximum value of the |
modality of this covariate Vj*/ |
modality of this covariate Vj*/ |
ij=(int)(covar[Tvar[j]][i]); /* ij=0 or 1 or -1. Value of the covariate Tvar[j] for individual i |
ij=(int)(covar[Tvar[j]][i]); /* ij=0 or 1 or -1. Value of the covariate Tvar[j] for individual i |
Line 3325 void tricode(int *Tvar, int **nbcode, in
|
Line 3412 void tricode(int *Tvar, int **nbcode, in
|
/* getting the maximum value of the modality of the covariate |
/* getting the maximum value of the modality of the covariate |
(should be 0 or 1 now) Tvar[j]. If V=sex and male is coded 0 and |
(should be 0 or 1 now) Tvar[j]. If V=sex and male is coded 0 and |
female is 1, then modmaxcovj=1.*/ |
female is 1, then modmaxcovj=1.*/ |
} /* end for loop on individuals */ |
} /* end for loop on individuals i */ |
printf(" Minimal and maximal values of %d th covariate V%d: min=%d max=%d \n", j, Tvar[j], modmincovj, modmaxcovj); |
printf(" Minimal and maximal values of %d th covariate V%d: min=%d max=%d \n", j, Tvar[j], modmincovj, modmaxcovj); |
|
fprintf(ficlog," Minimal and maximal values of %d th covariate V%d: min=%d max=%d \n", j, Tvar[j], modmincovj, modmaxcovj); |
cptcode=modmaxcovj; |
cptcode=modmaxcovj; |
/* Ndum[0] = frequency of 0 for model-covariate j, Ndum[1] frequency of 1 etc. */ |
/* Ndum[0] = frequency of 0 for model-covariate j, Ndum[1] frequency of 1 etc. */ |
/*for (i=0; i<=cptcode; i++) {*/ |
/*for (i=0; i<=cptcode; i++) {*/ |
for (i=modmincovj; i<=modmaxcovj; i++) { /* i=-1 ? 0 and 1*//* For each value of the modality of model-cov j */ |
for (k=modmincovj; k<=modmaxcovj; k++) { /* k=-1 ? 0 and 1*//* For each value k of the modality of model-cov j */ |
printf("Frequencies of covariates %d ie V%d with value %d: %d\n", j, Tvar[j], i, Ndum[i]); |
printf("Frequencies of covariates %d ie V%d with value %d: %d\n", j, Tvar[j], k, Ndum[k]); |
if( Ndum[i] != 0 ){ /* Counts if nobody answered, empty modality */ |
fprintf(ficlog, "Frequencies of covariates %d ie V%d with value %d: %d\n", j, Tvar[j], k, Ndum[k]); |
ncodemax[j]++; /* ncodemax[j]= Number of non-null modalities of the j th covariate. */ |
if( Ndum[k] != 0 ){ /* Counts if nobody answered modality k ie empty modality, we skip it and reorder */ |
|
if( k != -1){ |
|
ncodemax[j]++; /* ncodemax[j]= Number of modalities of the j th |
|
covariate for which somebody answered excluding |
|
undefined. Usually 2: 0 and 1. */ |
|
} |
|
ncodemaxwundef[j]++; /* ncodemax[j]= Number of modalities of the j th |
|
covariate for which somebody answered including |
|
undefined. Usually 3: -1, 0 and 1. */ |
} |
} |
/* In fact ncodemax[j]=2 (dichotom. variables only) but it could be more for |
/* In fact ncodemax[j]=2 (dichotom. variables only) but it could be more for |
historical reasons: 3 if coded 1, 2, 3 and 4 and Ndum[2]=0 */ |
historical reasons: 3 if coded 1, 2, 3 and 4 and Ndum[2]=0 */ |
Line 3350 void tricode(int *Tvar, int **nbcode, in
|
Line 3446 void tricode(int *Tvar, int **nbcode, in
|
nbcode[Tvar[j]][1]=0; |
nbcode[Tvar[j]][1]=0; |
nbcode[Tvar[j]][2]=1; |
nbcode[Tvar[j]][2]=1; |
nbcode[Tvar[j]][3]=2; |
nbcode[Tvar[j]][3]=2; |
|
To be continued (not working yet). |
*/ |
*/ |
ij=1; /* ij is similar to i but can jumps over null modalities */ |
ij=0; /* ij is similar to i but can jump over null modalities */ |
for (i=modmincovj; i<=modmaxcovj; i++) { /* i= 1 to 2 for dichotomous, or from 1 to 3 */ |
for (i=modmincovj; i<=modmaxcovj; i++) { /* i= 1 to 2 for dichotomous, or from 1 to 3 or from -1 or 0 to 1 currently*/ |
for (k=0; k<= cptcode; k++) { /* k=-1 ? k=0 to 1 *//* Could be 1 to 4 */ |
if (Ndum[i] == 0) { /* If nobody responded to this modality k */ |
/*recode from 0 */ |
break; |
if (Ndum[k] != 0) { /* If at least one individual responded to this modality k */ |
} |
nbcode[Tvar[j]][ij]=k; /* stores the modality k in an array nbcode. |
ij++; |
k is a modality. If we have model=V1+V1*sex |
nbcode[Tvar[j]][ij]=i; /* stores the original value of modality i in an array nbcode, ij modality from 1 to last non-nul modality.*/ |
then: nbcode[1][1]=0 ; nbcode[1][2]=1; nbcode[2][1]=0 ; nbcode[2][2]=1; */ |
cptcode = ij; /* New max modality for covar j */ |
ij++; |
} /* end of loop on modality i=-1 to 1 or more */ |
} |
|
if (ij > ncodemax[j]) break; |
/* for (k=0; k<= cptcode; k++) { /\* k=-1 ? k=0 to 1 *\//\* Could be 1 to 4 *\//\* cptcode=modmaxcovj *\/ */ |
} /* end of loop on */ |
/* /\*recode from 0 *\/ */ |
} /* end of loop on modality */ |
/* k is a modality. If we have model=V1+V1*sex */ |
|
/* then: nbcode[1][1]=0 ; nbcode[1][2]=1; nbcode[2][1]=0 ; nbcode[2][2]=1; */ |
|
/* But if some modality were not used, it is recoded from 0 to a newer modmaxcovj=cptcode *\/ */ |
|
/* } */ |
|
/* /\* cptcode = ij; *\/ /\* New max modality for covar j *\/ */ |
|
/* if (ij > ncodemax[j]) { */ |
|
/* printf( " Error ij=%d > ncodemax[%d]=%d\n", ij, j, ncodemax[j]); */ |
|
/* fprintf(ficlog, " Error ij=%d > ncodemax[%d]=%d\n", ij, j, ncodemax[j]); */ |
|
/* break; */ |
|
/* } */ |
|
/* } /\* end of loop on modality k *\/ */ |
} /* end of loop on model-covariate j. nbcode[Tvarj][1]=0 and nbcode[Tvarj][2]=1 sets the value of covariate j*/ |
} /* end of loop on model-covariate j. nbcode[Tvarj][1]=0 and nbcode[Tvarj][2]=1 sets the value of covariate j*/ |
|
|
for (k=-1; k< maxncov; k++) Ndum[k]=0; |
for (k=-1; k< maxncov; k++) Ndum[k]=0; |
Line 3374 void tricode(int *Tvar, int **nbcode, in
|
Line 3481 void tricode(int *Tvar, int **nbcode, in
|
Ndum[ij]++; /* Might be supersed V1 + V1*age */ |
Ndum[ij]++; /* Might be supersed V1 + V1*age */ |
} |
} |
|
|
ij=1; |
ij=0; |
for (i=0; i<= maxncov-1; i++) { /* modmaxcovj is unknown here. Only Ndum[2(V2),3(age*V3), 5(V3*V2) 6(V1*V4) */ |
for (i=0; i<= maxncov-1; i++) { /* modmaxcovj is unknown here. Only Ndum[2(V2),3(age*V3), 5(V3*V2) 6(V1*V4) */ |
/*printf("Ndum[%d]=%d\n",i, Ndum[i]);*/ |
/*printf("Ndum[%d]=%d\n",i, Ndum[i]);*/ |
if((Ndum[i]!=0) && (i<=ncovcol)){ |
if((Ndum[i]!=0) && (i<=ncovcol)){ |
|
ij++; |
/*printf("diff Ndum[%d]=%d\n",i, Ndum[i]);*/ |
/*printf("diff Ndum[%d]=%d\n",i, Ndum[i]);*/ |
Tvaraff[ij]=i; /*For printing (unclear) */ |
Tvaraff[ij]=i; /*For printing (unclear) */ |
ij++; |
}else{ |
}else |
/* Tvaraff[ij]=0; */ |
Tvaraff[ij]=0; |
} |
} |
} |
ij--; |
/* ij--; */ |
cptcoveff=ij; /*Number of total covariates*/ |
cptcoveff=ij; /*Number of total covariates*/ |
|
|
} |
} |
Line 3739 void varevsij(char optionfilefiname[], d
|
Line 3847 void varevsij(char optionfilefiname[], d
|
|
|
if(popbased==1){ |
if(popbased==1){ |
if(mobilav!=0) |
if(mobilav!=0) |
strcpy(digitp,"-populbased-mobilav-"); |
strcpy(digitp,"-POPULBASED-MOBILAV_"); |
else strcpy(digitp,"-populbased-nomobil-"); |
else strcpy(digitp,"-POPULBASED-NOMOBIL_"); |
} |
} |
else |
else |
strcpy(digitp,"-stablbased-"); |
strcpy(digitp,"-STABLBASED_"); |
|
|
if (mobilav!=0) { |
if (mobilav!=0) { |
mobaverage= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX); |
mobaverage= ma3x(1, AGESUP,1,NCOVMAX, 1,NCOVMAX); |
Line 3753 void varevsij(char optionfilefiname[], d
|
Line 3861 void varevsij(char optionfilefiname[], d
|
} |
} |
} |
} |
|
|
strcpy(fileresprobmorprev,"prmorprev"); |
strcpy(fileresprobmorprev,"PRMORPREV-"); |
sprintf(digit,"%-d",ij); |
sprintf(digit,"%-d",ij); |
/*printf("DIGIT=%s, ij=%d ijr=%-d|\n",digit, ij,ij);*/ |
/*printf("DIGIT=%s, ij=%d ijr=%-d|\n",digit, ij,ij);*/ |
strcat(fileresprobmorprev,digit); /* Tvar to be done */ |
strcat(fileresprobmorprev,digit); /* Tvar to be done */ |
strcat(fileresprobmorprev,digitp); /* Popbased or not, mobilav or not */ |
strcat(fileresprobmorprev,digitp); /* Popbased or not, mobilav or not */ |
strcat(fileresprobmorprev,fileres); |
strcat(fileresprobmorprev,fileresu); |
if((ficresprobmorprev=fopen(fileresprobmorprev,"w"))==NULL) { |
if((ficresprobmorprev=fopen(fileresprobmorprev,"w"))==NULL) { |
printf("Problem with resultfile: %s\n", fileresprobmorprev); |
printf("Problem with resultfile: %s\n", fileresprobmorprev); |
fprintf(ficlog,"Problem with resultfile: %s\n", fileresprobmorprev); |
fprintf(ficlog,"Problem with resultfile: %s\n", fileresprobmorprev); |
Line 3776 void varevsij(char optionfilefiname[], d
|
Line 3884 void varevsij(char optionfilefiname[], d
|
} |
} |
fprintf(ficresprobmorprev,"\n"); |
fprintf(ficresprobmorprev,"\n"); |
fprintf(ficgp,"\n# Routine varevsij"); |
fprintf(ficgp,"\n# Routine varevsij"); |
/* fprintf(fichtm, "#Local time at start: %s", strstart);*/ |
fprintf(ficgp,"\nunset title \n"); |
|
/* fprintf(fichtm, "#Local time at start: %s", strstart);*/ |
fprintf(fichtm,"\n<li><h4> Computing probabilities of dying over estepm months as a weighted average (i.e global mortality independent of initial healh state)</h4></li>\n"); |
fprintf(fichtm,"\n<li><h4> Computing probabilities of dying over estepm months as a weighted average (i.e global mortality independent of initial healh state)</h4></li>\n"); |
fprintf(fichtm,"\n<br>%s <br>\n",digitp); |
fprintf(fichtm,"\n<br>%s <br>\n",digitp); |
/* } */ |
/* } */ |
Line 3988 void varevsij(char optionfilefiname[], d
|
Line 4097 void varevsij(char optionfilefiname[], d
|
free_vector(gmp,nlstate+1,nlstate+ndeath); |
free_vector(gmp,nlstate+1,nlstate+ndeath); |
free_matrix(gradgp,1,npar,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*/ |
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 */ |
/* 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 set log y; unset log x;set xlabel \"Age\"; set ylabel \"Force of mortality (year-1)\";"); |
|
fprintf(ficgp,"\nset out \"%s%s.svg\";",subdirf3(optionfilefiname,"VARMUPTJGR-",digitp),digit); |
/* fprintf(ficgp,"\n plot \"%s\" u 1:($3*%6.3f) not w l 1 ",fileresprobmorprev,YEARM/estepm); */ |
/* fprintf(ficgp,"\n plot \"%s\" u 1:($3*%6.3f) not w l 1 ",fileresprobmorprev,YEARM/estepm); */ |
/* fprintf(ficgp,"\n replot \"%s\" u 1:(($3+1.96*$4)*%6.3f) t \"95\%% interval\" w l 2 ",fileresprobmorprev,YEARM/estepm); */ |
/* fprintf(ficgp,"\n replot \"%s\" u 1:(($3+1.96*$4)*%6.3f) t \"95\%% interval\" w l 2 ",fileresprobmorprev,YEARM/estepm); */ |
/* fprintf(ficgp,"\n replot \"%s\" u 1:(($3-1.96*$4)*%6.3f) not w l 2 ",fileresprobmorprev,YEARM/estepm); */ |
/* fprintf(ficgp,"\n replot \"%s\" u 1:(($3-1.96*$4)*%6.3f) not w l 2 ",fileresprobmorprev,YEARM/estepm); */ |
Line 3998 void varevsij(char optionfilefiname[], d
|
Line 4109 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)) 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(ficgp,"\n replot \"%s\" u 1:(($3-1.96*$4)) not w l lt 2 ",subdirf(fileresprobmorprev)); |
fprintf(fichtm,"\n<br> File (multiple files are possible if covariates are present): <A href=\"%s\">%s</a>\n",subdirf(fileresprobmorprev),subdirf(fileresprobmorprev)); |
fprintf(fichtm,"\n<br> File (multiple files are possible if covariates are present): <A href=\"%s\">%s</a>\n",subdirf(fileresprobmorprev),subdirf(fileresprobmorprev)); |
fprintf(fichtm,"\n<br> Probability is computed over estepm=%d months. <br> <img src=\"%s%s.png\"> <br>\n", estepm,subdirf3(optionfilefiname,"varmuptjgr",digitp),digit); |
fprintf(fichtm,"\n<br> Probability is computed over estepm=%d months. <br> <img src=\"%s%s.svg\"> <br>\n", estepm,subdirf3(optionfilefiname,"VARMUPTJGR-",digitp),digit); |
/* fprintf(fichtm,"\n<br> 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 <br> <img src=\"varmuptjgr%s%s.png\"> <br>\n", stepm,YEARM,digitp,digit); |
/* fprintf(fichtm,"\n<br> 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 <br> <img src=\"varmuptjgr%s%s.svg\"> <br>\n", stepm,YEARM,digitp,digit); |
*/ |
*/ |
/* fprintf(ficgp,"\nset out \"varmuptjgr%s%s%s.png\";replot;",digitp,optionfilefiname,digit); */ |
/* fprintf(ficgp,"\nset out \"varmuptjgr%s%s%s.svg\";replot;",digitp,optionfilefiname,digit); */ |
fprintf(ficgp,"\nset out \"%s%s.png\";replot;\n",subdirf3(optionfilefiname,"varmuptjgr",digitp),digit); |
fprintf(ficgp,"\nset out;\nset out \"%s%s.svg\";replot;set out;\n",subdirf3(optionfilefiname,"VARMUPTJGR-",digitp),digit); |
|
|
free_vector(xp,1,npar); |
free_vector(xp,1,npar); |
free_matrix(doldm,1,nlstate,1,nlstate); |
free_matrix(doldm,1,nlstate,1,nlstate); |
Line 4120 void varprob(char optionfilefiname[], do
|
Line 4231 void varprob(char optionfilefiname[], do
|
char fileresprobcor[FILENAMELENGTH]; |
char fileresprobcor[FILENAMELENGTH]; |
double ***varpij; |
double ***varpij; |
|
|
strcpy(fileresprob,"prob"); |
strcpy(fileresprob,"PROB_"); |
strcat(fileresprob,fileres); |
strcat(fileresprob,fileres); |
if((ficresprob=fopen(fileresprob,"w"))==NULL) { |
if((ficresprob=fopen(fileresprob,"w"))==NULL) { |
printf("Problem with resultfile: %s\n", fileresprob); |
printf("Problem with resultfile: %s\n", fileresprob); |
fprintf(ficlog,"Problem with resultfile: %s\n", fileresprob); |
fprintf(ficlog,"Problem with resultfile: %s\n", fileresprob); |
} |
} |
strcpy(fileresprobcov,"probcov"); |
strcpy(fileresprobcov,"PROBCOV_"); |
strcat(fileresprobcov,fileres); |
strcat(fileresprobcov,fileresu); |
if((ficresprobcov=fopen(fileresprobcov,"w"))==NULL) { |
if((ficresprobcov=fopen(fileresprobcov,"w"))==NULL) { |
printf("Problem with resultfile: %s\n", fileresprobcov); |
printf("Problem with resultfile: %s\n", fileresprobcov); |
fprintf(ficlog,"Problem with resultfile: %s\n", fileresprobcov); |
fprintf(ficlog,"Problem with resultfile: %s\n", fileresprobcov); |
} |
} |
strcpy(fileresprobcor,"probcor"); |
strcpy(fileresprobcor,"PROBCOR_"); |
strcat(fileresprobcor,fileres); |
strcat(fileresprobcor,fileresu); |
if((ficresprobcor=fopen(fileresprobcor,"w"))==NULL) { |
if((ficresprobcor=fopen(fileresprobcor,"w"))==NULL) { |
printf("Problem with resultfile: %s\n", fileresprobcor); |
printf("Problem with resultfile: %s\n", fileresprobcor); |
fprintf(ficlog,"Problem with resultfile: %s\n", fileresprobcor); |
fprintf(ficlog,"Problem with resultfile: %s\n", fileresprobcor); |
Line 4175 void varprob(char optionfilefiname[], do
|
Line 4286 void varprob(char optionfilefiname[], do
|
fprintf(fichtm,"\n<li><h4> Computing and drawing one step probabilities with their confidence intervals</h4></li>\n"); |
fprintf(fichtm,"\n<li><h4> Computing and drawing one step probabilities with their confidence intervals</h4></li>\n"); |
fprintf(fichtm,"\n"); |
fprintf(fichtm,"\n"); |
|
|
fprintf(fichtm,"\n<li><h4> <a href=\"%s\">Matrix of variance-covariance of pairs of step probabilities (drawings)</a></h4></li>\n",optionfilehtmcov); |
fprintf(fichtm,"\n<li><h4> <a href=\"%s\">Matrix of variance-covariance of one-step probabilities (drawings)</a></h4> this page is important in order to visualize confidence intervals and especially correlation between disability and recovery, or more generally, way in and way back.</li>\n",optionfilehtmcov); |
fprintf(fichtmcov,"\n<h4>Matrix of variance-covariance of pairs of step probabilities</h4>\n\ |
fprintf(fichtmcov,"Current page is file <a href=\"%s\">%s</a><br>\n\n<h4>Matrix of variance-covariance of pairs of step probabilities</h4>\n",optionfilehtmcov, optionfilehtmcov); |
file %s<br>\n",optionfilehtmcov); |
fprintf(fichtmcov,"\nEllipsoids of confidence centered on point (p<inf>ij</inf>, p<inf>kl</inf>) are estimated \ |
fprintf(fichtmcov,"\nEllipsoids of confidence centered on point (p<inf>ij</inf>, p<inf>kl</inf>) are estimated\ |
|
and drawn. It helps understanding how is the covariance between two incidences.\ |
and drawn. It helps understanding how is the covariance between two incidences.\ |
They are expressed in year<sup>-1</sup> in order to be less dependent of stepm.<br>\n"); |
They are expressed in year<sup>-1</sup> in order to be less dependent of stepm.<br>\n"); |
fprintf(fichtmcov,"\n<br> Contour plot corresponding to x'cov<sup>-1</sup>x = 4 (where x is the column vector (pij,pkl)) are drawn. \ |
fprintf(fichtmcov,"\n<br> Contour plot corresponding to x'cov<sup>-1</sup>x = 4 (where x is the column vector (pij,pkl)) are drawn. \ |
Line 4199 To be simple, these graphs help to under
|
Line 4309 To be simple, these graphs help to under
|
/*j1++;*/ |
/*j1++;*/ |
if (cptcovn>0) { |
if (cptcovn>0) { |
fprintf(ficresprob, "\n#********** Variable "); |
fprintf(ficresprob, "\n#********** Variable "); |
for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprob, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]); |
for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprob, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,z1)]); |
fprintf(ficresprob, "**********\n#\n"); |
fprintf(ficresprob, "**********\n#\n"); |
fprintf(ficresprobcov, "\n#********** Variable "); |
fprintf(ficresprobcov, "\n#********** Variable "); |
for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcov, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]); |
for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcov, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,z1)]); |
fprintf(ficresprobcov, "**********\n#\n"); |
fprintf(ficresprobcov, "**********\n#\n"); |
|
|
fprintf(ficgp, "\n#********** Variable "); |
fprintf(ficgp, "\n#********** Variable "); |
for (z1=1; z1<=cptcoveff; z1++) fprintf(ficgp, " V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]); |
for (z1=1; z1<=cptcoveff; z1++) fprintf(ficgp, " V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,z1)]); |
fprintf(ficgp, "**********\n#\n"); |
fprintf(ficgp, "**********\n#\n"); |
|
|
|
|
fprintf(fichtmcov, "\n<hr size=\"2\" color=\"#EC5E5E\">********** Variable "); |
fprintf(fichtmcov, "\n<hr size=\"2\" color=\"#EC5E5E\">********** Variable "); |
for (z1=1; z1<=cptcoveff; z1++) fprintf(fichtm, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]); |
for (z1=1; z1<=cptcoveff; z1++) fprintf(fichtm, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,z1)]); |
fprintf(fichtmcov, "**********\n<hr size=\"2\" color=\"#EC5E5E\">"); |
fprintf(fichtmcov, "**********\n<hr size=\"2\" color=\"#EC5E5E\">"); |
|
|
fprintf(ficresprobcor, "\n#********** Variable "); |
fprintf(ficresprobcor, "\n#********** Variable "); |
for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcor, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtab[j1][z1]]); |
for (z1=1; z1<=cptcoveff; z1++) fprintf(ficresprobcor, "V%d=%d ",Tvaraff[z1],nbcode[Tvaraff[z1]][codtabm(j1,z1)]); |
fprintf(ficresprobcor, "**********\n#"); |
fprintf(ficresprobcor, "**********\n#"); |
} |
} |
|
|
Line 4228 To be simple, these graphs help to under
|
Line 4338 To be simple, these graphs help to under
|
if(nagesqr==1) |
if(nagesqr==1) |
cov[3]= age*age; |
cov[3]= age*age; |
for (k=1; k<=cptcovn;k++) { |
for (k=1; k<=cptcovn;k++) { |
cov[2+nagesqr+k]=nbcode[Tvar[k]][codtab[j1][Tvar[k]]];/* j1 1 2 3 4 |
cov[2+nagesqr+k]=nbcode[Tvar[k]][codtabm(j1,k)]; |
|
/*cov[2+nagesqr+k]=nbcode[Tvar[k]][codtabm(j1,Tvar[k])];*//* j1 1 2 3 4 |
* 1 1 1 1 1 |
* 1 1 1 1 1 |
* 2 2 1 1 1 |
* 2 2 1 1 1 |
* 3 1 2 1 1 |
* 3 1 2 1 1 |
Line 4236 To be simple, these graphs help to under
|
Line 4347 To be simple, these graphs help to under
|
/* nbcode[1][1]=0 nbcode[1][2]=1;*/ |
/* nbcode[1][1]=0 nbcode[1][2]=1;*/ |
} |
} |
/* for (k=1; k<=cptcovage;k++) cov[2+Tage[k]]=cov[2+Tage[k]]*cov[2]; */ |
/* for (k=1; k<=cptcovage;k++) cov[2+Tage[k]]=cov[2+Tage[k]]*cov[2]; */ |
for (k=1; k<=cptcovage;k++) cov[2+Tage[k]]=nbcode[Tvar[Tage[k]]][codtab[ij][Tvar[Tage[k]]]]*cov[2]; |
for (k=1; k<=cptcovage;k++) cov[2+Tage[k]]=nbcode[Tvar[Tage[k]]][codtabm(ij,k)]*cov[2]; |
for (k=1; k<=cptcovprod;k++) |
for (k=1; k<=cptcovprod;k++) |
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtab[ij][Tvard[k][1]]]*nbcode[Tvard[k][2]][codtab[ij][Tvard[k][2]]]; |
cov[2+nagesqr+Tprod[k]]=nbcode[Tvard[k][1]][codtabm(ij,k)]*nbcode[Tvard[k][2]][codtabm(ij,k)]; |
|
|
|
|
for(theta=1; theta <=npar; theta++){ |
for(theta=1; theta <=npar; theta++){ |
Line 4386 To be simple, these graphs help to under
|
Line 4497 To be simple, these graphs help to under
|
/* mu2+ v21*lc1*cost + v22*lc2*sin(t) */ |
/* mu2+ v21*lc1*cost + v22*lc2*sin(t) */ |
if(first==1){ |
if(first==1){ |
first=0; |
first=0; |
|
fprintf(ficgp,"\n# Ellipsoids of confidence\n#\n"); |
fprintf(ficgp,"\nset parametric;unset label"); |
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 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<br>Ellipsoids of confidence cov(p%1d%1d,p%1d%1d) expressed in year<sup>-1</sup>\ |
fprintf(fichtmcov,"\n<br>Ellipsoids of confidence cov(p%1d%1d,p%1d%1d) expressed in year<sup>-1</sup>\ |
:<a href=\"%s%d%1d%1d-%1d%1d.png\">\ |
:<a href=\"%s_%d%1d%1d-%1d%1d.svg\">\ |
%s%d%1d%1d-%1d%1d.png</A>, ",k1,l1,k2,l2,\ |
%s_%d%1d%1d-%1d%1d.svg</A>, ",k1,l1,k2,l2,\ |
subdirf2(optionfilefiname,"varpijgr"), j1,k1,l1,k2,l2,\ |
subdirf2(optionfilefiname,"VARPIJGR_"), j1,k1,l1,k2,l2,\ |
subdirf2(optionfilefiname,"varpijgr"), j1,k1,l1,k2,l2); |
subdirf2(optionfilefiname,"VARPIJGR_"), j1,k1,l1,k2,l2); |
fprintf(fichtmcov,"\n<br><img src=\"%s%d%1d%1d-%1d%1d.png\"> ",subdirf2(optionfilefiname,"varpijgr"), j1,k1,l1,k2,l2); |
fprintf(fichtmcov,"\n<br><img src=\"%s_%d%1d%1d-%1d%1d.svg\"> ",subdirf2(optionfilefiname,"VARPIJGR_"), j1,k1,l1,k2,l2); |
fprintf(fichtmcov,"\n<br> Correlation at age %d (%.3f),",(int) age, c12); |
fprintf(fichtmcov,"\n<br> 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,"\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,"\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",\ |
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",\ |
Line 4413 To be simple, these graphs help to under
|
Line 4525 To be simple, these graphs help to under
|
}/* if first */ |
}/* if first */ |
} /* age mod 5 */ |
} /* age mod 5 */ |
} /* end loop age */ |
} /* 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;\nset out \"%s_%d%1d%1d-%1d%1d.svg\";replot;set out;",subdirf2(optionfilefiname,"VARPIJGR_"), j1,k1,l1,k2,l2); |
first=1; |
first=1; |
} /*l12 */ |
} /*l12 */ |
} /* k12 */ |
} /* k12 */ |
Line 4435 To be simple, these graphs help to under
|
Line 4547 To be simple, these graphs help to under
|
|
|
|
|
/******************* Printing html file ***********/ |
/******************* Printing html file ***********/ |
void printinghtml(char fileres[], char title[], char datafile[], int firstpass, \ |
void printinghtml(char fileresu[], char title[], char datafile[], int firstpass, \ |
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 estepm ,\ |
int popforecast, int estepm ,\ |
Line 4448 void printinghtml(char fileres[], char t
|
Line 4560 void printinghtml(char fileres[], char t
|
</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> <br>\n ", |
jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,subdirf2(fileres,"p"),subdirf2(fileres,"p")); |
jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,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(fileres,"pij"),subdirf2(fileres,"pij")); |
stepm,subdirf2(fileresu,"PIJ_"),subdirf2(fileresu,"PIJ_")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Period (stable) prevalence in each health state: <a href=\"%s\">%s</a> <br>\n", |
- Period (stable) prevalence in each health state: <a href=\"%s\">%s</a> <br>\n", |
subdirf2(fileres,"pl"),subdirf2(fileres,"pl")); |
subdirf2(fileresu,"PL_"),subdirf2(fileresu,"PL_")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- (a) Life expectancies by health status at initial age, ei. (b) health expectancies by health status at initial age, eij . If one or more covariates are included, specific tables for each value of the covariate are output in sequences within the same file (estepm=%2d months): \ |
- (a) Life expectancies by health status at initial age, ei. (b) health expectancies by health status at initial age, eij . If one or more covariates are included, specific tables for each value of the covariate are output in sequences within the same file (estepm=%2d months): \ |
<a href=\"%s\">%s</a> <br>\n", |
<a href=\"%s\">%s</a> <br>\n", |
estepm,subdirf2(fileres,"e"),subdirf2(fileres,"e")); |
estepm,subdirf2(fileresu,"E_"),subdirf2(fileresu,"E_")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Population projections by age and states: \ |
- Population projections by age and states: \ |
<a href=\"%s\">%s</a> <br>\n</li>", subdirf2(fileres,"f"),subdirf2(fileres,"f")); |
<a href=\"%s\">%s</a> <br>\n</li>", subdirf2(fileresu,"F_"),subdirf2(fileresu,"F_")); |
|
|
fprintf(fichtm," \n<ul><li><b>Graphs</b></li><p>"); |
fprintf(fichtm," \n<ul><li><b>Graphs</b></li><p>"); |
|
|
Line 4470 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
Line 4582 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
|
|
jj1=0; |
jj1=0; |
for(k1=1; k1<=m;k1++){ |
for(k1=1; k1<=m;k1++){ |
for(i1=1; i1<=ncodemax[k1];i1++){ |
/* for(i1=1; i1<=ncodemax[k1];i1++){ */ |
jj1++; |
jj1++; |
if (cptcovn > 0) { |
if (cptcovn > 0) { |
fprintf(fichtm,"<hr size=\"2\" color=\"#EC5E5E\">************ Results for covariates"); |
fprintf(fichtm,"<hr size=\"2\" color=\"#EC5E5E\">************ Results for covariates"); |
for (cpt=1; cpt<=cptcoveff;cpt++) |
for (cpt=1; cpt<=cptcoveff;cpt++){ |
fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtab[jj1][cpt]]); |
fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]); |
|
printf(" V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]);fflush(stdout); |
|
} |
fprintf(fichtm," ************\n<hr size=\"2\" color=\"#EC5E5E\">"); |
fprintf(fichtm," ************\n<hr size=\"2\" color=\"#EC5E5E\">"); |
} |
} |
|
/* aij, bij */ |
|
fprintf(fichtm,"<br>- Logit model, for example: logit(pij)=log(pij/pii)= aij+ bij age + V1 age + etc. as a function of age: <a href=\"%s_%d-1.svg\">%s_%d-1.svg</a><br> \ |
|
<img src=\"%s_%d-1.svg\">",subdirf2(optionfilefiname,"PE_"),jj1,subdirf2(optionfilefiname,"PE_"),jj1,subdirf2(optionfilefiname,"PE_"),jj1); |
/* Pij */ |
/* Pij */ |
fprintf(fichtm,"<br>- Pij or Conditional probabilities to be observed in state j being in state i, %d (stepm) months before: <a href=\"%s%d_1.png\">%s%d_1.png</a><br> \ |
fprintf(fichtm,"<br>\n- Pij or conditional probabilities to be observed in state j being in state i, %d (stepm) months before: <a href=\"%s_%d-2.svg\">%s_%d-2.svg</a><br> \ |
<img src=\"%s%d_1.png\">",stepm,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1); |
<img src=\"%s_%d-2.svg\">",stepm,subdirf2(optionfilefiname,"PE_"),jj1,subdirf2(optionfilefiname,"PE_"),jj1,subdirf2(optionfilefiname,"PE_"),jj1); |
/* Quasi-incidences */ |
/* Quasi-incidences */ |
fprintf(fichtm,"<br>- Pij or Conditional probabilities to be observed in state j being in state i %d (stepm) months\ |
fprintf(fichtm,"<br>\n- Iij 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: <a href=\"%s%d_2.png\">%s%d_2.png</a><br> \ |
before but expressed in per year i.e. quasi incidences if stepm is small and probabilities too,\ |
<img src=\"%s%d_2.png\">",stepm,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1); |
incidence (rates) are the limit when h tends to zero of the ratio of the probability hPij \ |
/* Period (stable) prevalence in each health state */ |
divided by h: hPij/h : <a href=\"%s_%d-3.svg\">%s_%d-3.svg</a><br> \ |
for(cpt=1; cpt<=nlstate;cpt++){ |
<img src=\"%s_%d-3.svg\">",stepm,subdirf2(optionfilefiname,"PE_"),jj1,subdirf2(optionfilefiname,"PE_"),jj1,subdirf2(optionfilefiname,"PE_"),jj1); |
fprintf(fichtm,"<br>- Convergence 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.png\">%s%d_%d.png</a><br> \ |
/* Survival functions (period) in state j */ |
<img src=\"%s%d_%d.png\">", 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,"<br>\n- Survival functions in state %d. Or probability to survive 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,"LIJ_"),cpt,jj1,subdirf2(optionfilefiname,"LIJ_"),cpt,jj1,subdirf2(optionfilefiname,"LIJ_"),cpt,jj1); |
|
} |
|
/* State specific survival functions (period) */ |
|
for(cpt=1; cpt<=nlstate;cpt++){ |
|
fprintf(fichtm,"<br>\n- Survival functions from state %d in any different live states and total.\ |
|
Or probability to survive in various states (1 to %d) being in state %d at different ages.\ |
|
<a href=\"%s%d_%d.svg\">%s%d_%d.svg</a><br> <img src=\"%s_%d-%d.svg\">", cpt, nlstate, cpt, subdirf2(optionfilefiname,"LIJT_"),cpt,jj1,subdirf2(optionfilefiname,"LIJT_"),cpt,jj1,subdirf2(optionfilefiname,"LIJT_"),cpt,jj1); |
|
} |
|
/* Period (stable) prevalence in each health state */ |
|
for(cpt=1; cpt<=nlstate;cpt++){ |
|
fprintf(fichtm,"<br>\n- Convergence 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,"P_"),cpt,jj1,subdirf2(optionfilefiname,"P_"),cpt,jj1,subdirf2(optionfilefiname,"P_"),cpt,jj1); |
|
} |
for(cpt=1; cpt<=nlstate;cpt++) { |
for(cpt=1; cpt<=nlstate;cpt++) { |
fprintf(fichtm,"\n<br>- Life expectancy by health state (%d) at initial age and its decomposition into health expectancies in each alive state (1 to %d) : <a href=\"%s%d%d.png\">%s%d%d.png</a> <br> \ |
fprintf(fichtm,"\n<br>- Life expectancy by health state (%d) at initial age and its decomposition into health expectancies in each alive state (1 to %d) (or area under each survival functions): <a href=\"%s%d%d.svg\">%s%d%d.svg</a> <br> \ |
<img src=\"%s%d%d.png\">",cpt,nlstate,subdirf2(optionfilefiname,"exp"),cpt,jj1,subdirf2(optionfilefiname,"exp"),cpt,jj1,subdirf2(optionfilefiname,"exp"),cpt,jj1); |
<img src=\"%s_%d%d.svg\">",cpt,nlstate,subdirf2(optionfilefiname,"EXP_"),cpt,jj1,subdirf2(optionfilefiname,"EXP_"),cpt,jj1,subdirf2(optionfilefiname,"EXP_"),cpt,jj1); |
} |
} |
} /* end i1 */ |
/* } /\* end i1 *\/ */ |
}/* End k1 */ |
}/* End k1 */ |
fprintf(fichtm,"</ul>"); |
fprintf(fichtm,"</ul>"); |
|
|
|
|
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
\n<br><li><h4> <a name='secondorder'>Result files (second order: variances)</a></h4>\n\ |
\n<br><li><h4> <a name='secondorder'>Result files (second order: variances)</a></h4>\n\ |
- Parameter file with estimated parameters and covariance matrix: <a href=\"%s\">%s</a> <br>\n", rfileres,rfileres); |
- Parameter file with estimated parameters and covariance matrix: <a href=\"%s\">%s</a> <br> \ |
|
- 95%% confidence intervals and Wald tests of the estimated parameters are in the log file.<br> \ |
|
But because parameters are usually highly correlated (a higher incidence of disability \ |
|
and a higher incidence of recovery can give very close observed transition) it might \ |
|
be very useful to look not only at linear confidence intervals estimated from the \ |
|
variances but at the covariance matrix. And instead of looking at the estimated coefficients \ |
|
(parameters) of the logistic regression, it might be more meaningful to visualize the \ |
|
covariance matrix of the one-step probabilities. \ |
|
See page 'Matrix of variance-covariance of one-step probabilities' below. \n", rfileres,rfileres); |
|
|
fprintf(fichtm," - Variance of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
fprintf(fichtm," - Standard deviation of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
subdirf2(fileres,"prob"),subdirf2(fileres,"prob")); |
subdirf2(fileresu,"PROB_"),subdirf2(fileresu,"PROB_")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Variance-covariance of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
- Variance-covariance of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
subdirf2(fileres,"probcov"),subdirf2(fileres,"probcov")); |
subdirf2(fileresu,"PROBCOV_"),subdirf2(fileresu,"PROBCOV_")); |
|
|
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Correlation matrix of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
- Correlation matrix of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
subdirf2(fileres,"probcor"),subdirf2(fileres,"probcor")); |
subdirf2(fileresu,"PROBCOR_"),subdirf2(fileresu,"PROBCOR_")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Variances and covariances of health expectancies by age and <b>initial health status</b> (cov(e<sup>ij</sup>,e<sup>kl</sup>)(estepm=%2d months): \ |
- Variances and covariances of health expectancies by age and <b>initial health status</b> (cov(e<sup>ij</sup>,e<sup>kl</sup>)(estepm=%2d months): \ |
<a href=\"%s\">%s</a> <br>\n</li>", |
<a href=\"%s\">%s</a> <br>\n</li>", |
estepm,subdirf2(fileres,"cve"),subdirf2(fileres,"cve")); |
estepm,subdirf2(fileresu,"CVE_"),subdirf2(fileresu,"CVE_")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- (a) Health expectancies by health status at initial age (e<sup>ij</sup>) and standard errors (in parentheses) (b) life expectancies and standard errors (e<sup>i.</sup>=e<sup>i1</sup>+e<sup>i2</sup>+...)(estepm=%2d months): \ |
- (a) Health expectancies by health status at initial age (e<sup>ij</sup>) and standard errors (in parentheses) (b) life expectancies and standard errors (e<sup>i.</sup>=e<sup>i1</sup>+e<sup>i2</sup>+...)(estepm=%2d months): \ |
<a href=\"%s\">%s</a> <br>\n</li>", |
<a href=\"%s\">%s</a> <br>\n</li>", |
estepm,subdirf2(fileres,"stde"),subdirf2(fileres,"stde")); |
estepm,subdirf2(fileresu,"STDE_"),subdirf2(fileresu,"STDE_")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Variances and covariances of health expectancies by age. Status (i) based health expectancies (in state j), e<sup>ij</sup> are weighted by the period prevalences in each state i (if popbased=1, an additional computation is done using the cross-sectional prevalences, i.e population based) (estepm=%d months): <a href=\"%s\">%s</a><br>\n", |
- Variances and covariances of health expectancies by age. Status (i) based health expectancies (in state j), e<sup>ij</sup> are weighted by the period prevalences in each state i (if popbased=1, an additional computation is done using the cross-sectional prevalences, i.e population based) (estepm=%d months): <a href=\"%s\">%s</a><br>\n", |
estepm, subdirf2(fileres,"v"),subdirf2(fileres,"v")); |
estepm, subdirf2(fileresu,"V_"),subdirf2(fileresu,"V_")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Total life expectancy and total health expectancies to be spent in each health state e<sup>.j</sup> with their standard errors (if popbased=1, an additional computation is done using the cross-sectional prevalences, i.e population based) (estepm=%d months): <a href=\"%s\">%s</a> <br>\n", |
- Total life expectancy and total health expectancies to be spent in each health state e<sup>.j</sup> with their standard errors (if popbased=1, an additional computation is done using the cross-sectional prevalences, i.e population based) (estepm=%d months): <a href=\"%s\">%s</a> <br>\n", |
estepm, subdirf2(fileres,"t"),subdirf2(fileres,"t")); |
estepm, subdirf2(fileresu,"T_"),subdirf2(fileresu,"T_")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
- Standard deviation of period (stable) prevalences: <a href=\"%s\">%s</a> <br>\n",\ |
- Standard deviation of period (stable) prevalences: <a href=\"%s\">%s</a> <br>\n",\ |
subdirf2(fileres,"vpl"),subdirf2(fileres,"vpl")); |
subdirf2(fileresu,"VPL_"),subdirf2(fileresu,"VPL_")); |
|
|
/* if(popforecast==1) fprintf(fichtm,"\n */ |
/* if(popforecast==1) fprintf(fichtm,"\n */ |
/* - Prevalences forecasting: <a href=\"f%s\">f%s</a> <br>\n */ |
/* - Prevalences forecasting: <a href=\"f%s\">f%s</a> <br>\n */ |
Line 4544 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
Line 4681 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
|
|
jj1=0; |
jj1=0; |
for(k1=1; k1<=m;k1++){ |
for(k1=1; k1<=m;k1++){ |
for(i1=1; i1<=ncodemax[k1];i1++){ |
/* for(i1=1; i1<=ncodemax[k1];i1++){ */ |
jj1++; |
jj1++; |
if (cptcovn > 0) { |
if (cptcovn > 0) { |
fprintf(fichtm,"<hr size=\"2\" color=\"#EC5E5E\">************ Results for covariates"); |
fprintf(fichtm,"<hr size=\"2\" color=\"#EC5E5E\">************ Results for covariates"); |
for (cpt=1; cpt<=cptcoveff;cpt++) |
for (cpt=1; cpt<=cptcoveff;cpt++) |
fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtab[jj1][cpt]]); |
fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]); |
fprintf(fichtm," ************\n<hr size=\"2\" color=\"#EC5E5E\">"); |
fprintf(fichtm," ************\n<hr size=\"2\" color=\"#EC5E5E\">"); |
} |
} |
for(cpt=1; cpt<=nlstate;cpt++) { |
for(cpt=1; cpt<=nlstate;cpt++) { |
fprintf(fichtm,"<br>- Observed (cross-sectional) and period (incidence based) \ |
fprintf(fichtm,"<br>- Observed (cross-sectional) and period (incidence based) \ |
prevalence (with 95%% confidence interval) in state (%d): %s%d_%d.png <br>\ |
prevalence (with 95%% confidence interval) in state (%d): %s%d_%d.svg <br>\ |
<img src=\"%s%d_%d.png\">",cpt,subdirf2(optionfilefiname,"v"),cpt,jj1,subdirf2(optionfilefiname,"v"),cpt,jj1); |
<img src=\"%s_%d-%d.svg\">",cpt,subdirf2(optionfilefiname,"V_"),cpt,jj1,subdirf2(optionfilefiname,"V_"),cpt,jj1); |
} |
} |
fprintf(fichtm,"\n<br>- Total life expectancy by age and \ |
fprintf(fichtm,"\n<br>- Total life expectancy by age and \ |
health expectancies in states (1) and (2). If popbased=1 the smooth (due to the model) \ |
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\ |
true period expectancies (those weighted with period prevalences are also\ |
drawn in addition to the population based expectancies computed using\ |
drawn in addition to the population based expectancies computed using\ |
observed and cahotic prevalences: %s%d.png<br>\ |
observed and cahotic prevalences: %s_%d.svg<br>\ |
<img src=\"%s%d.png\">",subdirf2(optionfilefiname,"e"),jj1,subdirf2(optionfilefiname,"e"),jj1); |
<img src=\"%s_%d.svg\">",subdirf2(optionfilefiname,"E_"),jj1,subdirf2(optionfilefiname,"E_"),jj1); |
} /* end i1 */ |
/* } /\* end i1 *\/ */ |
}/* End k1 */ |
}/* End k1 */ |
fprintf(fichtm,"</ul>"); |
fprintf(fichtm,"</ul>"); |
fflush(fichtm); |
fflush(fichtm); |
} |
} |
|
|
/******************* Gnuplot file **************/ |
/******************* Gnuplot file **************/ |
void printinggnuplot(char fileres[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){ |
void printinggnuplot(char fileresu[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){ |
|
|
char dirfileres[132],optfileres[132]; |
char dirfileres[132],optfileres[132]; |
int cpt=0,k1=0,i=0,k=0,j=0,jk=0,k2=0,k3=0,ij=0,l=0; |
int cpt=0,k1=0,i=0,k=0,j=0,jk=0,k2=0,k3=0,ij=0,l=0; |
int ng=0; |
int ng=0; |
|
int vpopbased; |
/* if((ficgp=fopen(optionfilegnuplot,"a"))==NULL) { */ |
/* if((ficgp=fopen(optionfilegnuplot,"a"))==NULL) { */ |
/* printf("Problem with file %s",optionfilegnuplot); */ |
/* printf("Problem with file %s",optionfilegnuplot); */ |
/* fprintf(ficlog,"Problem with file %s",optionfilegnuplot); */ |
/* fprintf(ficlog,"Problem with file %s",optionfilegnuplot); */ |
Line 4585 void printinggnuplot(char fileres[], cha
|
Line 4723 void printinggnuplot(char fileres[], cha
|
/*#endif */ |
/*#endif */ |
m=pow(2,cptcoveff); |
m=pow(2,cptcoveff); |
|
|
|
/* 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"); |
|
fprintf(ficgp,"\n set log y; unset log x;set xlabel \"Age\"; set ylabel \"Likelihood (-2Log(L))\";"); |
|
/* fprintf(ficgp,"\nset ter svg size 640, 480"); */ /* Too big for svg */ |
|
fprintf(ficgp,"\nset ter png size 640, 480"); |
|
/* good for mle=4 plot by number of matrix products. |
|
replot "rrtest1/toto.txt" u 2:($4 == 1 && $5==2 ? $9 : 1/0):5 t "p12" with point lc 1 */ |
|
/* replot exp(p1+p2*x)/(1+exp(p1+p2*x)+exp(p3+p4*x)+exp(p5+p6*x)) t "p12(x)" */ |
|
/* fprintf(ficgp,"\nset out \"%s.svg\";",subdirf2(optionfilefiname,"ILK_")); */ |
|
fprintf(ficgp,"\nset out \"%s.png\";",subdirf2(optionfilefiname,"ILK_")); |
|
fprintf(ficgp,"\nplot \"%s\" u 2:(-$11):3 t \"All sample, all transitions\" with dots lc variable",subdirf(fileresilk)); |
|
fprintf(ficgp,"\nreplot \"%s\" u 2:($3 <= 3 ? -$11 : 1/0):3 t \"First 3 individuals\" with line lc variable", subdirf(fileresilk)); |
|
fprintf(ficgp,"\nset out\n"); |
|
/* fprintf(ficgp,"\nset out \"%s.svg\"; replot; set out; # bug gnuplot",subdirf2(optionfilefiname,"ILK_")); */ |
|
|
strcpy(dirfileres,optionfilefiname); |
strcpy(dirfileres,optionfilefiname); |
strcpy(optfileres,"vpl"); |
strcpy(optfileres,"vpl"); |
/* 1eme*/ |
/* 1eme*/ |
fprintf(ficgp,"\n# 1st: Period (stable) prevalence with CI: 'vpl' files\n"); |
fprintf(ficgp,"\n# 1st: Period (stable) prevalence with CI: 'VPL_' files\n"); |
for (cpt=1; cpt<= nlstate ; cpt ++) { |
for (cpt=1; cpt<= nlstate ; cpt ++) { |
for (k1=1; k1<= m ; k1 ++) { /* plot [100000000000000000000:-100000000000000000000] "mysbiaspar/vplrmysbiaspar.txt to check */ |
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,"\nset out \"%s_%d-%d.svg\" \n",subdirf2(optionfilefiname,"V_"),cpt,k1); |
fprintf(ficgp,"\n#set out \"v%s%d_%d.png\" \n",optionfilefiname,cpt,k1); |
fprintf(ficgp,"\n#set out \"V_%s_%d-%d.svg\" \n",optionfilefiname,cpt,k1); |
fprintf(ficgp,"set xlabel \"Age\" \n\ |
fprintf(ficgp,"set xlabel \"Age\" \n\ |
set ylabel \"Probability\" \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); |
plot [%.f:%.f] \"%s\" every :::%d::%d u 1:2 \"%%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),k1-1,k1-1); |
|
|
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)"); |
} |
} |
fprintf(ficgp,"\" t\"Period (stable) prevalence\" w l lt 0,\"%s\" every :::%d::%d u 1:($2+1.96*$3) \"%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1); |
fprintf(ficgp,"\" t\"Period (stable) prevalence\" w l lt 0,\"%s\" every :::%d::%d u 1:($2+1.96*$3) \"%%lf",subdirf2(fileresu,"VPL_"),k1-1,k1-1); |
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)"); |
} |
} |
fprintf(ficgp,"\" t\"95%% CI\" w l lt 1,\"%s\" every :::%d::%d u 1:($2-1.96*$3) \"%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1); |
fprintf(ficgp,"\" t\"95%% CI\" w l lt 1,\"%s\" every :::%d::%d u 1:($2-1.96*$3) \"%%lf",subdirf2(fileresu,"VPL_"),k1-1,k1-1); |
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)"); |
} |
} |
fprintf(ficgp,"\" t\"\" w l lt 1,\"%s\" every :::%d::%d u 1:($%d) t\"Observed prevalence \" w l lt 2",subdirf2(fileres,"p"),k1-1,k1-1,2+4*(cpt-1)); |
fprintf(ficgp,"\" t\"\" w l lt 1,\"%s\" every :::%d::%d u 1:($%d) t\"Observed prevalence \" w l lt 2",subdirf2(fileresu,"P_"),k1-1,k1-1,2+4*(cpt-1)); |
} |
fprintf(ficgp,"\nset out \n"); |
} |
} /* k1 */ |
|
} /* cpt */ |
/*2 eme*/ |
/*2 eme*/ |
fprintf(ficgp,"\n# 2nd: Total life expectancy with CI: 't' files\n"); |
fprintf(ficgp,"\n# 2nd: Total life expectancy with CI: 't' files\n"); |
for (k1=1; k1<= m ; k1 ++) { |
for (k1=1; k1<= m ; k1 ++) { |
fprintf(ficgp,"\nset out \"%s%d.png\" \n",subdirf2(optionfilefiname,"e"),k1); |
fprintf(ficgp,"\nset out \"%s_%d.svg\" \n",subdirf2(optionfilefiname,"E_"),k1); |
fprintf(ficgp,"set ylabel \"Years\" \nset ter png small size 320, 240\nplot [%.f:%.f] ",ageminpar,fage); |
for(vpopbased=0; vpopbased <= popbased; vpopbased++){ /* Done for vpopbased=0 and vpopbased=1 if popbased==1*/ |
|
if(vpopbased==0) |
for (i=1; i<= nlstate+1 ; i ++) { |
fprintf(ficgp,"set ylabel \"Years\" \nset ter svg size 640, 480\nplot [%.f:%.f] ",ageminpar,fage); |
k=2*i; |
else |
fprintf(ficgp,"\"%s\" every :::%d::%d u 1:2 \"%%lf",subdirf2(fileres,"t"),k1-1,k1-1); |
fprintf(ficgp,"\nreplot "); |
for (j=1; j<= nlstate+1 ; j ++) { |
for (i=1; i<= nlstate+1 ; i ++) { |
if (j==i) fprintf(ficgp," %%lf (%%lf)"); |
k=2*i; |
else fprintf(ficgp," %%*lf (%%*lf)"); |
fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2==%d && $4!=0 ?$4 : 1/0) \"%%lf %%lf %%lf",subdirf2(fileresu,"T_"),k1-1,k1-1, vpopbased); |
} |
for (j=1; j<= nlstate+1 ; j ++) { |
if (i== 1) fprintf(ficgp,"\" t\"TLE\" w l ,"); |
if (j==i) fprintf(ficgp," %%lf (%%lf)"); |
else fprintf(ficgp,"\" t\"LE in state (%d)\" w l ,",i-1); |
else fprintf(ficgp," %%*lf (%%*lf)"); |
fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2-$3*2) \"%%lf",subdirf2(fileres,"t"),k1-1,k1-1); |
} |
for (j=1; j<= nlstate+1 ; j ++) { |
if (i== 1) fprintf(ficgp,"\" t\"TLE\" w l lt %d, \\\n",i); |
if (j==i) fprintf(ficgp," %%lf (%%lf)"); |
else fprintf(ficgp,"\" t\"LE in state (%d)\" w l lt %d, \\\n",i-1,i+1); |
else fprintf(ficgp," %%*lf (%%*lf)"); |
fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2==%d && $4!=0 ? $4-$5*2 : 1/0) \"%%lf %%lf %%lf",subdirf2(fileresu,"T_"),k1-1,k1-1,vpopbased); |
} |
for (j=1; j<= nlstate+1 ; j ++) { |
fprintf(ficgp,"\" t\"\" w l lt 0,"); |
if (j==i) fprintf(ficgp," %%lf (%%lf)"); |
fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2+$3*2) \"%%lf",subdirf2(fileres,"t"),k1-1,k1-1); |
else fprintf(ficgp," %%*lf (%%*lf)"); |
for (j=1; j<= nlstate+1 ; j ++) { |
} |
if (j==i) fprintf(ficgp," %%lf (%%lf)"); |
fprintf(ficgp,"\" t\"\" w l lt 0,"); |
else fprintf(ficgp," %%*lf (%%*lf)"); |
fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2==%d && $4!=0 ? $4+$5*2 : 1/0) \"%%lf %%lf %%lf",subdirf2(fileresu,"T_"),k1-1,k1-1,vpopbased); |
} |
for (j=1; j<= nlstate+1 ; j ++) { |
if (i== (nlstate+1)) fprintf(ficgp,"\" t\"\" w l lt 0"); |
if (j==i) fprintf(ficgp," %%lf (%%lf)"); |
else fprintf(ficgp,"\" t\"\" w l lt 0,"); |
else fprintf(ficgp," %%*lf (%%*lf)"); |
} |
} |
} |
if (i== (nlstate+1)) fprintf(ficgp,"\" t\"\" w l lt 0"); |
|
else fprintf(ficgp,"\" t\"\" w l lt 0,\\\n"); |
|
} /* state */ |
|
} /* vpopbased */ |
|
fprintf(ficgp,"\nset out;set out \"%s_%d.svg\"; replot; set out; \n",subdirf2(optionfilefiname,"E_"),k1); /* Buggy gnuplot */ |
|
} /* k1 */ |
/*3eme*/ |
/*3eme*/ |
|
|
for (k1=1; k1<= m ; k1 ++) { |
for (k1=1; k1<= m ; k1 ++) { |
for (cpt=1; cpt<= nlstate ; cpt ++) { |
for (cpt=1; cpt<= nlstate ; cpt ++) { |
/* k=2+nlstate*(2*cpt-2); */ |
/* k=2+nlstate*(2*cpt-2); */ |
k=2+(nlstate+1)*(cpt-1); |
k=2+(nlstate+1)*(cpt-1); |
fprintf(ficgp,"\nset out \"%s%d%d.png\" \n",subdirf2(optionfilefiname,"exp"),cpt,k1); |
fprintf(ficgp,"\nset out \"%s_%d%d.svg\" \n",subdirf2(optionfilefiname,"EXP_"),cpt,k1); |
fprintf(ficgp,"set ter png small size 320, 240\n\ |
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); |
plot [%.f:%.f] \"%s\" every :::%d::%d u 1:%d t \"e%d1\" w l",ageminpar,fage,subdirf2(fileresu,"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); |
/*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) "); |
for (i=1; i<= nlstate*2 ; i ++) fprintf(ficgp,"\%%lf (\%%lf) "); |
fprintf(ficgp,"\" t \"e%d1\" w l",cpt); |
fprintf(ficgp,"\" t \"e%d1\" w l",cpt); |
Line 4664 plot [%.f:%.f] \"%s\" every :::%d::%d u
|
Line 4823 plot [%.f:%.f] \"%s\" every :::%d::%d u
|
|
|
*/ |
*/ |
for (i=1; i< nlstate ; i ++) { |
for (i=1; i< nlstate ; i ++) { |
fprintf(ficgp," ,\"%s\" every :::%d::%d u 1:%d t \"e%d%d\" w l",subdirf2(fileres,"e"),k1-1,k1-1,k+i,cpt,i+1); |
fprintf(ficgp," ,\"%s\" every :::%d::%d u 1:%d t \"e%d%d\" w l",subdirf2(fileresu,"E_"),k1-1,k1-1,k+i,cpt,i+1); |
/* fprintf(ficgp," ,\"%s\" every :::%d::%d u 1:%d t \"e%d%d\" w l",subdirf2(fileres,"e"),k1-1,k1-1,k+2*i,cpt,i+1);*/ |
/* fprintf(ficgp," ,\"%s\" every :::%d::%d u 1:%d t \"e%d%d\" w l",subdirf2(fileres,"e"),k1-1,k1-1,k+2*i,cpt,i+1);*/ |
|
|
} |
} |
fprintf(ficgp," ,\"%s\" every :::%d::%d u 1:%d t \"e%d.\" w l",subdirf2(fileres,"e"),k1-1,k1-1,k+nlstate,cpt); |
fprintf(ficgp," ,\"%s\" every :::%d::%d u 1:%d t \"e%d.\" w l",subdirf2(fileresu,"E_"),k1-1,k1-1,k+nlstate,cpt); |
} |
} |
} |
} |
|
|
/* CV preval stable (period) */ |
/* Survival functions (period) from state i in state j by initial state i */ |
for (k1=1; k1<= m ; k1 ++) { /* For each multivariate if any */ |
for (k1=1; k1<= m ; k1 ++) { /* For each multivariate if any */ |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */ |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */ |
k=3; |
k=3; |
|
fprintf(ficgp,"\n#\n#\n# Survival functions in state j : 'lij' files, cov=%d state=%d",k1, cpt); |
|
fprintf(ficgp,"\nset out \"%s_%d-%d.svg\" \n",subdirf2(optionfilefiname,"LIJ_"),cpt,k1); |
|
fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability to be alive\" \n\ |
|
set ter svg size 640, 480\n\ |
|
unset log y\n\ |
|
plot [%.f:%.f] ", ageminpar, agemaxpar); |
|
for (i=1; i<= nlstate ; i ++){ |
|
if(i==1) |
|
fprintf(ficgp,"\"%s\"",subdirf2(fileresu,"PIJ_")); |
|
else |
|
fprintf(ficgp,", '' "); |
|
l=(nlstate+ndeath)*(i-1)+1; |
|
fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l); |
|
for (j=2; j<= nlstate+ndeath ; j ++) |
|
fprintf(ficgp,"+$%d",k+l+j-1); |
|
fprintf(ficgp,")) t \"l(%d,%d)\" w l",i,cpt); |
|
} /* nlstate */ |
|
fprintf(ficgp,"\nset out\n"); |
|
} /* end cpt state*/ |
|
} /* end covariate */ |
|
|
|
/* Survival functions (period) from state i in state j by final state j */ |
|
for (k1=1; k1<= m ; k1 ++) { /* For each covariate if any */ |
|
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each inital state */ |
|
k=3; |
|
fprintf(ficgp,"\n#\n#\n# Survival functions in state j and all livestates from state i by final state j: 'lij' files, cov=%d state=%d",k1, cpt); |
|
fprintf(ficgp,"\nset out \"%s_%d-%d.svg\" \n",subdirf2(optionfilefiname,"LIJT_"),cpt,k1); |
|
fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability to be alive\" \n\ |
|
set ter svg size 640, 480\n\ |
|
unset log y\n\ |
|
plot [%.f:%.f] ", ageminpar, agemaxpar); |
|
for (j=1; j<= nlstate ; j ++){ /* Lived in state j */ |
|
if(j==1) |
|
fprintf(ficgp,"\"%s\"",subdirf2(fileresu,"PIJ_")); |
|
else |
|
fprintf(ficgp,", '' "); |
|
l=(nlstate+ndeath)*(cpt-1) +j; |
|
fprintf(ficgp," u (($1==%d && (floor($2)%%5 == 0)) ? ($3):1/0):($%d",k1,k+l); |
|
/* for (i=2; i<= nlstate+ndeath ; i ++) */ |
|
/* fprintf(ficgp,"+$%d",k+l+i-1); */ |
|
fprintf(ficgp,") t \"l(%d,%d)\" w l",cpt,j); |
|
} /* nlstate */ |
|
fprintf(ficgp,", '' "); |
|
fprintf(ficgp," u (($1==%d && (floor($2)%%5 == 0)) ? ($3):1/0):(",k1); |
|
for (j=1; j<= nlstate ; j ++){ /* Lived in state j */ |
|
l=(nlstate+ndeath)*(cpt-1) +j; |
|
if(j < nlstate) |
|
fprintf(ficgp,"$%d +",k+l); |
|
else |
|
fprintf(ficgp,"$%d) t\"l(%d,.)\" w l",k+l,cpt); |
|
} |
|
fprintf(ficgp,"\nset out\n"); |
|
} /* end cpt state*/ |
|
} /* end covariate */ |
|
|
|
/* CV preval stable (period) for each covariate */ |
|
for (k1=1; k1<= m ; k1 ++) { /* For each covariate 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,"\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\ |
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\ |
unset log y\n\ |
plot [%.f:%.f] ", ageminpar, agemaxpar); |
plot [%.f:%.f] ", ageminpar, agemaxpar); |
for (i=1; i<= nlstate ; i ++){ |
for (i=1; i<= nlstate ; i ++){ |
if(i==1) |
if(i==1) |
fprintf(ficgp,"\"%s\"",subdirf2(fileres,"pij")); |
fprintf(ficgp,"\"%s\"",subdirf2(fileresu,"PIJ_")); |
else |
else |
fprintf(ficgp,", '' "); |
fprintf(ficgp,", '' "); |
l=(nlstate+ndeath)*(i-1)+1; |
l=(nlstate+ndeath)*(i-1)+1; |
fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l); |
fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l); |
for (j=1; j<= (nlstate-1) ; j ++) |
for (j=2; j<= nlstate ; j ++) |
fprintf(ficgp,"+$%d",k+l+j); |
fprintf(ficgp,"+$%d",k+l+j-1); |
fprintf(ficgp,")) t \"prev(%d,%d)\" w l",i,cpt); |
fprintf(ficgp,")) t \"prev(%d,%d)\" w l",i,cpt); |
} /* nlstate */ |
} /* nlstate */ |
fprintf(ficgp,"\n"); |
fprintf(ficgp,"\nset out\n"); |
} /* end cpt state*/ |
} /* end cpt state*/ |
} /* end covariate */ |
} /* end covariate */ |
|
|
/* proba elementaires */ |
/* proba elementaires */ |
fprintf(ficgp,"\n##############\n#MLE estimated parameters\n#############\n"); |
fprintf(ficgp,"\n##############\n#MLE estimated parameters\n#############\n"); |
for(i=1,jk=1; i <=nlstate; i++){ |
for(i=1,jk=1; i <=nlstate; i++){ |
Line 4715 plot [%.f:%.f] ", ageminpar, agemaxpar)
|
Line 4933 plot [%.f:%.f] ", ageminpar, agemaxpar)
|
fprintf(ficgp,"##############\n#\n"); |
fprintf(ficgp,"##############\n#\n"); |
|
|
/*goto avoid;*/ |
/*goto avoid;*/ |
fprintf(ficgp,"\n##############\n#Graphics of of probabilities or incidences\n#############\n"); |
fprintf(ficgp,"\n##############\n#Graphics of probabilities or incidences\n#############\n"); |
fprintf(ficgp,"# logi(p12/p11)=a12+b12*age+c12age*age+d12*V1+e12*V1*age\n"); |
fprintf(ficgp,"# logi(p12/p11)=a12+b12*age+c12age*age+d12*V1+e12*V1*age\n"); |
fprintf(ficgp,"# logi(p12/p11)=p1 +p2*age +p3*age*age+ p4*V1+ p5*V1*age\n"); |
fprintf(ficgp,"# logi(p12/p11)=p1 +p2*age +p3*age*age+ p4*V1+ p5*V1*age\n"); |
fprintf(ficgp,"# logi(p13/p11)=a13+b13*age+c13age*age+d13*V1+e13*V1*age\n"); |
fprintf(ficgp,"# logi(p13/p11)=a13+b13*age+c13age*age+d13*V1+e13*V1*age\n"); |
Line 4729 plot [%.f:%.f] ", ageminpar, agemaxpar)
|
Line 4947 plot [%.f:%.f] ", ageminpar, agemaxpar)
|
fprintf(ficgp,"# +exp(a13+b13*age+c13age*age+d13*V1+e13*V1*age))\n"); |
fprintf(ficgp,"# +exp(a13+b13*age+c13age*age+d13*V1+e13*V1*age))\n"); |
fprintf(ficgp,"# +exp(a14+b14*age+c14age*age+d14*V1+e14*V1*age)+...)\n"); |
fprintf(ficgp,"# +exp(a14+b14*age+c14age*age+d14*V1+e14*V1*age)+...)\n"); |
fprintf(ficgp,"#\n"); |
fprintf(ficgp,"#\n"); |
for(ng=1; ng<=2;ng++){ /* Number of graphics: first is probabilities second is incidence per year*/ |
for(ng=1; ng<=3;ng++){ /* Number of graphics: first is logit, 2nd is probabilities, third is incidences per year*/ |
fprintf(ficgp,"# ng=%d\n",ng); |
fprintf(ficgp,"# ng=%d\n",ng); |
fprintf(ficgp,"# jk=1 to 2^%d=%d\n",cptcoveff,m); |
fprintf(ficgp,"# jk=1 to 2^%d=%d\n",cptcoveff,m); |
for(jk=1; jk <=m; jk++) { |
for(jk=1; jk <=m; jk++) { |
fprintf(ficgp,"# jk=%d\n",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\" ",subdirf2(optionfilefiname,"PE_"),jk,ng); |
if (ng==2) |
fprintf(ficgp,"\nset ter svg size 640, 480 "); |
|
if (ng==1){ |
|
fprintf(ficgp,"\nset ylabel \"Value of the logit of the model\"\n"); /* exp(a12+b12*x) could be nice */ |
|
fprintf(ficgp,"\nunset log y"); |
|
}else if (ng==2){ |
|
fprintf(ficgp,"\nset ylabel \"Probability\"\n"); |
|
fprintf(ficgp,"\nset log y"); |
|
}else if (ng==3){ |
fprintf(ficgp,"\nset ylabel \"Quasi-incidence per year\"\n"); |
fprintf(ficgp,"\nset ylabel \"Quasi-incidence per year\"\n"); |
else |
fprintf(ficgp,"\nset log y"); |
fprintf(ficgp,"\nset title \"Probability\"\n"); |
}else |
fprintf(ficgp,"\nset ter png small size 320, 240\nset log y\nplot [%.f:%.f] ",ageminpar,agemaxpar); |
fprintf(ficgp,"\nunset title "); |
|
fprintf(ficgp,"\nplot [%.f:%.f] ",ageminpar,agemaxpar); |
i=1; |
i=1; |
for(k2=1; k2<=nlstate; k2++) { |
for(k2=1; k2<=nlstate; k2++) { |
k3=i; |
k3=i; |
for(k=1; k<=(nlstate+ndeath); k++) { |
for(k=1; k<=(nlstate+ndeath); k++) { |
if (k != k2){ |
if (k != k2){ |
if(ng==2) |
switch( ng) { |
|
case 1: |
if(nagesqr==0) |
if(nagesqr==0) |
fprintf(ficgp," %f*exp(p%d+p%d*x",YEARM/stepm,i,i+1); |
fprintf(ficgp," p%d+p%d*x",i,i+1); |
else /* nagesqr =1 */ |
else /* nagesqr =1 */ |
fprintf(ficgp," %f*exp(p%d+p%d*x+p%d*x*x",YEARM/stepm,i,i+1,i+1+nagesqr); |
fprintf(ficgp," p%d+p%d*x+p%d*x*x",i,i+1,i+1+nagesqr); |
else |
break; |
|
case 2: /* ng=2 */ |
if(nagesqr==0) |
if(nagesqr==0) |
fprintf(ficgp," exp(p%d+p%d*x",i,i+1); |
fprintf(ficgp," exp(p%d+p%d*x",i,i+1); |
else /* nagesqr =1 */ |
else /* nagesqr =1 */ |
fprintf(ficgp," exp(p%d+p%d*x+p%d*x*x",i,i+1,i+1+nagesqr); |
fprintf(ficgp," exp(p%d+p%d*x+p%d*x*x",i,i+1,i+1+nagesqr); |
|
break; |
|
case 3: |
|
if(nagesqr==0) |
|
fprintf(ficgp," %f*exp(p%d+p%d*x",YEARM/stepm,i,i+1); |
|
else /* nagesqr =1 */ |
|
fprintf(ficgp," %f*exp(p%d+p%d*x+p%d*x*x",YEARM/stepm,i,i+1,i+1+nagesqr); |
|
break; |
|
} |
ij=1;/* To be checked else nbcode[0][0] wrong */ |
ij=1;/* To be checked else nbcode[0][0] wrong */ |
for(j=3; j <=ncovmodel-nagesqr; j++) { |
for(j=3; j <=ncovmodel-nagesqr; j++) { |
if(((j-2)==Tage[ij]) &&(ij <=cptcovage)) { /* Bug valgrind */ |
/* printf("Tage[%d]=%d, j=%d\n", ij, Tage[ij], j); */ |
fprintf(ficgp,"+p%d*%d*x",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]); |
if(ij <=cptcovage) { /* Bug valgrind */ |
ij++; |
if((j-2)==Tage[ij]) { /* Bug valgrind */ |
|
fprintf(ficgp,"+p%d*%d*x",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtabm(jk,j-2)]); |
|
/* fprintf(ficgp,"+p%d*%d*x",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtabm(jk,Tvar[j-2])]); */ |
|
ij++; |
|
} |
} |
} |
else |
else |
fprintf(ficgp,"+p%d*%d",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtab[jk][j-2]]); |
fprintf(ficgp,"+p%d*%d",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtabm(jk,j-2)]); |
} |
} |
fprintf(ficgp,")/(1"); |
if(ng != 1){ |
|
fprintf(ficgp,")/(1"); |
|
|
for(k1=1; k1 <=nlstate; k1++){ |
for(k1=1; k1 <=nlstate; k1++){ |
if(nagesqr==0) |
if(nagesqr==0) |
fprintf(ficgp,"+exp(p%d+p%d*x",k3+(k1-1)*ncovmodel,k3+(k1-1)*ncovmodel+1); |
fprintf(ficgp,"+exp(p%d+p%d*x",k3+(k1-1)*ncovmodel,k3+(k1-1)*ncovmodel+1); |
else /* nagesqr =1 */ |
else /* nagesqr =1 */ |
fprintf(ficgp,"+exp(p%d+p%d*x+p%d*x*x",k3+(k1-1)*ncovmodel,k3+(k1-1)*ncovmodel+1,k3+(k1-1)*ncovmodel+1+nagesqr); |
fprintf(ficgp,"+exp(p%d+p%d*x+p%d*x*x",k3+(k1-1)*ncovmodel,k3+(k1-1)*ncovmodel+1,k3+(k1-1)*ncovmodel+1+nagesqr); |
|
|
ij=1; |
ij=1; |
for(j=3; j <=ncovmodel-nagesqr; j++){ |
for(j=3; j <=ncovmodel-nagesqr; j++){ |
if(((j-2)==Tage[ij]) &&(ij <=cptcovage)) { |
if(ij <=cptcovage) { /* Bug valgrind */ |
fprintf(ficgp,"+p%d*%d*x",k3+(k1-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]); |
if((j-2)==Tage[ij]) { /* Bug valgrind */ |
ij++; |
fprintf(ficgp,"+p%d*%d*x",k3+(k1-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtabm(jk,j-2)]); |
|
/* fprintf(ficgp,"+p%d*%d*x",k3+(k1-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtabm(jk,Tvar[j-2])]); */ |
|
ij++; |
|
} |
|
} |
|
else |
|
fprintf(ficgp,"+p%d*%d",k3+(k1-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtabm(jk,j-2)]); |
} |
} |
else |
fprintf(ficgp,")"); |
fprintf(ficgp,"+p%d*%d",k3+(k1-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtab[jk][j-2]]); |
|
} |
} |
fprintf(ficgp,")"); |
fprintf(ficgp,")"); |
|
if(ng ==2) |
|
fprintf(ficgp," t \"p%d%d\" ", k2,k); |
|
else /* ng= 3 */ |
|
fprintf(ficgp," t \"i%d%d\" ", k2,k); |
|
}else{ /* end ng <> 1 */ |
|
fprintf(ficgp," t \"logit(p%d%d)\" ", k2,k); |
} |
} |
fprintf(ficgp,") t \"p%d%d\" ", k2,k); |
|
if ((k+k2)!= (nlstate*2+ndeath)) fprintf(ficgp,","); |
if ((k+k2)!= (nlstate*2+ndeath)) fprintf(ficgp,","); |
i=i+ncovmodel; |
i=i+ncovmodel; |
} |
} |
} /* end k */ |
} /* end k */ |
} /* end k2 */ |
} /* end k2 */ |
|
fprintf(ficgp,"\n set out\n"); |
} /* end jk */ |
} /* end jk */ |
} /* end ng */ |
} /* end ng */ |
/* avoid: */ |
/* avoid: */ |
Line 4856 void prevforecast(char fileres[], double
|
Line 5108 void prevforecast(char fileres[], double
|
agelim=AGESUP; |
agelim=AGESUP; |
prevalence(probs, ageminpar, agemax, s, agev, nlstate, imx, Tvar, nbcode, ncodemax, mint, anint, dateprev1, dateprev2, firstpass, lastpass); |
prevalence(probs, ageminpar, agemax, s, agev, nlstate, imx, Tvar, nbcode, ncodemax, mint, anint, dateprev1, dateprev2, firstpass, lastpass); |
|
|
strcpy(fileresf,"f"); |
strcpy(fileresf,"F_"); |
strcat(fileresf,fileres); |
strcat(fileresf,fileresu); |
if((ficresf=fopen(fileresf,"w"))==NULL) { |
if((ficresf=fopen(fileresf,"w"))==NULL) { |
printf("Problem with forecast resultfile: %s\n", fileresf); |
printf("Problem with forecast resultfile: %s\n", fileresf); |
fprintf(ficlog,"Problem with forecast resultfile: %s\n", fileresf); |
fprintf(ficlog,"Problem with forecast resultfile: %s\n", fileresf); |
Line 4906 void prevforecast(char fileres[], double
|
Line 5158 void prevforecast(char fileres[], double
|
k=k+1; |
k=k+1; |
fprintf(ficresf,"\n#******"); |
fprintf(ficresf,"\n#******"); |
for(j=1;j<=cptcoveff;j++) { |
for(j=1;j<=cptcoveff;j++) { |
fprintf(ficresf," V%d=%d, hpijx=probability over h years, hp.jx is weighted by observed prev ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficresf," V%d=%d, hpijx=probability over h years, hp.jx is weighted by observed prev ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
} |
} |
fprintf(ficresf,"******\n"); |
fprintf(ficresf,"******\n"); |
fprintf(ficresf,"# Covariate valuofcovar yearproj age"); |
fprintf(ficresf,"# Covariate valuofcovar yearproj age"); |
Line 4930 void prevforecast(char fileres[], double
|
Line 5182 void prevforecast(char fileres[], double
|
if (h*hstepm/YEARM*stepm ==yearp) { |
if (h*hstepm/YEARM*stepm ==yearp) { |
fprintf(ficresf,"\n"); |
fprintf(ficresf,"\n"); |
for(j=1;j<=cptcoveff;j++) |
for(j=1;j<=cptcoveff;j++) |
fprintf(ficresf,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficresf,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
fprintf(ficresf,"%.f %.f ",anproj1+yearp,agec+h*hstepm/YEARM*stepm); |
fprintf(ficresf,"%.f %.f ",anproj1+yearp,agec+h*hstepm/YEARM*stepm); |
} |
} |
for(j=1; j<=nlstate+ndeath;j++) { |
for(j=1; j<=nlstate+ndeath;j++) { |
Line 4980 void populforecast(char fileres[], doubl
|
Line 5232 void populforecast(char fileres[], doubl
|
prevalence(probs, ageminpar, agemax, s, agev, nlstate, imx, Tvar, nbcode, ncodemax, mint, anint, dateprev1, dateprev2, firstpass, lastpass); |
prevalence(probs, ageminpar, agemax, s, agev, nlstate, imx, Tvar, nbcode, ncodemax, mint, anint, dateprev1, dateprev2, firstpass, lastpass); |
|
|
|
|
strcpy(filerespop,"pop"); |
strcpy(filerespop,"POP_"); |
strcat(filerespop,fileres); |
strcat(filerespop,fileresu); |
if((ficrespop=fopen(filerespop,"w"))==NULL) { |
if((ficrespop=fopen(filerespop,"w"))==NULL) { |
printf("Problem with forecast resultfile: %s\n", filerespop); |
printf("Problem with forecast resultfile: %s\n", filerespop); |
fprintf(ficlog,"Problem with forecast resultfile: %s\n", filerespop); |
fprintf(ficlog,"Problem with forecast resultfile: %s\n", filerespop); |
Line 5028 void populforecast(char fileres[], doubl
|
Line 5280 void populforecast(char fileres[], doubl
|
k=k+1; |
k=k+1; |
fprintf(ficrespop,"\n#******"); |
fprintf(ficrespop,"\n#******"); |
for(j=1;j<=cptcoveff;j++) { |
for(j=1;j<=cptcoveff;j++) { |
fprintf(ficrespop," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficrespop," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
} |
} |
fprintf(ficrespop,"******\n"); |
fprintf(ficrespop,"******\n"); |
fprintf(ficrespop,"# Age"); |
fprintf(ficrespop,"# Age"); |
Line 5334 double gompertz_f(const gsl_vector *v, v
|
Line 5586 double gompertz_f(const gsl_vector *v, v
|
#endif |
#endif |
|
|
/******************* Printing html file ***********/ |
/******************* Printing html file ***********/ |
void printinghtmlmort(char fileres[], char title[], char datafile[], int firstpass, \ |
void printinghtmlmort(char fileresu[], char title[], char datafile[], int firstpass, \ |
int lastpass, int stepm, int weightopt, char model[],\ |
int lastpass, int stepm, int weightopt, char model[],\ |
int imx, double p[],double **matcov,double agemortsup){ |
int imx, double p[],double **matcov,double agemortsup){ |
int i,k; |
int i,k; |
Line 5343 void printinghtmlmort(char fileres[], ch
|
Line 5595 void printinghtmlmort(char fileres[], ch
|
fprintf(fichtm," mu(age) =%lf*exp(%lf*(age-%d)) per year<br><br>",p[1],p[2],agegomp); |
fprintf(fichtm," mu(age) =%lf*exp(%lf*(age-%d)) per year<br><br>",p[1],p[2],agegomp); |
for (i=1;i<=2;i++) |
for (i=1;i<=2;i++) |
fprintf(fichtm," p[%d] = %lf [%f ; %f]<br>\n",i,p[i],p[i]-2*sqrt(matcov[i][i]),p[i]+2*sqrt(matcov[i][i])); |
fprintf(fichtm," p[%d] = %lf [%f ; %f]<br>\n",i,p[i],p[i]-2*sqrt(matcov[i][i]),p[i]+2*sqrt(matcov[i][i])); |
fprintf(fichtm,"<br><br><img src=\"graphmort.png\">"); |
fprintf(fichtm,"<br><br><img src=\"graphmort.svg\">"); |
fprintf(fichtm,"</ul>"); |
fprintf(fichtm,"</ul>"); |
|
|
fprintf(fichtm,"<ul><li><h4>Life table</h4>\n <br>"); |
fprintf(fichtm,"<ul><li><h4>Life table</h4>\n <br>"); |
Line 5358 fprintf(fichtm,"<ul><li><h4>Life table</
|
Line 5610 fprintf(fichtm,"<ul><li><h4>Life table</
|
} |
} |
|
|
/******************* Gnuplot file **************/ |
/******************* Gnuplot file **************/ |
void printinggnuplotmort(char fileres[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){ |
void printinggnuplotmort(char fileresu[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){ |
|
|
char dirfileres[132],optfileres[132]; |
char dirfileres[132],optfileres[132]; |
|
|
Line 5372 void printinggnuplotmort(char fileres[],
|
Line 5624 void printinggnuplotmort(char fileres[],
|
|
|
strcpy(dirfileres,optionfilefiname); |
strcpy(dirfileres,optionfilefiname); |
strcpy(optfileres,"vpl"); |
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 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, "set size 0.65,0.65\n"); */ |
fprintf(ficgp,"plot [%d:100] %lf*exp(%lf*(x-%d))",agegomp,p[1],p[2],agegomp); |
fprintf(ficgp,"plot [%d:100] %lf*exp(%lf*(x-%d))",agegomp,p[1],p[2],agegomp); |
|
|
Line 5395 int readdata(char datafile[], int firsto
|
Line 5647 int readdata(char datafile[], int firsto
|
|
|
|
|
if((fic=fopen(datafile,"r"))==NULL) { |
if((fic=fopen(datafile,"r"))==NULL) { |
printf("Problem while opening datafile: %s\n", datafile);return 1; |
printf("Problem while opening datafile: %s\n", datafile);fflush(stdout); |
fprintf(ficlog,"Problem while opening datafile: %s\n", datafile);return 1; |
fprintf(ficlog,"Problem while opening datafile: %s\n", datafile);fflush(ficlog);return 1; |
} |
} |
|
|
i=1; |
i=1; |
Line 5597 int decodemodel ( char model[], int last
|
Line 5849 int decodemodel ( char model[], int last
|
if (strlen(model) >1){ /* If there is at least 1 covariate */ |
if (strlen(model) >1){ /* If there is at least 1 covariate */ |
j=0, j1=0, k1=0, k2=-1, ks=0, cptcovn=0; |
j=0, j1=0, k1=0, k2=-1, ks=0, cptcovn=0; |
if (strstr(model,"AGE") !=0){ |
if (strstr(model,"AGE") !=0){ |
printf("Error. AGE must be in lower case 'age' model=1+age+%s ",model); |
printf("Error. AGE must be in lower case 'age' model=1+age+%s. ",model); |
fprintf(ficlog,"Error. AGE must be in lower case model=1+age+%s ",model);fflush(ficlog); |
fprintf(ficlog,"Error. AGE must be in lower case model=1+age+%s. ",model);fflush(ficlog); |
return 1; |
return 1; |
} |
} |
if (strstr(model,"v") !=0){ |
if (strstr(model,"v") !=0){ |
Line 5611 int decodemodel ( char model[], int last
|
Line 5863 int decodemodel ( char model[], int last
|
printf(" strpt=%s, model=%s\n",strpt, model); |
printf(" strpt=%s, model=%s\n",strpt, model); |
if(strpt != model){ |
if(strpt != model){ |
printf("Error in model: 'model=%s'; 'age*age' should in first place before other covariates\n \ |
printf("Error in model: 'model=%s'; 'age*age' should in first place before other covariates\n \ |
'model=1+age+age*age+V1' or 'model=1+age+age*age+V1+V1*age', please swap as well as \n \ |
'model=1+age+age*age+V1.' or 'model=1+age+age*age+V1+V1*age.', please swap as well as \n \ |
corresponding column of parameters.\n",model); |
corresponding column of parameters.\n",model); |
fprintf(ficlog,"Error in model: 'model=%s'; 'age*age' should in first place before other covariates\n \ |
fprintf(ficlog,"Error in model: 'model=%s'; 'age*age' should in first place before other covariates\n \ |
'model=1+age+age*age+V1' or 'model=1+age+age*age+V1+V1*age', please swap as well as \n \ |
'model=1+age+age*age+V1.' or 'model=1+age+age*age+V1+V1*age.', please swap as well as \n \ |
corresponding column of parameters.\n",model); fflush(ficlog); |
corresponding column of parameters.\n",model); fflush(ficlog); |
return 1; |
return 1; |
} |
} |
Line 5685 int decodemodel ( char model[], int last
|
Line 5937 int decodemodel ( char model[], int last
|
/* k=1 Tvar[1]=2 (from V2) */ |
/* k=1 Tvar[1]=2 (from V2) */ |
/* k=5 Tvar[5] */ |
/* k=5 Tvar[5] */ |
/* for (k=1; k<=cptcovn;k++) { */ |
/* for (k=1; k<=cptcovn;k++) { */ |
/* cov[2+k]=nbcode[Tvar[k]][codtab[ij][Tvar[k]]]; */ |
/* cov[2+k]=nbcode[Tvar[k]][codtabm(ij,Tvar[k])]; */ |
/* } */ |
/* } */ |
/* for (k=1; k<=cptcovage;k++) cov[2+Tage[k]]=nbcode[Tvar[Tage[k]]][codtab[ij][Tvar[Tage[k]]]]*cov[2]; */ |
/* for (k=1; k<=cptcovage;k++) cov[2+Tage[k]]=nbcode[Tvar[Tage[k]]][codtabm(ij,Tvar[Tage[k])]]*cov[2]; */ |
/* |
/* |
* Treating invertedly V2+V1+V3*age+V2*V4 is as if written V2*V4 +V3*age + V1 + V2 */ |
* Treating invertedly V2+V1+V3*age+V2*V4 is as if written V2*V4 +V3*age + V1 + V2 */ |
for(k=cptcovt; k>=1;k--) /**< Number of covariates */ |
for(k=cptcovt; k>=1;k--) /**< Number of covariates */ |
Line 6065 void syscompilerinfo(int logged)
|
Line 6317 void syscompilerinfo(int logged)
|
|
|
} |
} |
|
|
int prevalence_limit(double *p, double **prlim, double ageminpar, double agemaxpar){ |
int prevalence_limit(double *p, double **prlim, double ageminpar, double agemaxpar, double ftolpl){ |
/*--------------- Prevalence limit (period or stable prevalence) --------------*/ |
/*--------------- Prevalence limit (period or stable prevalence) --------------*/ |
int i, j, k, i1 ; |
int i, j, k, i1 ; |
double ftolpl = 1.e-10; |
/* double ftolpl = 1.e-10; */ |
double age, agebase, agelim; |
double age, agebase, agelim; |
|
|
strcpy(filerespl,"pl"); |
strcpy(filerespl,"PL_"); |
strcat(filerespl,fileres); |
strcat(filerespl,fileresu); |
if((ficrespl=fopen(filerespl,"w"))==NULL) { |
if((ficrespl=fopen(filerespl,"w"))==NULL) { |
printf("Problem with period (stable) prevalence resultfile: %s\n", filerespl);return 1; |
printf("Problem with period (stable) prevalence resultfile: %s\n", filerespl);return 1; |
fprintf(ficlog,"Problem with period (stable) prevalence resultfile: %s\n", filerespl);return 1; |
fprintf(ficlog,"Problem with period (stable) prevalence resultfile: %s\n", filerespl);return 1; |
} |
} |
printf("Computing period (stable) prevalence: result on file '%s' \n", filerespl); |
printf("Computing period (stable) prevalence: result on file '%s' \n", filerespl); |
fprintf(ficlog,"Computing period (stable) prevalence: result on file '%s' \n", filerespl); |
fprintf(ficlog,"Computing period (stable) prevalence: result on file '%s' \n", filerespl); |
pstamp(ficrespl); |
pstamp(ficrespl); |
fprintf(ficrespl,"# Period (stable) prevalence \n"); |
fprintf(ficrespl,"# Period (stable) prevalence \n"); |
fprintf(ficrespl,"#Age "); |
fprintf(ficrespl,"#Age "); |
for(i=1; i<=nlstate;i++) fprintf(ficrespl,"%d-%d ",i,i); |
for(i=1; i<=nlstate;i++) fprintf(ficrespl,"%d-%d ",i,i); |
fprintf(ficrespl,"\n"); |
fprintf(ficrespl,"\n"); |
|
|
/* prlim=matrix(1,nlstate,1,nlstate);*/ /* back in main */ |
/* prlim=matrix(1,nlstate,1,nlstate);*/ /* back in main */ |
|
|
Line 6098 int prevalence_limit(double *p, double *
|
Line 6350 int prevalence_limit(double *p, double *
|
//for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){ |
//for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){ |
k=k+1; |
k=k+1; |
/* to clean */ |
/* to clean */ |
//printf("cptcov=%d cptcod=%d codtab=%d\n",cptcov, cptcod,codtab[cptcod][cptcov]); |
//printf("cptcov=%d cptcod=%d codtab=%d\n",cptcov, cptcod,codtabm(cptcod,cptcov)); |
fprintf(ficrespl,"\n#******"); |
fprintf(ficrespl,"#******"); |
printf("\n#******"); |
printf("#******"); |
fprintf(ficlog,"\n#******"); |
fprintf(ficlog,"#******"); |
for(j=1;j<=cptcoveff;j++) { |
for(j=1;j<=cptcoveff;j++) { |
fprintf(ficrespl," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficrespl," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
printf(" V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
printf(" V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
fprintf(ficlog," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficlog," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
} |
} |
fprintf(ficrespl,"******\n"); |
fprintf(ficrespl,"******\n"); |
printf("******\n"); |
printf("******\n"); |
Line 6113 int prevalence_limit(double *p, double *
|
Line 6365 int prevalence_limit(double *p, double *
|
|
|
fprintf(ficrespl,"#Age "); |
fprintf(ficrespl,"#Age "); |
for(j=1;j<=cptcoveff;j++) { |
for(j=1;j<=cptcoveff;j++) { |
fprintf(ficrespl,"V%d %d",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficrespl,"V%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
} |
} |
for(i=1; i<=nlstate;i++) fprintf(ficrespl,"%d-%d ",i,i); |
for(i=1; i<=nlstate;i++) fprintf(ficrespl,"%d-%d ",i,i); |
fprintf(ficrespl,"\n"); |
fprintf(ficrespl,"\n"); |
Line 6123 int prevalence_limit(double *p, double *
|
Line 6375 int prevalence_limit(double *p, double *
|
prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k); |
prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k); |
fprintf(ficrespl,"%.0f ",age ); |
fprintf(ficrespl,"%.0f ",age ); |
for(j=1;j<=cptcoveff;j++) |
for(j=1;j<=cptcoveff;j++) |
fprintf(ficrespl,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficrespl,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
for(i=1; i<=nlstate;i++) |
for(i=1; i<=nlstate;i++) |
fprintf(ficrespl," %.5f", prlim[i][i]); |
fprintf(ficrespl," %.5f", prlim[i][i]); |
fprintf(ficrespl,"\n"); |
fprintf(ficrespl,"\n"); |
Line 6145 int hPijx(double *p, int bage, int fage)
|
Line 6397 int hPijx(double *p, int bage, int fage)
|
double agedeb; |
double agedeb; |
double ***p3mat; |
double ***p3mat; |
|
|
strcpy(filerespij,"pij"); strcat(filerespij,fileres); |
strcpy(filerespij,"PIJ_"); strcat(filerespij,fileresu); |
if((ficrespij=fopen(filerespij,"w"))==NULL) { |
if((ficrespij=fopen(filerespij,"w"))==NULL) { |
printf("Problem with Pij resultfile: %s\n", filerespij); return 1; |
printf("Problem with Pij resultfile: %s\n", filerespij); return 1; |
fprintf(ficlog,"Problem with Pij resultfile: %s\n", filerespij); return 1; |
fprintf(ficlog,"Problem with Pij resultfile: %s\n", filerespij); return 1; |
Line 6170 int hPijx(double *p, int bage, int fage)
|
Line 6422 int hPijx(double *p, int bage, int fage)
|
for (k=1; k <= (int) pow(2,cptcoveff); k++){ |
for (k=1; k <= (int) pow(2,cptcoveff); k++){ |
fprintf(ficrespij,"\n#****** "); |
fprintf(ficrespij,"\n#****** "); |
for(j=1;j<=cptcoveff;j++) |
for(j=1;j<=cptcoveff;j++) |
fprintf(ficrespij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficrespij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
fprintf(ficrespij,"******\n"); |
fprintf(ficrespij,"******\n"); |
|
|
for (agedeb=fage; agedeb>=bage; agedeb--){ /* If stepm=6 months */ |
for (agedeb=fage; agedeb>=bage; agedeb--){ /* If stepm=6 months */ |
Line 6222 int main(int argc, char *argv[])
|
Line 6474 int main(int argc, char *argv[])
|
|
|
int jj, ll, li, lj, lk; |
int jj, ll, li, lj, lk; |
int numlinepar=0; /* Current linenumber of parameter file */ |
int numlinepar=0; /* Current linenumber of parameter file */ |
|
int num_filled; |
int itimes; |
int itimes; |
int NDIM=2; |
int NDIM=2; |
int vpopbased=0; |
int vpopbased=0; |
Line 6231 int main(int argc, char *argv[])
|
Line 6484 int main(int argc, char *argv[])
|
/* FILE *ficgp;*/ /*Gnuplot File */ |
/* FILE *ficgp;*/ /*Gnuplot File */ |
struct stat info; |
struct stat info; |
double agedeb=0.; |
double agedeb=0.; |
double ageminpar=1.e20,agemin=1.e20, agemaxpar=-1.e20, agemax=-1.e20; |
|
|
double ageminpar=AGEOVERFLOW,agemin=AGEOVERFLOW, agemaxpar=-AGEOVERFLOW, agemax=-AGEOVERFLOW; |
|
|
double fret; |
double fret; |
double dum=0.; /* Dummy variable */ |
double dum=0.; /* Dummy variable */ |
Line 6239 int main(int argc, char *argv[])
|
Line 6493 int main(int argc, char *argv[])
|
double ***mobaverage; |
double ***mobaverage; |
|
|
char line[MAXLINE]; |
char line[MAXLINE]; |
char path[MAXLINE],pathc[MAXLINE],pathcd[MAXLINE],pathtot[MAXLINE],model[MAXLINE]; |
char path[MAXLINE],pathc[MAXLINE],pathcd[MAXLINE],pathtot[MAXLINE]; |
|
|
|
char model[MAXLINE], modeltemp[MAXLINE]; |
char pathr[MAXLINE], pathimach[MAXLINE]; |
char pathr[MAXLINE], pathimach[MAXLINE]; |
char *tok, *val; /* pathtot */ |
char *tok, *val; /* pathtot */ |
int firstobs=1, lastobs=10; |
int firstobs=1, lastobs=10; |
int c, h , cpt; |
int c, h , cpt, c2; |
int jl=0; |
int jl=0; |
int i1, j1, jk, stepsize=0; |
int i1, j1, jk, stepsize=0; |
|
int count=0; |
|
|
int *tab; |
int *tab; |
int mobilavproj=0 , prevfcast=0 ; /* moving average of prev, If prevfcast=1 prevalence projection */ |
int mobilavproj=0 , prevfcast=0 ; /* moving average of prev, If prevfcast=1 prevalence projection */ |
int mobilav=0,popforecast=0; |
int mobilav=0,popforecast=0; |
Line 6317 int main(int argc, char *argv[])
|
Line 6575 int main(int argc, char *argv[])
|
getcwd(pathcd, size); |
getcwd(pathcd, size); |
#endif |
#endif |
syscompilerinfo(0); |
syscompilerinfo(0); |
printf("\n%s\n%s",version,fullversion); |
printf("\nIMaCh version %s, %s\n%s",version, copyright, fullversion); |
if(argc <=1){ |
if(argc <=1){ |
printf("\nEnter the parameter file name: "); |
printf("\nEnter the parameter file name: "); |
fgets(pathr,FILENAMELENGTH,stdin); |
fgets(pathr,FILENAMELENGTH,stdin); |
Line 6381 int main(int argc, char *argv[])
|
Line 6639 int main(int argc, char *argv[])
|
goto end; |
goto end; |
} |
} |
fprintf(ficlog,"Log filename:%s\n",filelog); |
fprintf(ficlog,"Log filename:%s\n",filelog); |
fprintf(ficlog,"\n%s\n%s",version,fullversion); |
fprintf(ficlog,"Version %s %s",version,fullversion); |
fprintf(ficlog,"\nEnter the parameter file name: \n"); |
fprintf(ficlog,"\nEnter the parameter file name: \n"); |
fprintf(ficlog,"pathimach=%s\npathtot=%s\n\ |
fprintf(ficlog,"pathimach=%s\npathtot=%s\n\ |
path=%s \n\ |
path=%s \n\ |
Line 6389 int main(int argc, char *argv[])
|
Line 6647 int main(int argc, char *argv[])
|
optionfilext=%s\n\ |
optionfilext=%s\n\ |
optionfilefiname='%s'\n",pathimach,pathtot,path,optionfile,optionfilext,optionfilefiname); |
optionfilefiname='%s'\n",pathimach,pathtot,path,optionfile,optionfilext,optionfilefiname); |
|
|
syscompilerinfo(0); |
syscompilerinfo(1); |
|
|
printf("Local time (at start):%s",strstart); |
printf("Local time (at start):%s",strstart); |
fprintf(ficlog,"Local time (at start): %s",strstart); |
fprintf(ficlog,"Local time (at start): %s",strstart); |
Line 6400 int main(int argc, char *argv[])
|
Line 6658 int main(int argc, char *argv[])
|
/* */ |
/* */ |
strcpy(fileres,"r"); |
strcpy(fileres,"r"); |
strcat(fileres, optionfilefiname); |
strcat(fileres, optionfilefiname); |
|
strcat(fileresu, optionfilefiname); /* Without r in front */ |
strcat(fileres,".txt"); /* Other files have txt extension */ |
strcat(fileres,".txt"); /* Other files have txt extension */ |
|
strcat(fileresu,".txt"); /* Other files have txt extension */ |
|
|
/* Main ---------arguments file --------*/ |
/* Main ---------arguments file --------*/ |
|
|
Line 6415 int main(int argc, char *argv[])
|
Line 6675 int main(int argc, char *argv[])
|
|
|
|
|
strcpy(filereso,"o"); |
strcpy(filereso,"o"); |
strcat(filereso,fileres); |
strcat(filereso,fileresu); |
if((ficparo=fopen(filereso,"w"))==NULL) { /* opened on subdirectory */ |
if((ficparo=fopen(filereso,"w"))==NULL) { /* opened on subdirectory */ |
printf("Problem with Output resultfile: %s\n", filereso); |
printf("Problem with Output resultfile: %s\n", filereso); |
fprintf(ficlog,"Problem with Output resultfile: %s\n", filereso); |
fprintf(ficlog,"Problem with Output resultfile: %s\n", filereso); |
Line 6425 int main(int argc, char *argv[])
|
Line 6685 int main(int argc, char *argv[])
|
|
|
/* Reads comments: lines beginning with '#' */ |
/* Reads comments: lines beginning with '#' */ |
numlinepar=0; |
numlinepar=0; |
while((c=getc(ficpar))=='#' && c!= EOF){ |
|
ungetc(c,ficpar); |
/* First parameter line */ |
fgets(line, MAXLINE, ficpar); |
while(fgets(line, MAXLINE, ficpar)) { |
|
/* If line starts with a # it is a comment */ |
|
if (line[0] == '#') { |
|
numlinepar++; |
|
fputs(line,stdout); |
|
fputs(line,ficparo); |
|
fputs(line,ficlog); |
|
continue; |
|
}else |
|
break; |
|
} |
|
if((num_filled=sscanf(line,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\n", \ |
|
title, datafile, &lastobs, &firstpass,&lastpass)) !=EOF){ |
|
if (num_filled != 5) { |
|
printf("Should be 5 parameters\n"); |
|
} |
numlinepar++; |
numlinepar++; |
fputs(line,stdout); |
printf("title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\n", title, datafile, lastobs, firstpass,lastpass); |
fputs(line,ficparo); |
|
fputs(line,ficlog); |
|
} |
} |
ungetc(c,ficpar); |
/* Second parameter line */ |
|
while(fgets(line, MAXLINE, ficpar)) { |
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); |
/* If line starts with a # it is a comment */ |
numlinepar++; |
if (line[0] == '#') { |
printf("title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nlstate,ndeath, maxwav, mle, weightopt,model); |
numlinepar++; |
|
fputs(line,stdout); |
|
fputs(line,ficparo); |
|
fputs(line,ficlog); |
|
continue; |
|
}else |
|
break; |
|
} |
|
if((num_filled=sscanf(line,"ftol=%lf stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n", \ |
|
&ftol, &stepm, &ncovcol, &nlstate, &ndeath, &maxwav, &mle, &weightopt)) !=EOF){ |
|
if (num_filled != 8) { |
|
printf("Not 8\n"); |
|
} |
|
printf("ftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nlstate,ndeath, maxwav, mle, weightopt); |
|
} |
|
ftolpl=6*ftol*1.e5; /* 6.e-3 make convergences in less than 80 loops for the prevalence limit */ |
|
/* Third parameter line */ |
|
while(fgets(line, MAXLINE, ficpar)) { |
|
/* If line starts with a # it is a comment */ |
|
if (line[0] == '#') { |
|
numlinepar++; |
|
fputs(line,stdout); |
|
fputs(line,ficparo); |
|
fputs(line,ficlog); |
|
continue; |
|
}else |
|
break; |
|
} |
|
if((num_filled=sscanf(line,"model=1+age%[^.\n]", model)) !=EOF){ |
|
if (num_filled == 0) |
|
model[0]='\0'; |
|
else if (num_filled != 1){ |
|
printf("ERROR %d: Model should be at minimum 'model=1+age.' %s\n",num_filled, line); |
|
fprintf(ficlog,"ERROR %d: Model should be at minimum 'model=1+age.' %s\n",num_filled, line); |
|
model[0]='\0'; |
|
goto end; |
|
} |
|
else{ |
|
if (model[0]=='+'){ |
|
for(i=1; i<=strlen(model);i++) |
|
modeltemp[i-1]=model[i]; |
|
strcpy(model,modeltemp); |
|
} |
|
} |
|
/* 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 *\/ */ |
|
/* printf("title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nlstate,ndeath, maxwav, mle, weightopt,model); */ |
if(model[strlen(model)-1]=='.') /* Suppressing leading dot in the model */ |
if(model[strlen(model)-1]=='.') /* Suppressing leading dot in the model */ |
model[strlen(model)-1]='\0'; |
model[strlen(model)-1]='\0'; |
fprintf(ficparo,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol,nlstate,ndeath,maxwav, mle, weightopt,model); |
fprintf(ficparo,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol,nlstate,ndeath,maxwav, mle, weightopt,model); |
fprintf(ficlog,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol,nlstate,ndeath,maxwav, mle, weightopt,model); |
fprintf(ficlog,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol,nlstate,ndeath,maxwav, mle, weightopt,model); |
fflush(ficlog); |
fflush(ficlog); |
/* if(model[0]=='#'|| model[0]== '\0'){ */ |
/* if(model[0]=='#'|| model[0]== '\0'){ */ |
if(model[0]=='#'){ |
if(model[0]=='#'){ |
Line 6457 int main(int argc, char *argv[])
|
Line 6778 int main(int argc, char *argv[])
|
ungetc(c,ficpar); |
ungetc(c,ficpar); |
fgets(line, MAXLINE, ficpar); |
fgets(line, MAXLINE, ficpar); |
numlinepar++; |
numlinepar++; |
|
if(line[1]=='q'){ /* This #q will quit imach (the answer is q) */ |
|
z[0]=line[1]; |
|
} |
|
/* printf("****line [1] = %c \n",line[1]); */ |
fputs(line, stdout); |
fputs(line, stdout); |
//puts(line); |
//puts(line); |
fputs(line,ficparo); |
fputs(line,ficparo); |
Line 6498 int main(int argc, char *argv[])
|
Line 6823 int main(int argc, char *argv[])
|
} |
} |
else if(mle==-3) { /* Main Wizard */ |
else if(mle==-3) { /* Main Wizard */ |
prwizard(ncovmodel, nlstate, ndeath, model, ficparo); |
prwizard(ncovmodel, nlstate, ndeath, model, ficparo); |
printf(" You choose mle=-3, look at file %s for a template of covariance matrix \n",filereso); |
printf(" You chose mle=-3, look at file %s for a template of covariance matrix \n",filereso); |
fprintf(ficlog," You choose mle=-3, look at file %s for a template of covariance matrix \n",filereso); |
fprintf(ficlog," You chose mle=-3, look at file %s for a template of covariance matrix \n",filereso); |
param= ma3x(1,nlstate,1,nlstate+ndeath-1,1,ncovmodel); |
param= ma3x(1,nlstate,1,nlstate+ndeath-1,1,ncovmodel); |
matcov=matrix(1,npar,1,npar); |
matcov=matrix(1,npar,1,npar); |
} |
} |
Line 6523 int main(int argc, char *argv[])
|
Line 6848 int main(int argc, char *argv[])
|
if(jj==i) continue; |
if(jj==i) continue; |
j++; |
j++; |
fscanf(ficpar,"%1d%1d",&i1,&j1); |
fscanf(ficpar,"%1d%1d",&i1,&j1); |
if ((i1 != i) && (j1 != j)){ |
if ((i1 != i) || (j1 != jj)){ |
printf("Error in line parameters number %d, %1d%1d instead of %1d%1d \n \ |
printf("Error in line parameters number %d, %1d%1d instead of %1d%1d \n \ |
It might be a problem of design; if ncovcol and the model are correct\n \ |
It might be a problem of design; if ncovcol and the model are correct\n \ |
run imach with mle=-1 to get a correct template of the parameter file.\n",numlinepar, i,j, i1, j1); |
run imach with mle=-1 to get a correct template of the parameter file.\n",numlinepar, i,j, i1, j1); |
Line 6531 run imach with mle=-1 to get a correct t
|
Line 6856 run imach with mle=-1 to get a correct t
|
} |
} |
fprintf(ficparo,"%1d%1d",i1,j1); |
fprintf(ficparo,"%1d%1d",i1,j1); |
if(mle==1) |
if(mle==1) |
printf("%1d%1d",i,j); |
printf("%1d%1d",i,jj); |
fprintf(ficlog,"%1d%1d",i,j); |
fprintf(ficlog,"%1d%1d",i,jj); |
for(k=1; k<=ncovmodel;k++){ |
for(k=1; k<=ncovmodel;k++){ |
fscanf(ficpar," %lf",¶m[i][j][k]); |
fscanf(ficpar," %lf",¶m[i][j][k]); |
if(mle==1){ |
if(mle==1){ |
Line 6613 run imach with mle=-1 to get a correct t
|
Line 6938 run imach with mle=-1 to get a correct t
|
for(i=1; i <=npar; i++) |
for(i=1; i <=npar; i++) |
for(j=1; j <=npar; j++) matcov[i][j]=0.; |
for(j=1; j <=npar; j++) matcov[i][j]=0.; |
|
|
|
/* Scans npar lines */ |
for(i=1; i <=npar; i++){ |
for(i=1; i <=npar; i++){ |
fscanf(ficpar,"%s",str); |
count=fscanf(ficpar,"%1d%1d%1d",&i1,&j1,&jk); |
|
if(count != 3){ |
|
printf("Error! Error in parameter file %s at line %d after line starting with %1d%1d%1d\n\ |
|
This is probably because your covariance matrix doesn't \n contain exactly %d lines corresponding to your model line '1+age+%s'.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",optionfile,numlinepar, i1,j1,jk, npar, model); |
|
fprintf(ficlog,"Error! Error in parameter file %s at line %d after line starting with %1d%1d%1d\n\ |
|
This is probably because your covariance matrix doesn't \n contain exactly %d lines corresponding to your model line '1+age+%s'.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",optionfile,numlinepar, i1,j1,jk, npar, model); |
|
exit(1); |
|
}else |
if(mle==1) |
if(mle==1) |
printf("%s",str); |
printf("%1d%1d%1d",i1,j1,jk); |
fprintf(ficlog,"%s",str); |
fprintf(ficlog,"%1d%1d%1d",i1,j1,jk); |
fprintf(ficparo,"%s",str); |
fprintf(ficparo,"%1d%1d%1d",i1,j1,jk); |
for(j=1; j <=i; j++){ |
for(j=1; j <=i; j++){ |
fscanf(ficpar," %le",&matcov[i][j]); |
fscanf(ficpar," %le",&matcov[i][j]); |
if(mle==1){ |
if(mle==1){ |
Line 6634 run imach with mle=-1 to get a correct t
|
Line 6969 run imach with mle=-1 to get a correct t
|
fprintf(ficlog,"\n"); |
fprintf(ficlog,"\n"); |
fprintf(ficparo,"\n"); |
fprintf(ficparo,"\n"); |
} |
} |
|
/* End of read covariance matrix npar lines */ |
for(i=1; i <=npar; i++) |
for(i=1; i <=npar; i++) |
for(j=i+1;j<=npar;j++) |
for(j=i+1;j<=npar;j++) |
matcov[i][j]=matcov[j][i]; |
matcov[i][j]=matcov[j][i]; |
Line 6650 run imach with mle=-1 to get a correct t
|
Line 6986 run imach with mle=-1 to get a correct t
|
strcat(rfileres,"."); /* */ |
strcat(rfileres,"."); /* */ |
strcat(rfileres,optionfilext); /* Other files have txt extension */ |
strcat(rfileres,optionfilext); /* Other files have txt extension */ |
if((ficres =fopen(rfileres,"w"))==NULL) { |
if((ficres =fopen(rfileres,"w"))==NULL) { |
printf("Problem writing new parameter file: %s\n", fileres);goto end; |
printf("Problem writing new parameter file: %s\n", rfileres);goto end; |
fprintf(ficlog,"Problem writing new parameter file: %s\n", fileres);goto end; |
fprintf(ficlog,"Problem writing new parameter file: %s\n", rfileres);goto end; |
} |
} |
fprintf(ficres,"#%s\n",version); |
fprintf(ficres,"#%s\n",version); |
} /* End of mle != -3 */ |
} /* End of mle != -3 */ |
Line 6673 run imach with mle=-1 to get a correct t
|
Line 7009 run imach with mle=-1 to get a correct t
|
s=imatrix(1,maxwav+1,1,n); /* s[i][j] health state for wave i and individual j */ |
s=imatrix(1,maxwav+1,1,n); /* s[i][j] health state for wave i and individual j */ |
tab=ivector(1,NCOVMAX); |
tab=ivector(1,NCOVMAX); |
ncodemax=ivector(1,NCOVMAX); /* Number of code per covariate; if O and 1 only, 2**ncov; V1+V2+V3+V4=>16 */ |
ncodemax=ivector(1,NCOVMAX); /* Number of code per covariate; if O and 1 only, 2**ncov; V1+V2+V3+V4=>16 */ |
|
ncodemaxwundef=ivector(1,NCOVMAX); /* Number of code per covariate; if - 1 O and 1 only, 2**ncov; V1+V2+V3+V4=>16 */ |
|
|
/* Reads data from file datafile */ |
/* Reads data from file datafile */ |
if (readdata(datafile, firstobs, lastobs, &imx)==1) |
if (readdata(datafile, firstobs, lastobs, &imx)==1) |
Line 6760 run imach with mle=-1 to get a correct t
|
Line 7097 run imach with mle=-1 to get a correct t
|
V2+V1*age, there are 3 covariates Tvar[2]=1 (V1).*/ |
V2+V1*age, there are 3 covariates Tvar[2]=1 (V1).*/ |
/* 1 to ncodemax[j] is the maximum value of this jth covariate */ |
/* 1 to ncodemax[j] is the maximum value of this jth covariate */ |
|
|
codtab=imatrix(1,100,1,10); /* codtab[h,k]=( (h-1) - mod(k-1,2**(k-1) )/2**(k-1) */ |
/* codtab=imatrix(1,100,1,10);*/ /* codtab[h,k]=( (h-1) - mod(k-1,2**(k-1) )/2**(k-1) */ |
/*printf(" codtab[1,1],codtab[100,10]=%d,%d\n", codtab[1][1],codtab[100][10]);*/ |
/*printf(" codtab[1,1],codtab[100,10]=%d,%d\n", codtab[1][1],codtabm(100,10));*/ |
/* codtab gives the value 1 or 2 of the hth combination of k covariates (1 or 2).*/ |
/* codtab gives the value 1 or 2 of the hth combination of k covariates (1 or 2).*/ |
h=0; |
h=0; |
|
|
Line 6771 run imach with mle=-1 to get a correct t
|
Line 7108 run imach with mle=-1 to get a correct t
|
|
|
m=pow(2,cptcoveff); |
m=pow(2,cptcoveff); |
|
|
for(k=1;k<=cptcoveff; k++){ /* scans any effective covariate */ |
|
for(i=1; i <=pow(2,cptcoveff-k);i++){ /* i=1 to 8/1=8; i=1 to 8/2=4; i=1 to 8/8=1 */ |
|
for(j=1; j <= ncodemax[k]; j++){ /* For each modality of this covariate ncodemax=2*/ |
|
for(cpt=1; cpt <=pow(2,k-1); cpt++){ /* cpt=1 to 8/2**(3+1-1 or 3+1-3) =1 or 4 */ |
|
h++; |
|
if (h>m) |
|
h=1; |
|
/**< codtab(h,k) k = codtab[h,k]=( (h-1) - mod(k-1,2**(k-1) )/2**(k-1) + 1 |
/**< codtab(h,k) k = codtab[h,k]=( (h-1) - mod(k-1,2**(k-1) )/2**(k-1) + 1 |
* For k=4 covariates, h goes from 1 to 2**k |
* For k=4 covariates, h goes from 1 to 2**k |
* codtabm(h,k)= 1 & (h-1) >> (k-1) ; |
* codtabm(h,k)= 1 & (h-1) >> (k-1) ; |
Line 6791 run imach with mle=-1 to get a correct t
|
Line 7121 run imach with mle=-1 to get a correct t
|
* 6 2 1 2 1 |
* 6 2 1 2 1 |
* 7 i=4 1 2 2 1 |
* 7 i=4 1 2 2 1 |
* 8 2 2 2 1 |
* 8 2 2 2 1 |
* 9 i=5 1 i=3 1 i=2 1 1 |
* 9 i=5 1 i=3 1 i=2 1 2 |
* 10 2 1 1 1 |
* 10 2 1 1 2 |
* 11 i=6 1 2 1 1 |
* 11 i=6 1 2 1 2 |
* 12 2 2 1 1 |
* 12 2 2 1 2 |
* 13 i=7 1 i=4 1 2 1 |
* 13 i=7 1 i=4 1 2 2 |
* 14 2 1 2 1 |
* 14 2 1 2 2 |
* 15 i=8 1 2 2 1 |
* 15 i=8 1 2 2 2 |
* 16 2 2 2 1 |
* 16 2 2 2 2 |
*/ |
*/ |
codtab[h][k]=j; |
/* /\* for(h=1; h <=100 ;h++){ *\/ */ |
/* codtab[12][3]=1; */ |
/* /\* printf("h=%2d ", h); *\/ */ |
/*codtab[h][Tvar[k]]=j;*/ |
/* /\* for(k=1; k <=10; k++){ *\/ */ |
printf("h=%d k=%d j=%d codtab[h][k]=%d Tvar[k]=%d codtab[h][Tvar[k]]=%d \n",h, k,j,codtab[h][k],Tvar[k],codtab[h][Tvar[k]]); |
/* /\* printf("k=%d %d ",k,codtabm(h,k)); *\/ */ |
} |
/* /\* codtab[h][k]=codtabm(h,k); *\/ */ |
} |
/* /\* } *\/ */ |
} |
/* /\* printf("\n"); *\/ */ |
} |
/* } */ |
|
/* for(k=1;k<=cptcoveff; k++){ /\* scans any effective covariate *\/ */ |
|
/* for(i=1; i <=pow(2,cptcoveff-k);i++){ /\* i=1 to 8/1=8; i=1 to 8/2=4; i=1 to 8/8=1 *\/ */ |
|
/* for(j=1; j <= ncodemax[k]; j++){ /\* For each modality of this covariate ncodemax=2*\/ */ |
|
/* for(cpt=1; cpt <=pow(2,k-1); cpt++){ /\* cpt=1 to 8/2**(3+1-1 or 3+1-3) =1 or 4 *\/ */ |
|
/* h++; */ |
|
/* if (h>m) */ |
|
/* h=1; */ |
|
/* codtab[h][k]=j; */ |
|
/* /\* codtab[12][3]=1; *\/ */ |
|
/* /\*codtab[h][Tvar[k]]=j;*\/ */ |
|
/* /\* printf("h=%d k=%d j=%d codtab[h][k]=%d Tvar[k]=%d codtab[h][Tvar[k]]=%d \n",h, k,j,codtab[h][k],Tvar[k],codtab[h][Tvar[k]]); *\/ */ |
|
/* } */ |
|
/* } */ |
|
/* } */ |
|
/* } */ |
/* printf("codtab[1][2]=%d codtab[2][2]=%d",codtab[1][2],codtab[2][2]); |
/* printf("codtab[1][2]=%d codtab[2][2]=%d",codtab[1][2],codtab[2][2]); |
codtab[1][2]=1;codtab[2][2]=2; */ |
codtab[1][2]=1;codtab[2][2]=2; */ |
/* for(i=1; i <=m ;i++){ |
/* for(i=1; i <=m ;i++){ */ |
for(k=1; k <=cptcovn; k++){ |
/* for(k=1; k <=cptcovn; k++){ */ |
printf("i=%d k=%d %d %d ",i,k,codtab[i][k], cptcoveff); |
/* printf("i=%d k=%d %d %d ",i,k,codtab[i][k], cptcoveff); */ |
} |
/* } */ |
printf("\n"); |
/* printf("\n"); */ |
} |
/* } */ |
scanf("%d",i);*/ |
/* scanf("%d",i);*/ |
|
|
free_ivector(Ndum,-1,NCOVMAX); |
free_ivector(Ndum,-1,NCOVMAX); |
|
|
Line 6825 run imach with mle=-1 to get a correct t
|
Line 7170 run imach with mle=-1 to get a correct t
|
/* Initialisation of ----------- gnuplot -------------*/ |
/* Initialisation of ----------- gnuplot -------------*/ |
strcpy(optionfilegnuplot,optionfilefiname); |
strcpy(optionfilegnuplot,optionfilefiname); |
if(mle==-3) |
if(mle==-3) |
strcat(optionfilegnuplot,"-mort"); |
strcat(optionfilegnuplot,"-MORT_"); |
strcat(optionfilegnuplot,".gp"); |
strcat(optionfilegnuplot,".gp"); |
|
|
if((ficgp=fopen(optionfilegnuplot,"w"))==NULL) { |
if((ficgp=fopen(optionfilegnuplot,"w"))==NULL) { |
Line 6844 run imach with mle=-1 to get a correct t
|
Line 7189 run imach with mle=-1 to get a correct t
|
|
|
strcpy(optionfilehtm,optionfilefiname); /* Main html file */ |
strcpy(optionfilehtm,optionfilefiname); /* Main html file */ |
if(mle==-3) |
if(mle==-3) |
strcat(optionfilehtm,"-mort"); |
strcat(optionfilehtm,"-MORT_"); |
strcat(optionfilehtm,".htm"); |
strcat(optionfilehtm,".htm"); |
if((fichtm=fopen(optionfilehtm,"w"))==NULL) { |
if((fichtm=fopen(optionfilehtm,"w"))==NULL) { |
printf("Problem with %s \n",optionfilehtm); |
printf("Problem with %s \n",optionfilehtm); |
Line 6960 Interval (in months) between two waves:
|
Line 7305 Interval (in months) between two waves:
|
#else |
#else |
printf("Powell\n"); fprintf(ficlog,"Powell\n"); |
printf("Powell\n"); fprintf(ficlog,"Powell\n"); |
#endif |
#endif |
strcpy(filerespow,"pow-mort"); |
strcpy(filerespow,"POW-MORT_"); |
strcat(filerespow,fileres); |
strcat(filerespow,fileresu); |
if((ficrespow=fopen(filerespow,"w"))==NULL) { |
if((ficrespow=fopen(filerespow,"w"))==NULL) { |
printf("Problem with resultfile: %s\n", filerespow); |
printf("Problem with resultfile: %s\n", filerespow); |
fprintf(ficlog,"Problem with resultfile: %s\n", filerespow); |
fprintf(ficlog,"Problem with resultfile: %s\n", filerespow); |
Line 7072 Interval (in months) between two waves:
|
Line 7417 Interval (in months) between two waves:
|
} |
} |
|
|
printf("iter=%d MLE=%f Eq=%lf*exp(%lf*(age-%d))\n",iter,-gompertz(p),p[1],p[2],agegomp); |
printf("iter=%d MLE=%f Eq=%lf*exp(%lf*(age-%d))\n",iter,-gompertz(p),p[1],p[2],agegomp); |
for (i=1;i<=NDIM;i++) |
for (i=1;i<=NDIM;i++) { |
printf("%f [%f ; %f]\n",p[i],p[i]-2*sqrt(matcov[i][i]),p[i]+2*sqrt(matcov[i][i])); |
printf("%f [%f ; %f]\n",p[i],p[i]-2*sqrt(matcov[i][i]),p[i]+2*sqrt(matcov[i][i])); |
|
fprintf(ficlog,"%f [%f ; %f]\n",p[i],p[i]-2*sqrt(matcov[i][i]),p[i]+2*sqrt(matcov[i][i])); |
|
} |
lsurv=vector(1,AGESUP); |
lsurv=vector(1,AGESUP); |
lpop=vector(1,AGESUP); |
lpop=vector(1,AGESUP); |
tpop=vector(1,AGESUP); |
tpop=vector(1,AGESUP); |
Line 7106 Interval (in months) between two waves:
|
Line 7452 Interval (in months) between two waves:
|
|
|
|
|
replace_back_to_slash(pathc,pathcd); /* Even gnuplot wants a / */ |
replace_back_to_slash(pathc,pathcd); /* Even gnuplot wants a / */ |
printinggnuplotmort(fileres, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
if(ageminpar == AGEOVERFLOW ||agemaxpar == AGEOVERFLOW){ |
|
printf("Warning! Error in gnuplot file with ageminpar %f or agemaxpar %f overflow\n\ |
printinghtmlmort(fileres,title,datafile, firstpass, lastpass, \ |
This is probably because your parameter file doesn't \n contain the exact number of lines (or columns) corresponding to your model line.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",ageminpar,agemaxpar); |
|
fprintf(ficlog,"Warning! Error in gnuplot file with ageminpar %f or agemaxpar %f overflow\n\ |
|
This is probably because your parameter file doesn't \n contain the exact number of lines (or columns) corresponding to your model line.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",ageminpar,agemaxpar); |
|
}else |
|
printinggnuplotmort(fileresu, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
|
printinghtmlmort(fileresu,title,datafile, firstpass, lastpass, \ |
stepm, weightopt,\ |
stepm, weightopt,\ |
model,imx,p,matcov,agemortsup); |
model,imx,p,matcov,agemortsup); |
|
|
Line 7142 Interval (in months) between two waves:
|
Line 7495 Interval (in months) between two waves:
|
} |
} |
|
|
/*--------- results files --------------*/ |
/*--------- results files --------------*/ |
fprintf(ficres,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle= 0 weight=%d\nmodel=1+age+%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nlstate, ndeath, maxwav, weightopt,model); |
fprintf(ficres,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle= 0 weight=%d\nmodel=1+age+%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nlstate, ndeath, maxwav, weightopt,model); |
|
|
|
|
fprintf(ficres,"# Parameters nlstate*nlstate*ncov a12*1 + b12 * age + ...\n"); |
fprintf(ficres,"# Parameters nlstate*nlstate*ncov a12*1 + b12 * age + ...\n"); |
Line 7171 Interval (in months) between two waves:
|
Line 7524 Interval (in months) between two waves:
|
ftolhess=ftol; /* Usually correct */ |
ftolhess=ftol; /* Usually correct */ |
hesscov(matcov, p, npar, delti, ftolhess, func); |
hesscov(matcov, p, npar, delti, ftolhess, func); |
} |
} |
|
printf("Parameters and 95%% confidence intervals\n W is simply the result of the division of the parameter by the square root of covariance of the parameter.\n And Wald-based confidence intervals plus and minus 1.96 * W .\n But be careful that parameters are highly correlated because incidence of disability is highly correlated to incidence of recovery.\n It might be better to visualize the covariance matrix. See the page 'Matrix of variance-covariance of one-step probabilities' and its graphs.\n"); |
|
fprintf(ficlog, "Parameters, Wald tests and Wald-based confidence intervals\n W is simply the result of the division of the parameter by the square root of covariance of the parameter.\n And Wald-based confidence intervals plus and minus 1.96 * W \n It might be better to visualize the covariance matrix. See the page 'Matrix of variance-covariance of one-step probabilities' and its graphs.\n"); |
|
for(i=1,jk=1; i <=nlstate; i++){ |
|
for(k=1; k <=(nlstate+ndeath); k++){ |
|
if (k != i) { |
|
printf("%d%d ",i,k); |
|
fprintf(ficlog,"%d%d ",i,k); |
|
for(j=1; j <=ncovmodel; j++){ |
|
printf("%12.7f W=%8.3f CI=[%12.7f ; %12.7f] ",p[jk], p[jk]/sqrt(matcov[jk][jk]), p[jk]-1.96*sqrt(matcov[jk][jk]),p[jk]+1.96*sqrt(matcov[jk][jk])); |
|
fprintf(ficlog,"%12.7f W=%8.3f CI=[%12.7f ; %12.7f] ",p[jk], p[jk]/sqrt(matcov[jk][jk]), p[jk]-1.96*sqrt(matcov[jk][jk]),p[jk]+1.96*sqrt(matcov[jk][jk])); |
|
jk++; |
|
} |
|
printf("\n"); |
|
fprintf(ficlog,"\n"); |
|
} |
|
} |
|
} |
|
|
fprintf(ficres,"# Scales (for hessian or gradient estimation)\n"); |
fprintf(ficres,"# Scales (for hessian or gradient estimation)\n"); |
printf("# Scales (for hessian or gradient estimation)\n"); |
printf("# Scales (for hessian or gradient estimation)\n"); |
fprintf(ficlog,"# Scales (for hessian or gradient estimation)\n"); |
fprintf(ficlog,"# Scales (for hessian or gradient estimation)\n"); |
Line 7327 Interval (in months) between two waves:
|
Line 7698 Interval (in months) between two waves:
|
dateprev2=anprev2+(mprev2-1)/12.+(jprev2-1)/365.; |
dateprev2=anprev2+(mprev2-1)/12.+(jprev2-1)/365.; |
|
|
fscanf(ficpar,"pop_based=%d\n",&popbased); |
fscanf(ficpar,"pop_based=%d\n",&popbased); |
|
fprintf(ficlog,"pop_based=%d\n",popbased); |
fprintf(ficparo,"pop_based=%d\n",popbased); |
fprintf(ficparo,"pop_based=%d\n",popbased); |
fprintf(ficres,"pop_based=%d\n",popbased); |
fprintf(ficres,"pop_based=%d\n",popbased); |
|
|
Line 7351 Interval (in months) between two waves:
|
Line 7723 Interval (in months) between two waves:
|
/* ,dateprev1,dateprev2,jprev1, mprev1,anprev1,jprev2, mprev2,anprev2); */ |
/* ,dateprev1,dateprev2,jprev1, mprev1,anprev1,jprev2, mprev2,anprev2); */ |
|
|
replace_back_to_slash(pathc,pathcd); /* Even gnuplot wants a / */ |
replace_back_to_slash(pathc,pathcd); /* Even gnuplot wants a / */ |
printinggnuplot(fileres, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
if(ageminpar == AGEOVERFLOW ||agemaxpar == -AGEOVERFLOW){ |
|
printf("Warning! Error in gnuplot file with ageminpar %f or agemaxpar %f overflow\n\ |
|
This is probably because your parameter file doesn't \n contain the exact number of lines (or columns) corresponding to your model line.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",ageminpar,agemaxpar); |
|
fprintf(ficlog,"Warning! Error in gnuplot file with ageminpar %f or agemaxpar %f overflow\n\ |
|
This is probably because your parameter file doesn't \n contain the exact number of lines (or columns) corresponding to your model line.\n\ |
|
Please run with mle=-1 to get a correct covariance matrix.\n",ageminpar,agemaxpar); |
|
}else |
|
printinggnuplot(fileresu, optionfilefiname,ageminpar,agemaxpar,fage, pathc,p); |
|
|
printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,\ |
printinghtml(fileresu,title,datafile, firstpass, lastpass, stepm, weightopt,\ |
model,imx,jmin,jmax,jmean,rfileres,popforecast,estepm,\ |
model,imx,jmin,jmax,jmean,rfileres,popforecast,estepm,\ |
jprev1,mprev1,anprev1,jprev2,mprev2,anprev2); |
jprev1,mprev1,anprev1,jprev2,mprev2,anprev2); |
|
|
Line 7378 Interval (in months) between two waves:
|
Line 7758 Interval (in months) between two waves:
|
/*--------------- Prevalence limit (period or stable prevalence) --------------*/ |
/*--------------- Prevalence limit (period or stable prevalence) --------------*/ |
/*#include "prevlim.h"*/ /* Use ficrespl, ficlog */ |
/*#include "prevlim.h"*/ /* Use ficrespl, ficlog */ |
prlim=matrix(1,nlstate,1,nlstate); |
prlim=matrix(1,nlstate,1,nlstate); |
prevalence_limit(p, prlim, ageminpar, agemaxpar); |
prevalence_limit(p, prlim, ageminpar, agemaxpar, ftolpl); |
fclose(ficrespl); |
fclose(ficrespl); |
|
|
#ifdef FREEEXIT2 |
#ifdef FREEEXIT2 |
Line 7405 Interval (in months) between two waves:
|
Line 7785 Interval (in months) between two waves:
|
/*if((stepm == 1) && (strcmp(model,".")==0)){*/ |
/*if((stepm == 1) && (strcmp(model,".")==0)){*/ |
if(prevfcast==1){ |
if(prevfcast==1){ |
/* if(stepm ==1){*/ |
/* if(stepm ==1){*/ |
prevforecast(fileres, anproj1, mproj1, jproj1, agemin, agemax, dateprev1, dateprev2, mobilavproj, bage, fage, firstpass, lastpass, anproj2, p, cptcoveff); |
prevforecast(fileresu, anproj1, mproj1, jproj1, agemin, agemax, dateprev1, dateprev2, mobilavproj, bage, fage, firstpass, lastpass, anproj2, p, cptcoveff); |
/* (popforecast==1) populforecast(fileres, anpyram,mpyram,jpyram, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anpyram1,p, i1);*/ |
/* (popforecast==1) populforecast(fileres, anpyram,mpyram,jpyram, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anpyram1,p, i1);*/ |
/* } */ |
/* } */ |
/* else{ */ |
/* else{ */ |
Line 7435 Interval (in months) between two waves:
|
Line 7815 Interval (in months) between two waves:
|
|
|
/*---------- Health expectancies, no variances ------------*/ |
/*---------- Health expectancies, no variances ------------*/ |
|
|
strcpy(filerese,"e"); |
strcpy(filerese,"E_"); |
strcat(filerese,fileres); |
strcat(filerese,fileresu); |
if((ficreseij=fopen(filerese,"w"))==NULL) { |
if((ficreseij=fopen(filerese,"w"))==NULL) { |
printf("Problem with Health Exp. resultfile: %s\n", filerese); exit(0); |
printf("Problem with Health Exp. resultfile: %s\n", filerese); exit(0); |
fprintf(ficlog,"Problem with Health Exp. resultfile: %s\n", filerese); exit(0); |
fprintf(ficlog,"Problem with Health Exp. resultfile: %s\n", filerese); exit(0); |
Line 7449 Interval (in months) between two waves:
|
Line 7829 Interval (in months) between two waves:
|
for (k=1; k <= (int) pow(2,cptcoveff); k++){ |
for (k=1; k <= (int) pow(2,cptcoveff); k++){ |
fprintf(ficreseij,"\n#****** "); |
fprintf(ficreseij,"\n#****** "); |
for(j=1;j<=cptcoveff;j++) { |
for(j=1;j<=cptcoveff;j++) { |
fprintf(ficreseij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficreseij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
} |
} |
fprintf(ficreseij,"******\n"); |
fprintf(ficreseij,"******\n"); |
|
|
Line 7466 Interval (in months) between two waves:
|
Line 7846 Interval (in months) between two waves:
|
/*---------- Health expectancies and variances ------------*/ |
/*---------- Health expectancies and variances ------------*/ |
|
|
|
|
strcpy(filerest,"t"); |
strcpy(filerest,"T_"); |
strcat(filerest,fileres); |
strcat(filerest,fileresu); |
if((ficrest=fopen(filerest,"w"))==NULL) { |
if((ficrest=fopen(filerest,"w"))==NULL) { |
printf("Problem with total LE resultfile: %s\n", filerest);goto end; |
printf("Problem with total LE resultfile: %s\n", filerest);goto end; |
fprintf(ficlog,"Problem with total LE resultfile: %s\n", filerest);goto end; |
fprintf(ficlog,"Problem with total LE resultfile: %s\n", filerest);goto end; |
Line 7476 Interval (in months) between two waves:
|
Line 7856 Interval (in months) between two waves:
|
fprintf(ficlog,"Computing Total Life expectancies with their standard errors: file '%s' \n", filerest); |
fprintf(ficlog,"Computing Total Life expectancies with their standard errors: file '%s' \n", filerest); |
|
|
|
|
strcpy(fileresstde,"stde"); |
strcpy(fileresstde,"STDE_"); |
strcat(fileresstde,fileres); |
strcat(fileresstde,fileresu); |
if((ficresstdeij=fopen(fileresstde,"w"))==NULL) { |
if((ficresstdeij=fopen(fileresstde,"w"))==NULL) { |
printf("Problem with Health Exp. and std errors resultfile: %s\n", fileresstde); exit(0); |
printf("Problem with Health Exp. and std errors resultfile: %s\n", fileresstde); exit(0); |
fprintf(ficlog,"Problem with Health Exp. and std errors resultfile: %s\n", fileresstde); exit(0); |
fprintf(ficlog,"Problem with Health Exp. and std errors resultfile: %s\n", fileresstde); exit(0); |
Line 7485 Interval (in months) between two waves:
|
Line 7865 Interval (in months) between two waves:
|
printf("Computing Health Expectancies and standard errors: result on file '%s' \n", fileresstde); |
printf("Computing Health Expectancies and standard errors: result on file '%s' \n", fileresstde); |
fprintf(ficlog,"Computing Health Expectancies and standard errors: result on file '%s' \n", fileresstde); |
fprintf(ficlog,"Computing Health Expectancies and standard errors: result on file '%s' \n", fileresstde); |
|
|
strcpy(filerescve,"cve"); |
strcpy(filerescve,"CVE_"); |
strcat(filerescve,fileres); |
strcat(filerescve,fileresu); |
if((ficrescveij=fopen(filerescve,"w"))==NULL) { |
if((ficrescveij=fopen(filerescve,"w"))==NULL) { |
printf("Problem with Covar. Health Exp. resultfile: %s\n", filerescve); exit(0); |
printf("Problem with Covar. Health Exp. resultfile: %s\n", filerescve); exit(0); |
fprintf(ficlog,"Problem with Covar. Health Exp. resultfile: %s\n", filerescve); exit(0); |
fprintf(ficlog,"Problem with Covar. Health Exp. resultfile: %s\n", filerescve); exit(0); |
Line 7494 Interval (in months) between two waves:
|
Line 7874 Interval (in months) between two waves:
|
printf("Computing Covar. of Health Expectancies: result on file '%s' \n", filerescve); |
printf("Computing Covar. of Health Expectancies: result on file '%s' \n", filerescve); |
fprintf(ficlog,"Computing Covar. of Health Expectancies: result on file '%s' \n", filerescve); |
fprintf(ficlog,"Computing Covar. of Health Expectancies: result on file '%s' \n", filerescve); |
|
|
strcpy(fileresv,"v"); |
strcpy(fileresv,"V_"); |
strcat(fileresv,fileres); |
strcat(fileresv,fileresu); |
if((ficresvij=fopen(fileresv,"w"))==NULL) { |
if((ficresvij=fopen(fileresv,"w"))==NULL) { |
printf("Problem with variance resultfile: %s\n", fileresv);exit(0); |
printf("Problem with variance resultfile: %s\n", fileresv);exit(0); |
fprintf(ficlog,"Problem with variance resultfile: %s\n", fileresv);exit(0); |
fprintf(ficlog,"Problem with variance resultfile: %s\n", fileresv);exit(0); |
Line 7509 Interval (in months) between two waves:
|
Line 7889 Interval (in months) between two waves:
|
for (k=1; k <= (int) pow(2,cptcoveff); k++){ |
for (k=1; k <= (int) pow(2,cptcoveff); k++){ |
fprintf(ficrest,"\n#****** "); |
fprintf(ficrest,"\n#****** "); |
for(j=1;j<=cptcoveff;j++) |
for(j=1;j<=cptcoveff;j++) |
fprintf(ficrest,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficrest,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
fprintf(ficrest,"******\n"); |
fprintf(ficrest,"******\n"); |
|
|
fprintf(ficresstdeij,"\n#****** "); |
fprintf(ficresstdeij,"\n#****** "); |
fprintf(ficrescveij,"\n#****** "); |
fprintf(ficrescveij,"\n#****** "); |
for(j=1;j<=cptcoveff;j++) { |
for(j=1;j<=cptcoveff;j++) { |
fprintf(ficresstdeij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficresstdeij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
fprintf(ficrescveij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficrescveij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
} |
} |
fprintf(ficresstdeij,"******\n"); |
fprintf(ficresstdeij,"******\n"); |
fprintf(ficrescveij,"******\n"); |
fprintf(ficrescveij,"******\n"); |
|
|
fprintf(ficresvij,"\n#****** "); |
fprintf(ficresvij,"\n#****** "); |
for(j=1;j<=cptcoveff;j++) |
for(j=1;j<=cptcoveff;j++) |
fprintf(ficresvij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficresvij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
fprintf(ficresvij,"******\n"); |
fprintf(ficresvij,"******\n"); |
|
|
eij=ma3x(1,nlstate,1,nlstate,(int) bage, (int) fage); |
eij=ma3x(1,nlstate,1,nlstate,(int) bage, (int) fage); |
Line 7538 Interval (in months) between two waves:
|
Line 7918 Interval (in months) between two waves:
|
|
|
|
|
for(vpopbased=0; vpopbased <= popbased; vpopbased++){ /* Done for vpopbased=0 and vpopbased=1 if popbased==1*/ |
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 */ |
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 */ |
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 "); |
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 "); |
Line 7546 Interval (in months) between two waves:
|
Line 7926 Interval (in months) between two waves:
|
fprintf(ficrest,"the age specific prevalence observed (cross-sectionally) in the population i.e cross-sectionally\n in each health state (popbased=1) (mobilav=%d)\n",mobilav); |
fprintf(ficrest,"the age specific prevalence observed (cross-sectionally) in the population i.e cross-sectionally\n in each health state (popbased=1) (mobilav=%d)\n",mobilav); |
else |
else |
fprintf(ficrest,"the age specific period (stable) prevalences in each health state \n"); |
fprintf(ficrest,"the age specific period (stable) prevalences in each health state \n"); |
fprintf(ficrest,"# Age e.. (std) "); |
fprintf(ficrest,"# Age popbased mobilav e.. (std) "); |
for (i=1;i<=nlstate;i++) fprintf(ficrest,"e.%d (std) ",i); |
for (i=1;i<=nlstate;i++) fprintf(ficrest,"e.%d (std) ",i); |
fprintf(ficrest,"\n"); |
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); |
epj=vector(1,nlstate+1); |
for(age=bage; age <=fage ;age++){ |
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 (vpopbased==1) { |
if(mobilav ==0){ |
if(mobilav ==0){ |
for(i=1; i<=nlstate;i++) |
for(i=1; i<=nlstate;i++) |
Line 7563 Interval (in months) between two waves:
|
Line 7943 Interval (in months) between two waves:
|
} |
} |
} |
} |
|
|
fprintf(ficrest," %4.0f",age); |
fprintf(ficrest," %4.0f %d %d",age, vpopbased, mobilav); |
|
/* printf(" age %4.0f ",age); */ |
for(j=1, epj[nlstate+1]=0.;j <=nlstate;j++){ |
for(j=1, epj[nlstate+1]=0.;j <=nlstate;j++){ |
for(i=1, epj[j]=0.;i <=nlstate;i++) { |
for(i=1, epj[j]=0.;i <=nlstate;i++) { |
epj[j] += prlim[i][i]*eij[i][j][(int)age]; |
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]; |
epj[nlstate+1] +=epj[j]; |
} |
} |
|
/* printf(" age %4.0f \n",age); */ |
|
|
for(i=1, vepp=0.;i <=nlstate;i++) |
for(i=1, vepp=0.;i <=nlstate;i++) |
for(j=1;j <=nlstate;j++) |
for(j=1;j <=nlstate;j++) |
Line 7602 Interval (in months) between two waves:
|
Line 7985 Interval (in months) between two waves:
|
|
|
/*------- Variance of period (stable) prevalence------*/ |
/*------- Variance of period (stable) prevalence------*/ |
|
|
strcpy(fileresvpl,"vpl"); |
strcpy(fileresvpl,"VPL_"); |
strcat(fileresvpl,fileres); |
strcat(fileresvpl,fileresu); |
if((ficresvpl=fopen(fileresvpl,"w"))==NULL) { |
if((ficresvpl=fopen(fileresvpl,"w"))==NULL) { |
printf("Problem with variance of period (stable) prevalence resultfile: %s\n", fileresvpl); |
printf("Problem with variance of period (stable) prevalence resultfile: %s\n", fileresvpl); |
exit(0); |
exit(0); |
Line 7616 Interval (in months) between two waves:
|
Line 7999 Interval (in months) between two waves:
|
for (k=1; k <= (int) pow(2,cptcoveff); k++){ |
for (k=1; k <= (int) pow(2,cptcoveff); k++){ |
fprintf(ficresvpl,"\n#****** "); |
fprintf(ficresvpl,"\n#****** "); |
for(j=1;j<=cptcoveff;j++) |
for(j=1;j<=cptcoveff;j++) |
fprintf(ficresvpl,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]); |
fprintf(ficresvpl,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,j)]); |
fprintf(ficresvpl,"******\n"); |
fprintf(ficresvpl,"******\n"); |
|
|
varpl=matrix(1,nlstate,(int) bage, (int) fage); |
varpl=matrix(1,nlstate,(int) bage, (int) fage); |
Line 7646 Interval (in months) between two waves:
|
Line 8029 Interval (in months) between two waves:
|
free_ma3x(param,1,nlstate,1, nlstate+ndeath-1,1,ncovmodel); |
free_ma3x(param,1,nlstate,1, nlstate+ndeath-1,1,ncovmodel); |
|
|
free_ivector(ncodemax,1,NCOVMAX); |
free_ivector(ncodemax,1,NCOVMAX); |
|
free_ivector(ncodemaxwundef,1,NCOVMAX); |
free_ivector(Tvar,1,NCOVMAX); |
free_ivector(Tvar,1,NCOVMAX); |
free_ivector(Tprod,1,NCOVMAX); |
free_ivector(Tprod,1,NCOVMAX); |
free_ivector(Tvaraff,1,NCOVMAX); |
free_ivector(Tvaraff,1,NCOVMAX); |
free_ivector(Tage,1,NCOVMAX); |
free_ivector(Tage,1,NCOVMAX); |
|
|
free_imatrix(nbcode,0,NCOVMAX,0,NCOVMAX); |
free_imatrix(nbcode,0,NCOVMAX,0,NCOVMAX); |
free_imatrix(codtab,1,100,1,10); |
/* free_imatrix(codtab,1,100,1,10); */ |
fflush(fichtm); |
fflush(fichtm); |
fflush(ficgp); |
fflush(ficgp); |
|
|
Line 7753 Interval (in months) between two waves:
|
Line 8137 Interval (in months) between two waves:
|
} |
} |
end: |
end: |
while (z[0] != 'q') { |
while (z[0] != 'q') { |
printf("\nType q for exiting: "); |
printf("\nType q for exiting: "); fflush(stdout); |
scanf("%s",z); |
scanf("%s",z); |
} |
} |
} |
} |