version 1.269, 2017/05/23 08:39:25
|
version 1.270, 2017/05/24 05:45:29
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.270 2017/05/24 05:45:29 brouard |
|
*** empty log message *** |
|
|
Revision 1.269 2017/05/23 08:39:25 brouard |
Revision 1.269 2017/05/23 08:39:25 brouard |
Summary: Code into subroutine, cleanings |
Summary: Code into subroutine, cleanings |
|
|
Line 5464 void concatwav(int wav[], int **dh, int
|
Line 5467 void concatwav(int wav[], int **dh, int
|
/* hstepm beeing the number of stepms, if hstepm=1 the length of hstepm is stepm. |
/* hstepm beeing the number of stepms, if hstepm=1 the length of hstepm is stepm. |
nhstepm is the number of hstepm from age to agelim |
nhstepm is the number of hstepm from age to agelim |
nstepm is the number of stepm from age to agelin. |
nstepm is the number of stepm from age to agelin. |
Look at hpijx to understand the reason of that which relies in memory size |
Look at hpijx to understand the reason which relies in memory size consideration |
and note for a fixed period like estepm months */ |
and note for a fixed period like estepm months */ |
/* We decided (b) to get a life expectancy respecting the most precise curvature of the |
/* We decided (b) to get a life expectancy respecting the most precise curvature of the |
survival function given by stepm (the optimization length). Unfortunately it |
survival function given by stepm (the optimization length). Unfortunately it |
Line 6924 true period expectancies (those weighted
|
Line 6927 true period expectancies (those weighted
|
} |
} |
|
|
/******************* Gnuplot file **************/ |
/******************* Gnuplot file **************/ |
void printinggnuplot(char fileresu[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , int prevfcast, int backcast, char pathc[], double p[], int offyear, int offbyear){ |
void printinggnuplot(char fileresu[], char optionfilefiname[], double ageminpar, double agemaxpar, double bage, double fage , int prevfcast, int backcast, char pathc[], double p[], int offyear, int offbyear){ |
|
|
char dirfileres[132],optfileres[132]; |
char dirfileres[132],optfileres[132]; |
char gplotcondition[132], gplotlabel[132]; |
char gplotcondition[132], gplotlabel[132]; |
Line 6933 void printinggnuplot(char fileresu[], ch
|
Line 6936 void printinggnuplot(char fileresu[], ch
|
int ng=0; |
int ng=0; |
int vpopbased; |
int vpopbased; |
int ioffset; /* variable offset for columns */ |
int ioffset; /* variable offset for columns */ |
|
int iyearc=1; /* variable column for year of projection */ |
|
int iagec=1; /* variable column for age of projection */ |
int nres=0; /* Index of resultline */ |
int nres=0; /* Index of resultline */ |
int istart=1; /* For starting graphs in projections */ |
int istart=1; /* For starting graphs in projections */ |
|
|
Line 7506 set ter svg size 640, 480\nunset log y\n
|
Line 7511 set ter svg size 640, 480\nunset log y\n
|
/*# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 */ |
/*# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 */ |
fprintf(ficgp," u %d:(", ioffset); |
fprintf(ficgp," u %d:(", ioffset); |
if(i==nlstate+1){ |
if(i==nlstate+1){ |
fprintf(ficgp," $%d/(1.-$%d)):5 t 'pw.%d' with line lc variable ", \ |
fprintf(ficgp," $%d/(1.-$%d)):1 t 'pw.%d' with line lc variable ", \ |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate,cpt ); |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate,cpt ); |
fprintf(ficgp,",\\\n '' "); |
fprintf(ficgp,",\\\n '' "); |
fprintf(ficgp," u %d:(",ioffset); |
fprintf(ficgp," u %d:(",ioffset); |
fprintf(ficgp," (($5-$6) == %d ) ? $%d/(1.-$%d) : 1/0):5 with labels center not ", \ |
fprintf(ficgp," (($1-$2) == %d ) ? $%d/(1.-$%d) : 1/0):1 with labels center not ", \ |
offyear, \ |
offyear, \ |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate ); |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate ); |
}else |
}else |
fprintf(ficgp," $%d/(1.-$%d)) t 'p%d%d' with line ", \ |
fprintf(ficgp," $%d/(1.-$%d)) t 'p%d%d' with line ", \ |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate,i,cpt ); |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate,i,cpt ); |
}else{ /* more than 2 covariates */ |
}else{ /* more than 2 covariates */ |
if(cptcoveff ==1){ |
ioffset=2*cptcoveff+2; /* Age is in 4 or 6 or etc.*/ |
ioffset=4; /* Age is in 4 */ |
/*# V1 = 1 V2 = 0 yearproj age p11 p21 p.1 p12 p22 p.2 p13 p23 p.3*/ |
}else{ |
/*# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ |
ioffset=6; /* Age is in 6 */ |
iyearc=ioffset-1; |
/*# V1 = 1 V2 = 0 yearproj age p11 p21 p.1 p12 p22 p.2 p13 p23 p.3*/ |
iagec=ioffset; |
/*# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ |
|
} |
|
fprintf(ficgp," u %d:(",ioffset); |
fprintf(ficgp," u %d:(",ioffset); |
kl=0; |
kl=0; |
strcpy(gplotcondition,"("); |
strcpy(gplotcondition,"("); |
Line 7545 set ter svg size 640, 480\nunset log y\n
|
Line 7548 set ter svg size 640, 480\nunset log y\n
|
/*6+1+(i-1)+(nlstate+1)*nlstate; 6+1+(1-1) +(2+1)*2=13 */ |
/*6+1+(i-1)+(nlstate+1)*nlstate; 6+1+(1-1) +(2+1)*2=13 */ |
/* '' u 6:(($1==1 && $2==0 && $3==2 && $4==0)? $9/(1.-$15) : 1/0):($5==2000? 3:2) t 'p.1' with line lc variable*/ |
/* '' u 6:(($1==1 && $2==0 && $3==2 && $4==0)? $9/(1.-$15) : 1/0):($5==2000? 3:2) t 'p.1' with line lc variable*/ |
if(i==nlstate+1){ |
if(i==nlstate+1){ |
fprintf(ficgp,"%s ? $%d/(1.-$%d) : 1/0):5 t 'p.%d' with line lc variable", gplotcondition, \ |
fprintf(ficgp,"%s ? $%d/(1.-$%d) : 1/0):%d t 'p.%d' with line lc variable", gplotcondition, \ |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate,cpt ); |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate,iyearc, cpt ); |
fprintf(ficgp,",\\\n '' "); |
fprintf(ficgp,",\\\n '' "); |
fprintf(ficgp," u %d:(",ioffset); |
fprintf(ficgp," u %d:(",iagec); |
fprintf(ficgp,"%s && (($5-$6) == %d ) ? $%d/(1.-$%d) : 1/0):5 with labels center not ", gplotcondition, \ |
fprintf(ficgp,"%s && (($%d-$%d) == %d ) ? $%d/(1.-$%d) : 1/0):%d with labels center not ", gplotcondition, \ |
offyear, \ |
iyearc, iagec, offyear, \ |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate ); |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate, iyearc ); |
/* '' u 6:(($1==1 && $2==0 && $3==2 && $4==0) && (($5-$6) == 1947) ? $10/(1.-$22) : 1/0):5 with labels center boxed not*/ |
/* '' u 6:(($1==1 && $2==0 && $3==2 && $4==0) && (($5-$6) == 1947) ? $10/(1.-$22) : 1/0):5 with labels center boxed not*/ |
}else{ |
}else{ |
fprintf(ficgp,"%s ? $%d/(1.-$%d) : 1/0) t 'p%d%d' with line ", gplotcondition, \ |
fprintf(ficgp,"%s ? $%d/(1.-$%d) : 1/0) t 'p%d%d' with line ", gplotcondition, \ |
Line 7621 set ter svg size 640, 480\nunset log y\n
|
Line 7624 set ter svg size 640, 480\nunset log y\n
|
/*# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 */ |
/*# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 */ |
fprintf(ficgp," u %d:(", ioffset); |
fprintf(ficgp," u %d:(", ioffset); |
if(i==nlstate+1){ |
if(i==nlstate+1){ |
fprintf(ficgp," $%d/(1.-$%d)):5 t 'bw%d' with line lc variable ", \ |
fprintf(ficgp," $%d/(1.-$%d)):1 t 'bw%d' with line lc variable ", \ |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate,cpt ); |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate,cpt ); |
fprintf(ficgp,",\\\n '' "); |
fprintf(ficgp,",\\\n '' "); |
fprintf(ficgp," u %d:(",ioffset); |
fprintf(ficgp," u %d:(",ioffset); |
fprintf(ficgp," (($5-$6) == %d ) ? $%d : 1/0):5 with labels center not ", \ |
fprintf(ficgp," (($1-$2) == %d ) ? $%d : 1/0):1 with labels center not ", \ |
offbyear, \ |
offbyear, \ |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1) ); |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1) ); |
}else |
}else |
fprintf(ficgp," $%d/(1.-$%d)) t 'b%d%d' with line ", \ |
fprintf(ficgp," $%d/(1.-$%d)) t 'b%d%d' with line ", \ |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate,cpt,i ); |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), ioffset+1+(i-1)+(nlstate+1)*nlstate,cpt,i ); |
}else{ /* more than 2 covariates */ |
}else{ /* more than 2 covariates */ |
if(cptcoveff ==1){ |
ioffset=2*cptcoveff+2; /* Age is in 4 or 6 or etc.*/ |
ioffset=4; /* Age is in 4 */ |
/*# V1 = 1 V2 = 0 yearproj age p11 p21 p.1 p12 p22 p.2 p13 p23 p.3*/ |
}else{ |
/*# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ |
ioffset=6; /* Age is in 6 */ |
iyearc=ioffset-1; |
/*# V1 = 1 V2 = 0 yearproj age p11 p21 p.1 p12 p22 p.2 p13 p23 p.3*/ |
iagec=ioffset; |
/*# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ |
|
} |
|
fprintf(ficgp," u %d:(",ioffset); |
fprintf(ficgp," u %d:(",ioffset); |
kl=0; |
kl=0; |
strcpy(gplotcondition,"("); |
strcpy(gplotcondition,"("); |
Line 7660 set ter svg size 640, 480\nunset log y\n
|
Line 7661 set ter svg size 640, 480\nunset log y\n
|
/*6+1+(i-1)+(nlstate+1)*nlstate; 6+1+(1-1) +(2+1)*2=13 */ |
/*6+1+(i-1)+(nlstate+1)*nlstate; 6+1+(1-1) +(2+1)*2=13 */ |
/* '' u 6:(($1==1 && $2==0 && $3==2 && $4==0)? $9/(1.-$15) : 1/0):($5==2000? 3:2) t 'p.1' with line lc variable*/ |
/* '' u 6:(($1==1 && $2==0 && $3==2 && $4==0)? $9/(1.-$15) : 1/0):($5==2000? 3:2) t 'p.1' with line lc variable*/ |
if(i==nlstate+1){ |
if(i==nlstate+1){ |
fprintf(ficgp,"%s ? $%d : 1/0):5 t 'bw%d' with line lc variable", gplotcondition, \ |
fprintf(ficgp,"%s ? $%d : 1/0):%d t 'bw%d' with line lc variable", gplotcondition, \ |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1),cpt ); |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1),iyearc,cpt ); |
fprintf(ficgp,",\\\n '' "); |
fprintf(ficgp,",\\\n '' "); |
fprintf(ficgp," u %d:(",ioffset); |
fprintf(ficgp," u %d:(",iagec); |
/* fprintf(ficgp,"%s && (($5-$6) == %d ) ? $%d/(1.-$%d) : 1/0):5 with labels center not ", gplotcondition, \ */ |
/* fprintf(ficgp,"%s && (($5-$6) == %d ) ? $%d/(1.-$%d) : 1/0):5 with labels center not ", gplotcondition, \ */ |
fprintf(ficgp,"%s && (($5-$6) == %d ) ? $%d : 1/0):5 with labels center not ", gplotcondition, \ |
fprintf(ficgp,"%s && (($%d-$%d) == %d ) ? $%d : 1/0):%d with labels center not ", gplotcondition, \ |
offbyear, \ |
iyearc,iagec,offbyear, \ |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1) ); |
ioffset+(cpt-1)*(nlstate+1)+1+(i-1), iyearc ); |
/* '' u 6:(($1==1 && $2==0 && $3==2 && $4==0) && (($5-$6) == 1947) ? $10/(1.-$22) : 1/0):5 with labels center boxed not*/ |
/* '' u 6:(($1==1 && $2==0 && $3==2 && $4==0) && (($5-$6) == 1947) ? $10/(1.-$22) : 1/0):5 with labels center boxed not*/ |
}else{ |
}else{ |
/* fprintf(ficgp,"%s ? $%d/(1.-$%d) : 1/0) t 'p%d%d' with line ", gplotcondition, \ */ |
/* fprintf(ficgp,"%s ? $%d/(1.-$%d) : 1/0) t 'p%d%d' with line ", gplotcondition, \ */ |
Line 8154 set ter svg size 640, 480\nunset log y\n
|
Line 8155 set ter svg size 640, 480\nunset log y\n
|
if(estepm < stepm){ |
if(estepm < stepm){ |
printf ("Problem %d lower than %d\n",estepm, stepm); |
printf ("Problem %d lower than %d\n",estepm, stepm); |
} |
} |
else hstepm=estepm; |
else{ |
|
hstepm=estepm; |
|
} |
|
if(estepm > stepm){ /* Yes every two year */ |
|
stepsize=2; |
|
} |
|
|
hstepm=hstepm/stepm; |
hstepm=hstepm/stepm; |
yp1=modf(dateintmean,&yp);/* extracts integral of datemean in yp and |
yp1=modf(dateintmean,&yp);/* extracts integral of datemean in yp and |
Line 8199 set ter svg size 640, 480\nunset log y\n
|
Line 8205 set ter svg size 640, 480\nunset log y\n
|
for (yearp=0; yearp<=(anproj2-anproj1);yearp +=stepsize) { |
for (yearp=0; yearp<=(anproj2-anproj1);yearp +=stepsize) { |
fprintf(ficresf,"\n"); |
fprintf(ficresf,"\n"); |
fprintf(ficresf,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+yearp); |
fprintf(ficresf,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+yearp); |
for (agec=fage; agec>=(ageminpar-1); agec--){ |
/* for (agec=fage; agec>=(ageminpar-1); agec--){ */ |
|
for (agec=fage; agec>=(bage); agec--){ |
nhstepm=(int) rint((agelim-agec)*YEARM/stepm); |
nhstepm=(int) rint((agelim-agec)*YEARM/stepm); |
nhstepm = nhstepm/hstepm; |
nhstepm = nhstepm/hstepm; |
p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); |
p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); |
Line 8287 set ter svg size 640, 480\nunset log y\n
|
Line 8294 set ter svg size 640, 480\nunset log y\n
|
if(estepm < stepm){ |
if(estepm < stepm){ |
printf ("Problem %d lower than %d\n",estepm, stepm); |
printf ("Problem %d lower than %d\n",estepm, stepm); |
} |
} |
else hstepm=estepm; |
else{ |
|
hstepm=estepm; |
|
} |
|
if(estepm >= stepm){ /* Yes every two year */ |
|
stepsize=2; |
|
} |
|
|
hstepm=hstepm/stepm; |
hstepm=hstepm/stepm; |
yp1=modf(dateintmean,&yp);/* extracts integral of datemean in yp and |
yp1=modf(dateintmean,&yp);/* extracts integral of datemean in yp and |
Line 8334 set ter svg size 640, 480\nunset log y\n
|
Line 8346 set ter svg size 640, 480\nunset log y\n
|
fprintf(ficresfb,"\n"); |
fprintf(ficresfb,"\n"); |
fprintf(ficresfb,"\n# Back Forecasting at date %.lf/%.lf/%.lf ",jback1,mback1,anback1+yearp); |
fprintf(ficresfb,"\n# Back Forecasting at date %.lf/%.lf/%.lf ",jback1,mback1,anback1+yearp); |
/* printf("\n# Back Forecasting at date %.lf/%.lf/%.lf ",jback1,mback1,anback1+yearp); */ |
/* printf("\n# Back Forecasting at date %.lf/%.lf/%.lf ",jback1,mback1,anback1+yearp); */ |
for (agec=bage; agec<=agemax-1; agec++){ /* testing */ |
/* for (agec=bage; agec<=agemax-1; agec++){ /\* testing *\/ */ |
|
for (agec=bage; agec<=fage; agec++){ /* testing */ |
/* We compute bij at age agec over nhstepm, nhstepm decreases when agec increases because of agemax;*/ |
/* We compute bij at age agec over nhstepm, nhstepm decreases when agec increases because of agemax;*/ |
nhstepm=(int) rint((agec-agelim)*YEARM/stepm); |
nhstepm=(int) rint((agec-agelim)*YEARM/stepm); |
nhstepm = nhstepm/hstepm; |
nhstepm = nhstepm/hstepm; |
Line 12071 Please run with mle=-1 to get a correct
|
Line 12084 Please run with mle=-1 to get a correct
|
This is probably because your parameter file doesn't \n contain the exact number of lines (or columns) corresponding to your model line.\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); |
Please run with mle=-1 to get a correct covariance matrix.\n",ageminpar,agemaxpar); |
}else{ |
}else{ |
printinggnuplot(fileresu, optionfilefiname,ageminpar,agemaxpar,fage, prevfcast, backcast, pathc,p, (int)anproj1-(int)agemin, (int)anback1-(int)agemax+1); |
/* printinggnuplot(fileresu, optionfilefiname,ageminpar,agemaxpar,fage, prevfcast, backcast, pathc,p, (int)anproj1-(int)agemin, (int)anback1-(int)agemax+1); */ |
|
printinggnuplot(fileresu, optionfilefiname,ageminpar,agemaxpar,bage, fage, prevfcast, backcast, pathc,p, (int)anproj1-bage, (int)anback1-fage); |
} |
} |
printinghtml(fileresu,title,datafile, firstpass, lastpass, stepm, weightopt, \ |
printinghtml(fileresu,title,datafile, firstpass, lastpass, stepm, weightopt, \ |
model,imx,jmin,jmax,jmean,rfileres,popforecast,mobilav,prevfcast,mobilavproj,backcast, estepm, \ |
model,imx,jmin,jmax,jmean,rfileres,popforecast,mobilav,prevfcast,mobilavproj,backcast, estepm, \ |