version 1.85, 2003/06/17 13:12:43
|
version 1.87, 2003/06/18 12:26:01
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.87 2003/06/18 12:26:01 brouard |
|
Version 0.96 |
|
|
|
Revision 1.86 2003/06/17 20:04:08 brouard |
|
(Module): Change position of html and gnuplot routines and added |
|
routine fileappend. |
|
|
Revision 1.85 2003/06/17 13:12:43 brouard |
Revision 1.85 2003/06/17 13:12:43 brouard |
* imach.c (Repository): Check when date of death was earlier that |
* imach.c (Repository): Check when date of death was earlier that |
current date of interview. It may happen when the death was just |
current date of interview. It may happen when the death was just |
Line 19
|
Line 26
|
place. It differs from routine "prevalence" which may be called |
place. It differs from routine "prevalence" which may be called |
many times. Probs is memory consuming and must be used with |
many times. Probs is memory consuming and must be used with |
parcimony. |
parcimony. |
Version 0.95a2 (should output exactly the same maximization than 0.8a2) |
Version 0.95a3 (should output exactly the same maximization than 0.8a2) |
|
|
Revision 1.83 2003/06/10 13:39:11 lievre |
Revision 1.83 2003/06/10 13:39:11 lievre |
*** empty log message *** |
*** empty log message *** |
Line 122
|
Line 129
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
|
#include <sys/time.h> |
|
#include <time.h> |
|
#include "timeval.h" |
|
|
#define MAXLINE 256 |
#define MAXLINE 256 |
#define GNUPLOTPROGRAM "gnuplot" |
#define GNUPLOTPROGRAM "gnuplot" |
/*#define GNUPLOTPROGRAM "..\\gp37mgw\\wgnuplot"*/ |
/*#define GNUPLOTPROGRAM "..\\gp37mgw\\wgnuplot"*/ |
Line 153
|
Line 164
|
/* $Id$ */ |
/* $Id$ */ |
/* $State$ */ |
/* $State$ */ |
|
|
char version[]="Imach version 0.95a2, June 2003, INED-EUROREVES "; |
char version[]="Imach version 0.96, June 2003, INED-EUROREVES "; |
char fullversion[]="$Revision$ $Date$"; |
char fullversion[]="$Revision$ $Date$"; |
int erreur; /* Error number */ |
int erreur; /* Error number */ |
int nvar; |
int nvar; |
Line 167 int popbased=0;
|
Line 178 int popbased=0;
|
int *wav; /* Number of waves for this individuual 0 is possible */ |
int *wav; /* Number of waves for this individuual 0 is possible */ |
int maxwav; /* Maxim number of waves */ |
int maxwav; /* Maxim number of waves */ |
int jmin, jmax; /* min, max spacing between 2 waves */ |
int jmin, jmax; /* min, max spacing between 2 waves */ |
|
int gipmx, gsw; /* Global variables on the number of contributions |
|
to the likelihood and the sum of weights (done by funcone)*/ |
int mle, weightopt; |
int mle, weightopt; |
int **mw; /* mw[mi][i] is number of the mi wave for this individual */ |
int **mw; /* mw[mi][i] is number of the mi wave for this individual */ |
int **dh; /* dh[mi][i] is number of steps between mi,mi+1 for this individual */ |
int **dh; /* dh[mi][i] is number of steps between mi,mi+1 for this individual */ |
Line 1282 double func( double *x)
|
Line 1295 double func( double *x)
|
/*************** log-likelihood *************/ |
/*************** log-likelihood *************/ |
double funcone( double *x) |
double funcone( double *x) |
{ |
{ |
|
/* Same as likeli but slower because of a lot of printf and if */ |
int i, ii, j, k, mi, d, kk; |
int i, ii, j, k, mi, d, kk; |
double l, ll[NLSTATEMAX], cov[NCOVMAX]; |
double l, ll[NLSTATEMAX], cov[NCOVMAX]; |
double **out; |
double **out; |
double lli; /* Individual log likelihood */ |
double lli; /* Individual log likelihood */ |
|
double llt; |
int s1, s2; |
int s1, s2; |
double bbh, survp; |
double bbh, survp; |
/*extern weight */ |
/*extern weight */ |
Line 1342 double funcone( double *x)
|
Line 1357 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,"%6d %1d %1d %1d %1d %3d %10.6f %6.4f %10.6f %10.6f %10.6f ", \ |
fprintf(ficresilk,"%ld %6d %1d %1d %1d %1d %3d %10.6f %6.4f\ |
i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],2*weight[i]*lli,out[s1][s2],savm[s1][s2]); |
%10.6f %10.6f %10.6f ", \ |
for(k=1,l=0.; k<=nlstate; k++) |
num[i],i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i], |
fprintf(ficresilk," %10.6f",ll[k]); |
2*weight[i]*lli,out[s1][s2],savm[s1][s2]); |
fprintf(ficresilk,"\n"); |
for(k=1,llt=0.,l=0.; k<=nlstate; k++){ |
|
llt +=ll[k]*gipmx/gsw; |
|
fprintf(ficresilk," %10.6f",-ll[k]*gipmx/gsw); |
|
} |
|
fprintf(ficresilk," %10.6f\n", -llt); |
} |
} |
} /* end of wave */ |
} /* end of wave */ |
} /* end of individual */ |
} /* end of individual */ |
for(k=1,l=0.; k<=nlstate; k++) l += ll[k]; |
for(k=1,l=0.; k<=nlstate; k++) l += ll[k]; |
/* printf("l1=%f l2=%f ",ll[1],ll[2]); */ |
/* printf("l1=%f l2=%f ",ll[1],ll[2]); */ |
l= l*ipmx/sw; /* To get the same order of magnitude as if weight=1 for every body */ |
l= l*ipmx/sw; /* To get the same order of magnitude as if weight=1 for every body */ |
|
if(globpr==0){ /* First time we count the contributions and weights */ |
|
gipmx=ipmx; |
|
gsw=sw; |
|
} |
return -l; |
return -l; |
} |
} |
|
|
|
|
void likelione(FILE *ficres,double p[], int npar, int nlstate, int *globpr, long *ipmx, double *sw, double *fretone, double (*funcone)(double [])) |
void likelione(FILE *ficres,double p[], int npar, int nlstate, int *globpri, long *ipmx, double *sw, double *fretone, double (*funcone)(double [])) |
{ |
{ |
/* This routine should help understanding what is done with the selection of individuals/waves and |
/* This routine should help understanding what is done with |
|
the selection of individuals/waves and |
to check the exact contribution to the likelihood. |
to check the exact contribution to the likelihood. |
Plotting could be done. |
Plotting could be done. |
*/ |
*/ |
int k; |
int k; |
if(globpr !=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,fileres); |
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_product_matrix pij weight 2ln(pij)*weight 0pij_x 0pij_(x-stepm) cumulating_loglikeli_by_health_state"); |
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, "# i s1 s2 mi mw dh likeli weight out sav "); |
fprintf(ficresilk, "#num_i i s1 s2 mi mw dh likeli weight 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," ll[%d]",k); |
fprintf(ficresilk," -2*gipw/gsw*weight*ll[%d]++",k); |
fprintf(ficresilk,"\n"); |
fprintf(ficresilk," -2*gipw/gsw*weight*ll(total)\n"); |
} |
} |
|
|
*fretone=(*funcone)(p); |
*fretone=(*funcone)(p); |
if(globpr !=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",fileresilk,fileresilk); |
|
fflush(fichtm); |
|
} |
return; |
return; |
} |
} |
|
|
Line 1984 void concatwav(int wav[], int **dh, int
|
Line 2012 void concatwav(int wav[], int **dh, int
|
else if(j<0){ |
else if(j<0){ |
printf("Error! Negative delay (%d to death) between waves %d and %d of individual %ld at line %d who is aged %.1f with statuses from %d to %d\n ",j,mw[mi][i],mw[mi+1][i],num[i], i,agev[mw[mi][i]][i],s[mw[mi][i]][i] ,s[mw[mi+1][i]][i]); |
printf("Error! Negative delay (%d to death) between waves %d and %d of individual %ld at line %d who is aged %.1f with statuses from %d to %d\n ",j,mw[mi][i],mw[mi+1][i],num[i], i,agev[mw[mi][i]][i],s[mw[mi][i]][i] ,s[mw[mi+1][i]][i]); |
j=1; /* Careful Patch */ |
j=1; /* Careful Patch */ |
printf(" We assumed that the date of interview was correct (and not the date of death) and postponed the death %d month(s) (one stepm) after the interview.\n You MUST fixe the contradiction between dates.\n",stepm); |
printf(" We assumed that the date of interview was correct (and not the date of death) and postponed the death %d month(s) (one stepm) after the interview.\n You MUST fix the contradiction between dates.\n",stepm); |
printf("Error! Negative delay (%d to death) between waves %d and %d of individual %ld at line %d who is aged %.1f with statuses from %d to %d\n ",j,mw[mi][i],mw[mi+1][i],num[i], i,agev[mw[mi][i]][i],s[mw[mi][i]][i] ,s[mw[mi+1][i]][i]); |
printf("Error! Negative delay (%d to death) between waves %d and %d of individual %ld at line %d who is aged %.1f with statuses from %d to %d\n ",j,mw[mi][i],mw[mi+1][i],num[i], i,agev[mw[mi][i]][i],s[mw[mi][i]][i] ,s[mw[mi+1][i]][i]); |
fprintf(ficlog," We assumed that the date of interview was correct (and not the date of death) and postponed the death %d month(s) (one stepm) after the interview.\n You MUST fix the contradiction between dates.\n",stepm); |
fprintf(ficlog," We assumed that the date of interview was correct (and not the date of death) and postponed the death %d month(s) (one stepm) after the interview.\n You MUST fix the contradiction between dates.\n",stepm); |
} |
} |
Line 2348 void varevsij(char optionfilefiname[], d
|
Line 2376 void varevsij(char optionfilefiname[], d
|
else{ |
else{ |
fprintf(ficgp,"\n# Routine varevsij"); |
fprintf(ficgp,"\n# Routine varevsij"); |
} |
} |
if((fichtm=fopen(optionfilehtm,"a"))==NULL) { |
/* if((fichtm=fopen(optionfilehtm,"a"))==NULL) { */ |
printf("Problem with html file: %s\n", optionfilehtm); |
/* printf("Problem with html file: %s\n", optionfilehtm); */ |
fprintf(ficlog,"Problem with html file: %s\n", optionfilehtm); |
/* fprintf(ficlog,"Problem with html file: %s\n", optionfilehtm); */ |
exit(0); |
/* exit(0); */ |
} |
/* } */ |
else{ |
/* else{ */ |
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); |
} |
/* } */ |
varppt = matrix(nlstate+1,nlstate+ndeath,nlstate+1,nlstate+ndeath); |
varppt = matrix(nlstate+1,nlstate+ndeath,nlstate+1,nlstate+ndeath); |
|
|
fprintf(ficresvij,"# Variance and covariance of health expectancies e.j \n# (weighted average of eij where weights are the stable prevalence in health states i\n"); |
fprintf(ficresvij,"# Variance and covariance of health expectancies e.j \n# (weighted average of eij where weights are the stable prevalence in health states i\n"); |
Line 2586 void varevsij(char optionfilefiname[], d
|
Line 2614 void varevsij(char optionfilefiname[], d
|
if (mobilav!=0) free_ma3x(mobaverage,1, AGESUP,1,NCOVMAX, 1,NCOVMAX); |
if (mobilav!=0) free_ma3x(mobaverage,1, AGESUP,1,NCOVMAX, 1,NCOVMAX); |
fclose(ficresprobmorprev); |
fclose(ficresprobmorprev); |
fclose(ficgp); |
fclose(ficgp); |
fclose(fichtm); |
/* fclose(fichtm); */ |
} /* end varevsij */ |
} /* end varevsij */ |
|
|
/************ Variance of prevlim ******************/ |
/************ Variance of prevlim ******************/ |
Line 2751 void varprob(char optionfilefiname[], do
|
Line 2779 void varprob(char optionfilefiname[], do
|
else{ |
else{ |
fprintf(ficgp,"\n# Routine varprob"); |
fprintf(ficgp,"\n# Routine varprob"); |
} |
} |
if((fichtm=fopen(optionfilehtm,"a"))==NULL) { |
/* if((fichtm=fopen(optionfilehtm,"a"))==NULL) { */ |
printf("Problem with html file: %s\n", optionfilehtm); |
/* printf("Problem with html file: %s\n", optionfilehtm); */ |
fprintf(ficlog,"Problem with html file: %s\n", optionfilehtm); |
/* fprintf(ficlog,"Problem with html file: %s\n", optionfilehtm); */ |
exit(0); |
/* exit(0); */ |
} |
/* } */ |
else{ |
/* else{ */ |
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"); |
|
|
Line 2764 void varprob(char optionfilefiname[], do
|
Line 2792 void varprob(char optionfilefiname[], do
|
fprintf(fichtm,"\nWe have drawn ellipsoids of confidence around the p<inf>ij</inf>, p<inf>kl</inf> to understand the covariance between two incidences. They are expressed in year<sup>-1</sup> in order to be less dependent of stepm.<br>\n"); |
fprintf(fichtm,"\nWe have drawn ellipsoids of confidence around the p<inf>ij</inf>, p<inf>kl</inf> to understand the covariance between two incidences. They are expressed in year<sup>-1</sup> in order to be less dependent of stepm.<br>\n"); |
fprintf(fichtm,"\n<br> We have drawn x'cov<sup>-1</sup>x = 4 where x is the column vector (pij,pkl). It means that if pij and pkl where uncorrelated the (2X2) matrix would have been (1/(var pij), 0 , 0, 1/(var pkl)), and the confidence interval would be 2 standard deviations wide on each axis. <br> When both incidences are correlated we diagonalised the inverse of the covariance matrix and made the appropriate rotation.<br> \n"); |
fprintf(fichtm,"\n<br> We have drawn x'cov<sup>-1</sup>x = 4 where x is the column vector (pij,pkl). It means that if pij and pkl where uncorrelated the (2X2) matrix would have been (1/(var pij), 0 , 0, 1/(var pkl)), and the confidence interval would be 2 standard deviations wide on each axis. <br> When both incidences are correlated we diagonalised the inverse of the covariance matrix and made the appropriate rotation.<br> \n"); |
|
|
} |
/* } */ |
|
|
cov[1]=1; |
cov[1]=1; |
tj=cptcoveff; |
tj=cptcoveff; |
Line 2981 void varprob(char optionfilefiname[], do
|
Line 3009 void varprob(char optionfilefiname[], do
|
fclose(ficresprobcov); |
fclose(ficresprobcov); |
fclose(ficresprobcor); |
fclose(ficresprobcor); |
fclose(ficgp); |
fclose(ficgp); |
fclose(fichtm); |
|
} |
} |
|
|
|
|
Line 2994 void printinghtml(char fileres[], char t
|
Line 3021 void printinghtml(char fileres[], char t
|
double jprev2, double mprev2,double anprev2){ |
double jprev2, double mprev2,double anprev2){ |
int jj1, k1, i1, cpt; |
int jj1, k1, i1, cpt; |
/*char optionfilehtm[FILENAMELENGTH];*/ |
/*char optionfilehtm[FILENAMELENGTH];*/ |
if((fichtm=fopen(optionfilehtm,"a"))==NULL) { |
/* if((fichtm=fopen(optionfilehtm,"a"))==NULL) { */ |
printf("Problem with %s \n",optionfilehtm), exit(0); |
/* printf("Problem with %s \n",optionfilehtm), exit(0); */ |
fprintf(ficlog,"Problem with %s \n",optionfilehtm), exit(0); |
/* fprintf(ficlog,"Problem with %s \n",optionfilehtm), exit(0); */ |
} |
/* } */ |
|
|
fprintf(fichtm,"<ul><li><h4>Result files (first order: no variance)</h4>\n \ |
fprintf(fichtm,"<ul><li><h4>Result files (first order: no variance)</h4>\n \ |
- Observed prevalence in each state (during the period defined between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf): <a href=\"p%s\">p%s</a> <br>\n \ |
- Observed prevalence in each state (during the period defined between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf): <a href=\"p%s\">p%s</a> <br>\n \ |
Line 3084 interval) in state (%d): v%s%d%d.png <br
|
Line 3111 interval) in state (%d): v%s%d%d.png <br
|
} /* end i1 */ |
} /* end i1 */ |
}/* End k1 */ |
}/* End k1 */ |
fprintf(fichtm,"</ul>"); |
fprintf(fichtm,"</ul>"); |
fclose(fichtm); |
fflush(fichtm); |
} |
} |
|
|
/******************* Gnuplot file **************/ |
/******************* Gnuplot file **************/ |
Line 3591 populforecast(char fileres[], double anp
|
Line 3618 populforecast(char fileres[], double anp
|
fclose(ficrespop); |
fclose(ficrespop); |
} /* End of popforecast */ |
} /* End of popforecast */ |
|
|
|
int fileappend(FILE *fichier, char *optionfich) |
|
{ |
|
if((fichier=fopen(optionfich,"a"))==NULL) { |
|
printf("Problem with file: %s\n", optionfich); |
|
fprintf(ficlog,"Problem with file: %s\n", optionfich); |
|
return (0); |
|
} |
|
fflush(fichier); |
|
return (1); |
|
} |
/***********************************************/ |
/***********************************************/ |
/**************** Main Program *****************/ |
/**************** Main Program *****************/ |
/***********************************************/ |
/***********************************************/ |
Line 3601 int main(int argc, char *argv[])
|
Line 3638 int main(int argc, char *argv[])
|
int i,j, k, n=MAXN,iter,m,size=100,cptcode, cptcod; |
int i,j, k, n=MAXN,iter,m,size=100,cptcode, cptcod; |
int jj; |
int jj; |
int numlinepar=0; /* Current linenumber of parameter file */ |
int numlinepar=0; /* Current linenumber of parameter file */ |
|
/* FILE *fichtm; *//* Html File */ |
|
/* FILE *ficgp;*/ /*Gnuplot File */ |
double agedeb, agefin,hf; |
double agedeb, agefin,hf; |
double ageminpar=1.e20,agemin=1.e20, agemaxpar=-1.e20, agemax=-1.e20; |
double ageminpar=1.e20,agemin=1.e20, agemaxpar=-1.e20, agemax=-1.e20; |
|
|
Line 3644 int main(int argc, char *argv[])
|
Line 3683 int main(int argc, char *argv[])
|
|
|
|
|
char z[1]="c", occ; |
char z[1]="c", occ; |
#include <sys/time.h> |
|
#include <time.h> |
|
char stra[80], strb[80], strc[80], strd[80],stre[80],modelsav[80]; |
char stra[80], strb[80], strc[80], strd[80],stre[80],modelsav[80]; |
char *strt, *strtend; |
char *strt, *strtend; |
char *stratrunc; |
char *stratrunc; |
Line 3664 int main(int argc, char *argv[])
|
Line 3702 int main(int argc, char *argv[])
|
tm = *localtime(&start_time.tv_sec); |
tm = *localtime(&start_time.tv_sec); |
tmg = *gmtime(&start_time.tv_sec); |
tmg = *gmtime(&start_time.tv_sec); |
strt=asctime(&tm); |
strt=asctime(&tm); |
|
|
/* printf("Localtime (at start)=%s",strt); */ |
/* printf("Localtime (at start)=%s",strt); */ |
/* tp.tv_sec = tp.tv_sec +86400; */ |
/* tp.tv_sec = tp.tv_sec +86400; */ |
/* tm = *localtime(&start_time.tv_sec); */ |
/* tm = *localtime(&start_time.tv_sec); */ |
Line 3713 int main(int argc, char *argv[])
|
Line 3752 int main(int argc, char *argv[])
|
fprintf(ficlog,"\n%s\n%s",version,fullversion); |
fprintf(ficlog,"\n%s\n%s",version,fullversion); |
fprintf(ficlog,"\nEnter the parameter file name: "); |
fprintf(ficlog,"\nEnter the parameter file name: "); |
fprintf(ficlog,"pathtot=%s, path=%s, optionfile=%s optionfilext=%s optionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname); |
fprintf(ficlog,"pathtot=%s, path=%s, optionfile=%s optionfilext=%s optionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname); |
printf("Localtime (at start)=%s",strt); |
|
fprintf(ficlog,"Localtime (at start)=%s",strt); |
printf("Localtime (at start)=%s",strt); |
|
fprintf(ficlog,"Localtime (at start)=%s",strt); |
fflush(ficlog); |
fflush(ficlog); |
|
|
/* */ |
/* */ |
Line 4224 int main(int argc, char *argv[])
|
Line 4264 int main(int argc, char *argv[])
|
} |
} |
scanf("%d",i);*/ |
scanf("%d",i);*/ |
|
|
|
/*------------ gnuplot -------------*/ |
|
strcpy(optionfilegnuplot,optionfilefiname); |
|
strcat(optionfilegnuplot,".gp"); |
|
if((ficgp=fopen(optionfilegnuplot,"w"))==NULL) { |
|
printf("Problem with file %s",optionfilegnuplot); |
|
} |
|
else{ |
|
fprintf(ficgp,"\n# %s\n", version); |
|
fprintf(ficgp,"# %s\n", optionfilegnuplot); |
|
fprintf(ficgp,"set missing 'NaNq'\n"); |
|
} |
|
fclose(ficgp); |
|
/*--------- index.htm --------*/ |
|
|
|
strcpy(optionfilehtm,optionfilefiname); |
|
strcat(optionfilehtm,".htm"); |
|
if((fichtm=fopen(optionfilehtm,"w"))==NULL) { |
|
printf("Problem with %s \n",optionfilehtm), exit(0); |
|
} |
|
|
|
fprintf(fichtm,"<body>\n<title>IMaCh %s</title>\n <font size=\"2\">%s <br> %s</font> \ |
|
<hr size=\"2\" color=\"#EC5E5E\"> \n\ |
|
Title=%s <br>Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s<br>\n\ |
|
\n\ |
|
<hr size=\"2\" color=\"#EC5E5E\">\ |
|
<ul><li><h4>Parameter files</h4>\n\ |
|
- Copy of the parameter file: <a href=\"o%s\">o%s</a><br>\n\ |
|
- Log file of the run: <a href=\"%s\">%s</a><br>\n\ |
|
- Gnuplot file name: <a href=\"%s\">%s</a><br>\n\ |
|
- Date and time at start: %s</ul>\n",\ |
|
fileres,version,fullversion,title,datafile,firstpass,lastpass,stepm, weightopt,\ |
|
model,fileres,fileres,\ |
|
filelog,filelog,optionfilegnuplot,optionfilegnuplot,strt); |
|
/*fclose(fichtm);*/ |
|
fflush(fichtm); |
|
|
/* Calculates basic frequencies. Computes observed prevalence at single age |
/* Calculates basic frequencies. Computes observed prevalence at single age |
and prints on file fileres'p'. */ |
and prints on file fileres'p'. */ |
freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvaraff,nbcode, ncodemax,mint,anint); |
freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvaraff,nbcode, ncodemax,mint,anint); |
|
|
|
/* if((fichtm=fopen(optionfilehtm,"a"))==NULL) { */ |
|
/* printf("Problem with file: %s\n", optionfilehtm); */ |
|
/* fprintf(ficlog,"Problem with file: %s\n", optionfilehtm); */ |
|
/* } */ |
|
|
|
|
|
/* if(fileappend(fichtm, optionfilehtm)){ */ |
|
fprintf(fichtm,"\n"); |
|
fprintf(fichtm,"<br>Total number of observations=%d <br>\n\ |
|
Youngest age at first (selected) pass %.2f, oldest age %.2f<br>\n\ |
|
Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf<br>\n",\ |
|
imx,agemin,agemax,jmin,jmax,jmean); |
|
/* fclose(fichtm); */ |
|
/* } */ |
|
|
pmmij= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ |
pmmij= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ |
oldms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ |
oldms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ |
newms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ |
newms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ |
Line 4239 int main(int argc, char *argv[])
|
Line 4330 int main(int argc, char *argv[])
|
so we point p on param[1][1] so that p[1] maps on param[1][1][1] */ |
so we point p on param[1][1] so that p[1] maps on param[1][1][1] */ |
p=param[1][1]; /* *(*(*(param +1)+1)+0) */ |
p=param[1][1]; /* *(*(*(param +1)+1)+0) */ |
|
|
globpr=0; /* To get ipmx number of contributions and sum of weights*/ |
globpr=0; /* To get the number ipmx of contributions and the sum of weights*/ |
likelione(ficres, p, npar, nlstate, &globpr, &ipmx, &sw, &fretone, funcone); /* Prints the contributions to the likelihood */ |
likelione(ficres, p, npar, nlstate, &globpr, &ipmx, &sw, &fretone, funcone); /* Prints the contributions to the likelihood */ |
printf("First Likeli=%12.6f ipmx=%ld sw=%12.6f",fretone,ipmx,sw); |
printf("First Likeli=%12.6f ipmx=%ld sw=%12.6f",fretone,ipmx,sw); |
for (k=1; k<=npar;k++) |
for (k=1; k<=npar;k++) |
Line 4413 int main(int argc, char *argv[])
|
Line 4504 int main(int argc, char *argv[])
|
fprintf(ficparo,"popforecast=%d popfile=%s popfiledate=%.lf/%.lf/%.lf last-popfiledate=%.lf/%.lf/%.lf\n",popforecast,popfile,jpyram,mpyram,anpyram,jpyram1,mpyram1,anpyram1); |
fprintf(ficparo,"popforecast=%d popfile=%s popfiledate=%.lf/%.lf/%.lf last-popfiledate=%.lf/%.lf/%.lf\n",popforecast,popfile,jpyram,mpyram,anpyram,jpyram1,mpyram1,anpyram1); |
fprintf(ficres,"popforecast=%d popfile=%s popfiledate=%.lf/%.lf/%.lf last-popfiledate=%.lf/%.lf/%.lf\n",popforecast,popfile,jpyram,mpyram,anpyram,jpyram1,mpyram1,anpyram1); |
fprintf(ficres,"popforecast=%d popfile=%s popfiledate=%.lf/%.lf/%.lf last-popfiledate=%.lf/%.lf/%.lf\n",popforecast,popfile,jpyram,mpyram,anpyram,jpyram1,mpyram1,anpyram1); |
|
|
freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvaraff,nbcode, ncodemax,mint,anint); |
/* freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvaraff,nbcode, ncodemax,mint,anint);*/ |
/*,dateprev1,dateprev2,jprev1, mprev1,anprev1,jprev2, mprev2,anprev2);*/ |
/*,dateprev1,dateprev2,jprev1, mprev1,anprev1,jprev2, mprev2,anprev2);*/ |
|
|
/*------------ gnuplot -------------*/ |
|
strcpy(optionfilegnuplot,optionfilefiname); |
|
strcat(optionfilegnuplot,".gp"); |
|
if((ficgp=fopen(optionfilegnuplot,"w"))==NULL) { |
|
printf("Problem with file %s",optionfilegnuplot); |
|
} |
|
else{ |
|
fprintf(ficgp,"\n# %s\n", version); |
|
fprintf(ficgp,"# %s\n", optionfilegnuplot); |
|
fprintf(ficgp,"set missing 'NaNq'\n"); |
|
} |
|
fclose(ficgp); |
|
printinggnuplot(fileres, ageminpar,agemaxpar,fage, pathc,p); |
printinggnuplot(fileres, ageminpar,agemaxpar,fage, pathc,p); |
/*--------- index.htm --------*/ |
|
|
|
strcpy(optionfilehtm,optionfile); |
|
strcat(optionfilehtm,".htm"); |
|
if((fichtm=fopen(optionfilehtm,"w"))==NULL) { |
|
printf("Problem with %s \n",optionfilehtm), exit(0); |
|
} |
|
|
|
fprintf(fichtm,"<body> <font size=\"2\">%s </font> <hr size=\"2\" color=\"#EC5E5E\"> \n\ |
|
Title=%s <br>Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s<br>\n\ |
|
\n\ |
|
Total number of observations=%d <br>\n\ |
|
Youngest age at first (selected) pass %.2f, oldest age %.2f<br>\n\ |
|
Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf<br>\n\ |
|
<hr size=\"2\" color=\"#EC5E5E\">\ |
|
<ul><li><h4>Parameter files</h4>\n\ |
|
- Copy of the parameter file: <a href=\"o%s\">o%s</a><br>\n\ |
|
- Log file of the run: <a href=\"%s\">%s</a><br>\n\ |
|
- Gnuplot file name: <a href=\"%s\">%s</a></ul>\n",\ |
|
version,title,datafile,firstpass,lastpass,stepm, weightopt,\ |
|
model,imx,agemin,agemax,jmin,jmax,jmean,fileres,fileres,\ |
|
filelog,filelog,optionfilegnuplot,optionfilegnuplot); |
|
fclose(fichtm); |
|
|
|
printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,\ |
printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,\ |
model,imx,jmin,jmax,jmean,rfileres,popforecast,estepm,\ |
model,imx,jmin,jmax,jmean,rfileres,popforecast,estepm,\ |
Line 4800 ageminpar, agemax, s[lastpass][imx], age
|
Line 4856 ageminpar, agemax, s[lastpass][imx], age
|
printf("Total time was %d Sec. %d uSec.\n", end_time.tv_sec -start_time.tv_sec, end_time.tv_usec -start_time.tv_usec); |
printf("Total time was %d Sec. %d uSec.\n", end_time.tv_sec -start_time.tv_sec, end_time.tv_usec -start_time.tv_usec); |
fprintf(ficlog,"Total time was %d Sec. %d uSec.\n", end_time.tv_sec -start_time.tv_sec, end_time.tv_usec -start_time.tv_usec); |
fprintf(ficlog,"Total time was %d Sec. %d uSec.\n", end_time.tv_sec -start_time.tv_sec, end_time.tv_usec -start_time.tv_usec); |
/* printf("Total time was %d uSec.\n", total_usecs);*/ |
/* printf("Total time was %d uSec.\n", total_usecs);*/ |
|
/* if(fileappend(fichtm,optionfilehtm)){ */ |
|
fprintf(fichtm,"<br>Localtime at start %s and at end=%s<br>",strt, strtend); |
|
fclose(fichtm); |
/*------ End -----------*/ |
/*------ End -----------*/ |
|
|
end: |
end: |