/* $Id$
$State$
$Log$
+ Revision 1.163 2014/12/16 10:30:11 brouard
+ * imach.c (Module): Merging 1.61 to 1.162
+
Revision 1.162 2014/09/25 11:43:39 brouard
Summary: temporary backup 0.99!
#define YEARM 12. /**< Number of months per year */
#define AGESUP 130
#define AGEBASE 40
-#define AGEGOMP 10. /**< Minimal age for Gompertz adjustment */
+#define AGEGOMP 10 /**< Minimal age for Gompertz adjustment */
#ifdef _WIN32
#define DIRSEPARATOR '\\'
#define CHARSEPARATOR "\\"
int iter;
double a,b,d,etemp;
double fu=0,fv,fw,fx;
- double ftemp;
+ double ftemp=0.;
double p,q,r,tol1,tol2,u,v,w,x,xm;
double e=0.0;
for (j=1;j<=n;j++) xit[j]=xi[j][i];
fptt=(*fret);
#ifdef DEBUG
- printf("fret=%lf \n",*fret);
- fprintf(ficlog,"fret=%lf \n",*fret);
+ printf("fret=%lf, %lf, %lf \n", *fret, *fret, *fret);
+ fprintf(ficlog, "fret=%lf, %lf, %lf \n", *fret, *fret, *fret);
#endif
printf("%d",i);fflush(stdout);
fprintf(ficlog,"%d",i);fflush(ficlog);
fprintf(ficlog,"Gaining to use average direction of P0 P%d instead of biggest increase direction :\n",n,ibig);
#ifdef DEBUG
+ printf("Direction changed last moved %d in place of ibig=%d, new last is the average:\n",n,ibig);
+ fprintf(ficlog,"Direction changed last moved %d in place of ibig=%d, new last is the average:\n",n,ibig);
for(j=1;j<=n;j++){
printf(" %.12e",xit[j]);
fprintf(ficlog," %.12e",xit[j]);
*/
double s1, lnpijopii;
/*double t34;*/
- int i,j,j1, nc, ii, jj;
+ int i,j, nc, ii, jj;
for(i=1; i<= nlstate; i++){
for(j=1; j<i;j++){
{
double **a,**y,*x,pd;
double **hess;
- int i, j,jk;
+ int i, j;
int *indx;
double hessii(double p[], double delta, int theta, double delti[],double (*func)(double []),int npar);
k=kmax;
}
else if((k1 >khi/nkhif) || (k2 >khi/nkhif)){ /* Keeps lastvalue before 3.84/2 KHI2 5% 1d.f. */
- k=kmax; l=lmax*10.;
+ k=kmax; l=lmax*10;
}
else if((k1 >khi/nkhi) || (k2 >khi/nkhi)){
delts=delt;
double hessij( double x[], double delti[], int thetai,int thetaj,double (*func)(double []),int npar)
{
int i;
- int l=1, l1, lmax=20;
+ int l=1, lmax=20;
double k1,k2,k3,k4,res,fx;
double p2[MAXPARM+1];
int k;
void freqsummary(char fileres[], int iagemin, int iagemax, int **s, double **agev, int nlstate, int imx, int *Tvaraff, int **nbcode, int *ncodemax,double **mint,double **anint, char strstart[])
{ /* Some frequencies */
- int i, m, jk, k1,i1, j1, bool, z1,j;
+ int i, m, jk, j1, bool, z1,j;
int first;
double ***freq; /* Frequencies */
double *pp, **prop;
We still use firstpass and lastpass as another selection.
*/
- int i, m, jk, k1, i1, j1, bool, z1,j;
- double ***freq; /* Frequencies */
- double *pp, **prop;
- double pos,posprop;
+ int i, m, jk, j1, bool, z1,j;
+
+ double **prop;
+ double posprop;
double y2; /* in fractional years */
int iagemin, iagemax;
int first; /** to stop verbosity which is redirected to log file */
int j, k=0,jk, ju, jl;
double sum=0.;
first=0;
- jmin=1e+5;
+ jmin=100000;
jmax=-1;
jmean=0.;
for(i=1; i<=imx; i++){
{
/* Health expectancies, no variances */
- int i, j, nhstepm, hstepm, h, nstepm, k, cptj, cptj2, i2, j2;
+ int i, j, nhstepm, hstepm, h, nstepm;
int nhstepma, nstepma; /* Decreasing with age */
double age, agelim, hf;
double ***p3mat;
double **dnewm,**doldm;
double **dnewmp,**doldmp;
int i, j, nhstepm, hstepm, h, nstepm ;
- int k, cptcode;
+ int k;
double *xp;
double **gp, **gm; /* for var eij */
double ***gradg, ***trgradg; /*for var eij */
{
/* Variance of prevalence limit */
/* double **prevalim(double **prlim, int nlstate, double *xp, double age, double **oldm, double **savm,double ftolpl);*/
- double **newm;
+
double **dnewm,**doldm;
int i, j, nhstepm, hstepm;
- int k, cptcode;
double *xp;
double *gp, *gm;
double **gradg, **trgradg;
/************ Variance of one-step probabilities ******************/
void varprob(char optionfilefiname[], double **matcov, double x[], double delti[], int nlstate, double bage, double fage, int ij, int *Tvar, int **nbcode, int *ncodemax, char strstart[])
{
- int i, j=0, i1, k1, l1, t, tj;
+ int i, j=0, k1, l1, tj;
int k2, l2, j1, z1;
- int k=0,l, cptcode;
+ int k=0, l;
int first=1, first1, first2;
double cv12, mu1, mu2, lc1, lc2, v12, v21, v11, v22,v1,v2, c12, tnalp;
double **dnewm,**doldm;
double *gp, *gm;
double **gradg, **trgradg;
double **mu;
- double age,agelim, cov[NCOVMAX+1];
+ double age, cov[NCOVMAX+1];
double std=2.0; /* Number of standard deviation wide of confidence ellipsoids */
int theta;
char fileresprob[FILENAMELENGTH];
<img src=\"%s%d_2.png\">",stepm,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1);
/* Period (stable) prevalence in each health state */
for(cpt=1; cpt<=nlstate;cpt++){
- fprintf(fichtm,"<br>- Convergence from each state (1 to %d) to period (stable) prevalence in state %d <a href=\"%s%d_%d.png\">%s%d_%d.png</a><br> \
+ fprintf(fichtm,"<br>- Convergence from cross-sectional prevalence in each state (1 to %d) to period (stable) prevalence in specific state %d <a href=\"%s%d_%d.png\">%s%d_%d.png</a><br> \
<img src=\"%s%d_%d.png\">",nlstate, cpt, subdirf2(optionfilefiname,"p"),cpt,jj1,subdirf2(optionfilefiname,"p"),cpt,jj1,subdirf2(optionfilefiname,"p"),cpt,jj1);
}
for(cpt=1; cpt<=nlstate;cpt++) {
void printinggnuplot(char fileres[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){
char dirfileres[132],optfileres[132];
- int m0,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;
/* if((ficgp=fopen(optionfilegnuplot,"a"))==NULL) { */
/* printf("Problem with file %s",optionfilegnuplot); */
} /* end k2 */
} /* end jk */
} /* end ng */
- avoid:
+ /* avoid: */
fflush(ficgp);
} /* end gnuplot */
dateprev1 dateprev2 range of dates during which prevalence is computed
anproj2 year of en of projection (same day and month as proj1).
*/
- int yearp, stepsize, hstepm, nhstepm, j, k, c, cptcod, i, h, i1;
- int *popage;
+ int yearp, stepsize, hstepm, nhstepm, j, k, cptcod, i, h, i1;
double agec; /* generic age */
double agelim, ppij, yp,yp1,yp2,jprojmean,mprojmean,anprojmean;
double *popeffectif,*popcount;
/* Wizard to print covariance matrix template */
- char ca[32], cb[32], cc[32];
- int i,j, k, l, li, lj, lk, ll, jj, npar, itimes;
+ char ca[32], cb[32];
+ int i,j, k, li, lj, lk, ll, jj, npar, itimes;
int numlinepar;
printf("# Parameters nlstate*nlstate*ncov a12*1 + b12 * age + ...\n");
void printinggnuplotmort(char fileres[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){
char dirfileres[132],optfileres[132];
- int m,cpt,k1,i,k,j,jk,k2,k3,ij,l;
+
int ng;
/*-------- data file ----------*/
FILE *fic;
char dummy[]=" ";
- int i, j, n;
+ int i=0, j=0, n=0;
int linei, month, year,iout;
char line[MAXLINE], linetmp[MAXLINE];
- char stra[80], strb[80];
+ char stra[MAXLINE], strb[MAXLINE];
char *stratrunc;
int lstra;
continue;
}
trimbb(linetmp,line); /* Trims multiple blanks in line */
- for (j=0; line[j]!='\0';j++){
- line[j]=linetmp[j];
- }
+ strcpy(line, linetmp);
for (j=maxwav;j>=1;j--){
fclose(fic);
return (0);
- endread:
+ /* endread: */
printf("Exiting readdata: ");
fclose(fic);
return (1);
*/
{
int i, j, k, ks;
- int i1, j1, k1, k2;
+ int j1, k1, k2;
char modelsav[80];
char stra[80], strb[80], strc[80], strd[80],stre[80];
return (0); /* with covar[new additional covariate if product] and Tage if age */
- endread:
+ /*endread:*/
printf("Exiting decodemodel: ");
return (1);
}
fprintf(ficlog,"Total number of individuals= %d, Agemin = %.2f, Agemax= %.2f\n\n", imx, *agemin, *agemax);
return (0);
- endread:
+ /* endread:*/
printf("Exiting calandcheckages: ");
return (1);
}
double ssval;
#endif
int movingaverage(double ***probs, double bage,double fage, double ***mobaverage, int mobilav);
- int i,j, k, n=MAXN,iter,m,size=100,cptcode, cptcod;
- int linei, month, year,iout;
- int jj, ll, li, lj, lk, imk;
+ int i,j, k, n=MAXN,iter=0,m,size=100, cptcod;
+
+ int jj, ll, li, lj, lk;
int numlinepar=0; /* Current linenumber of parameter file */
int itimes;
int NDIM=2;
int vpopbased=0;
- char ca[32], cb[32], cc[32];
+ char ca[32], cb[32];
/* FILE *fichtm; *//* Html File */
/* FILE *ficgp;*/ /*Gnuplot File */
struct stat info;
- double agedeb, agefin,hf;
+ double agedeb;
double ageminpar=1.e20,agemin=1.e20, agemaxpar=-1.e20, agemax=-1.e20;
- double fret;
- double **xi,tmp,delta;
double dum; /* Dummy variable */
double ***p3mat;
double ***mobaverage;
- int *indx;
- char line[MAXLINE], linepar[MAXLINE];
+
+ char line[MAXLINE];
char path[MAXLINE],pathc[MAXLINE],pathcd[MAXLINE],pathtot[MAXLINE],model[MAXLINE];
char pathr[MAXLINE], pathimach[MAXLINE];
- char **bp, *tok, *val; /* pathtot */
+ char *tok, *val; /* pathtot */
int firstobs=1, lastobs=10;
- int sdeb, sfin; /* Status at beginning and end */
- int c, h , cpt,l;
- int ju,jl, mi;
- int i1,j1, jk,aa,bb, stepsize, ij;
- int jnais,jdc,jint4,jint1,jint2,jint3,*tab;
+ int c, h , cpt;
+ int jl;
+ int i1, j1, jk, stepsize;
+ int *tab;
int mobilavproj=0 , prevfcast=0 ; /* moving average of prev, If prevfcast=1 prevalence projection */
int mobilav=0,popforecast=0;
int hstepm, nhstepm;
double jprev1=1, mprev1=1,anprev1=2000,jprev2=1, mprev2=1,anprev2=2000;
double jpyram=1, mpyram=1,anpyram=2000,jpyram1=1, mpyram1=1,anpyram1=2000;
- double bage, fage, age, agelim, agebase;
+ double bage=0, fage=110, age, agelim, agebase;
double ftolpl=FTOL;
double **prlim;
double ***param; /* Matrix of parameters */
double ***eij, ***vareij;
double **varpl; /* Variances of prevalence limits by age */
double *epj, vepp;
- double kk1, kk2;
+
double dateprev1, dateprev2,jproj1=1,mproj1=1,anproj1=2000,jproj2=1,mproj2=1,anproj2=2000;
double **ximort;
char *alph[]={"a","a","b","c","d","e"}, str[4]="1234";
int *dcwave;
- char z[1]="c", occ;
+ char z[1]="c";
/*char *strt;*/
char strtend[80];
- long total_usecs;
-
+
/* setlocale (LC_ALL, ""); */
/* bindtextdomain (PACKAGE, LOCALEDIR); */
/* textdomain (PACKAGE); */
for(i=1; i <=nlstate; i++){
for(j=1; j <=nlstate+ndeath-1; j++){
fscanf(ficpar,"%1d%1d",&i1,&j1);
- if ((i1-i)*(j1-j)!=0){
+ if ( (i1-i) * (j1-j) != 0){
printf("Error in line parameters number %d, %1d%1d instead of %1d%1d \n",numlinepar, i,j, i1, j1);
exit(1);
}
if (mobilav!=0) free_ma3x(mobaverage,1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
free_ma3x(probs,1,AGESUP,1,NCOVMAX, 1,NCOVMAX);
} /* mle==-3 arrives here for freeing */
- endfree:
+ /* endfree:*/
free_matrix(prlim,1,nlstate,1,nlstate); /*here or after loop ? */
free_matrix(pmmij,1,nlstate+ndeath,1,nlstate+ndeath);
free_matrix(oldms, 1,nlstate+ndeath,1,nlstate+ndeath);