--- imach/src/imach.c 2022/08/31 09:52:36 1.336
+++ imach/src/imach.c 2022/09/04 17:40:33 1.338
@@ -1,6 +1,20 @@
-/* $Id: imach.c,v 1.336 2022/08/31 09:52:36 brouard Exp $
+/* $Id: imach.c,v 1.338 2022/09/04 17:40:33 brouard Exp $
$State: Exp $
$Log: imach.c,v $
+ Revision 1.338 2022/09/04 17:40:33 brouard
+ Summary: 0.99r36
+
+ * imach.c (Module): Now the easy runs i.e. without result or
+ model=1+age only did not work. The defautl combination should be 1
+ and not 0 because everything hasn't been tranformed yet.
+
+ Revision 1.337 2022/09/02 14:26:02 brouard
+ Summary: version 0.99r35
+
+ * src/imach.c: Version 0.99r35 because it outputs same results with
+ 1+age+V1+V1*age for females and 1+age for females only
+ (education=1 noweight)
+
Revision 1.336 2022/08/31 09:52:36 brouard
*** empty log message ***
@@ -1287,12 +1301,12 @@ typedef struct {
#define ODIRSEPARATOR '\\'
#endif
-/* $Id: imach.c,v 1.336 2022/08/31 09:52:36 brouard Exp $ */
+/* $Id: imach.c,v 1.338 2022/09/04 17:40:33 brouard Exp $ */
/* $State: Exp $ */
#include "version.h"
char version[]=__IMACH_VERSION__;
-char copyright[]="August 2022,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015-2020, Nihon University 2021-202, INED 2000-2022";
-char fullversion[]="$Revision: 1.336 $ $Date: 2022/08/31 09:52:36 $";
+char copyright[]="September 2022,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015-2020, Nihon University 2021-202, INED 2000-2022";
+char fullversion[]="$Revision: 1.338 $ $Date: 2022/09/04 17:40:33 $";
char strstart[80];
char optionfilext[10], optionfilefiname[FILENAMELENGTH];
int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */
@@ -1508,8 +1522,9 @@ int **nbcode, *Tvar; /**< model=V2 => Tv
/*Tvar[k]= 5 4 3 6 5 2 7 1 1 */
/* nsd 1 2 3 */ /* Counting single dummies covar fixed or tv */
/*TnsdVar[Tvar] 1 2 3 */
+/*Tvaraff[nsd] 4 3 1 */ /* ID of single dummy cova fixed or timevary*/
/*TvarsD[nsd] 4 3 1 */ /* ID of single dummy cova fixed or timevary*/
-/*TvarsDind[k] 2 3 9 */ /* position K of single dummy cova */
+/*TvarsDind[nsd] 2 3 9 */ /* position K of single dummy cova */
/* nsq 1 2 */ /* Counting single quantit tv */
/* TvarsQ[k] 5 2 */ /* Number of single quantitative cova */
/* TvarsQind 1 6 */ /* position K of single quantitative cova */
@@ -2502,7 +2517,8 @@ void powell(double p[], double **xi, int
xits=vector(1,n);
*fret=(*func)(p);
for (j=1;j<=n;j++) pt[j]=p[j];
- rcurr_time = time(NULL);
+ rcurr_time = time(NULL);
+ fp=(*fret); /* Initialisation */
for (*iter=1;;++(*iter)) {
ibig=0;
del=0.0;
@@ -2510,8 +2526,10 @@ void powell(double p[], double **xi, int
/* (void) gettimeofday(&curr_time,&tzp); */
rcurr_time = time(NULL);
curr_time = *localtime(&rcurr_time);
- printf("\nPowell iter=%d -2*LL=%.12f gain=%.12f=%.3g %ld sec. %ld sec.",*iter,*fret, fp-*fret,fp-*fret, rcurr_time-rlast_time, rcurr_time-rstart_time);fflush(stdout);
- fprintf(ficlog,"\nPowell iter=%d -2*LL=%.12f gain=%.12f=%.3g %ld sec. %ld sec.",*iter,*fret, fp-*fret,fp-*fret,rcurr_time-rlast_time, rcurr_time-rstart_time); fflush(ficlog);
+ /* printf("\nPowell iter=%d -2*LL=%.12f gain=%.12f=%.3g %ld sec. %ld sec.",*iter,*fret, fp-*fret,fp-*fret, rcurr_time-rlast_time, rcurr_time-rstart_time);fflush(stdout); */
+ /* fprintf(ficlog,"\nPowell iter=%d -2*LL=%.12f gain=%.12f=%.3g %ld sec. %ld sec.",*iter,*fret, fp-*fret,fp-*fret,rcurr_time-rlast_time, rcurr_time-rstart_time); fflush(ficlog); */
+ printf("\nPowell iter=%d -2*LL=%.12f gain=%.3lg %ld sec. %ld sec.",*iter,*fret,fp-*fret, rcurr_time-rlast_time, rcurr_time-rstart_time);fflush(stdout);
+ fprintf(ficlog,"\nPowell iter=%d -2*LL=%.12f gain=%.3lg %ld sec. %ld sec.",*iter,*fret,fp-*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); */
fp=(*fret); /* From former iteration or initial value */
for (i=1;i<=n;i++) {
@@ -2814,7 +2832,7 @@ void powell(double p[], double **xi, int
double **prevalim(double **prlim, int nlstate, double x[], double age, double **oldm, double **savm, double ftolpl, int *ncvyear, int ij, int nres)
{
- /**< Computes the prevalence limit in each live state at age x and for covariate combination ij
+ /**< Computes the prevalence limit in each live state at age x and for covariate combination ij . Nicely done
* (and selected quantitative values in nres)
* by left multiplying the unit
* matrix by transitions matrix until convergence is reached with precision ftolpl
@@ -5119,7 +5137,7 @@ Title=%s
Datafile=%s Firstpass=%d La
/* }else */ /* TODO TODO codtabm(j1,z1) or codtabm(j1,Tvaraff[z1]]z1)*/
/* if( iind >=imx-3) printf("Searching error iind=%d Tvaraff[z1]=%d covar[Tvaraff[z1]][iind]=%.f TnsdVar[Tvaraff[z1]]=%d, cptcoveff=%d, cptcovs=%d \n",iind, Tvaraff[z1], covar[Tvaraff[z1]][iind],TnsdVar[Tvaraff[z1]],cptcoveff, cptcovs); */
if(Tvaraff[z1]<1 || Tvaraff[z1]>=NCOVMAX)
- printf("Error Tvaraff[z1]=%d<1 or >=%d, cptcoveff=%d model=%s\n",Tvaraff[z1],NCOVMAX, cptcoveff, model);
+ printf("Error Tvaraff[z1]=%d<1 or >=%d, cptcoveff=%d model=1+age+%s\n",Tvaraff[z1],NCOVMAX, cptcoveff, model);
if (covar[Tvaraff[z1]][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,TnsdVar[Tvaraff[z1]])]){ /* for combination j1 of covariates */
/* Tests if the value of the covariate z1 for this individual iind responded to combination j1 (V4=1 V3=0) */
bool=0; /* bool should be equal to 1 to be selected, one covariate value failed */
@@ -5429,7 +5447,7 @@ Title=%s
Datafile=%s Firstpass=%d La
printf("# This combination (%d) is not valid and no result will be produced\n",j1);
invalidvarcomb[j1]=1;
}else{
- fprintf(ficresphtm,"\n
This combination (%d) is valid and result will be produced.
",j1); + fprintf(ficresphtm,"\nThis combination (%d) is valid and result will be produced (or no resultline).
",j1); invalidvarcomb[j1]=0; } fprintf(ficresphtmfr,"\n"); @@ -6542,11 +6560,16 @@ void concatwav(int wav[], int **dh, int pstamp(ficresprobmorprev); fprintf(ficresprobmorprev,"# probabilities of dying before estepm=%d months for people of exact age and weighted probabilities w1*p1j+w2*p2j+... stand dev in()\n",estepm); fprintf(ficresprobmorprev,"# Selected quantitative variables and dummies"); - for (j=1; j<= nsq; j++){ /* For each selected (single) quantitative value */ /* To be done*/ - fprintf(ficresprobmorprev," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]); + + /* We use TinvDoQresult[nres][resultmodel[nres][j] we sort according to the equation model and the resultline: it is a choice */ + /* for (j=1; j<= nsq; j++){ /\* For each selected (single) quantitative value *\/ /\* To be done*\/ */ + /* fprintf(ficresprobmorprev," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]); */ + /* } */ + for (j=1; j<= cptcovs; j++){ /* For each selected (single) quantitative value */ /* To be done*/ + fprintf(ficresprobmorprev," V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][Tvresult[nres][j]]); } - for(j=1;j<=cptcoveff;j++) - fprintf(ficresprobmorprev," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(ij,TnsdVar[Tvaraff[j]])]); + /* for(j=1;j<=cptcoveff;j++) */ + /* fprintf(ficresprobmorprev," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(ij,TnsdVar[Tvaraff[j]])]); */ fprintf(ficresprobmorprev,"\n"); fprintf(ficresprobmorprev,"# Age cov=%-d",ij); @@ -7193,9 +7216,9 @@ To be simple, these graphs help to under /* Including quantitative variables of the resultline to be done */ for (z1=1; z1<=cptcovs; z1++){ /* Loop on each variable of this resultline */ - printf("Varprob modelresult[%d][%d]=%d model=%s \n",nres, z1, modelresult[nres][z1], model); - fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=%s \n",nres, z1, modelresult[nres][z1], model); - /* fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=%s resultline[%d]=%s \n",nres, z1, modelresult[nres][z1], model, nres, resultline[nres]); */ + printf("Varprob modelresult[%d][%d]=%d model=1+age+%s \n",nres, z1, modelresult[nres][z1], model); + fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=1+age+%s \n",nres, z1, modelresult[nres][z1], model); + /* fprintf(ficlog,"Varprob modelresult[%d][%d]=%d model=1+age+%s resultline[%d]=%s \n",nres, z1, modelresult[nres][z1], model, nres, resultline[nres]); */ if(Dummy[modelresult[nres][z1]]==0){/* Dummy variable of the variable in position modelresult in the model corresponding to z1 in resultline */ if(Fixed[modelresult[nres][z1]]==0){ /* Fixed referenced to model equation */ fprintf(ficresprob,"V%d=%d ",Tvresult[nres][z1],Tresult[nres][z1]); /* Output of each value for the combination TKresult[nres], ordere by the covariate values in the resultline */ @@ -7217,7 +7240,7 @@ To be simple, these graphs help to under } }else if(Dummy[modelresult[nres][z1]]==1){ /* Quanti variable */ /* For each selected (single) quantitative value */ - fprintf(ficresprob," V%d=%f ",Tvqresult[nres][z1],Tqresult[nres][z1]); + fprintf(ficresprob," V%d=%lg ",Tvqresult[nres][z1],Tqresult[nres][z1]); if(Fixed[modelresult[nres][z1]]==0){ /* Fixed */ fprintf(ficresprob,"fixed "); fprintf(ficresprobcov,"fixed "); @@ -7564,29 +7587,39 @@ void printinghtml(char fileresu[], char jj1=0; fprintf(fichtm," \n");
fprintf(fichtm,"
************ Results for covariates");
- for (cpt=1; cpt<=cptcoveff;cpt++){
- fprintf(fichtm," V%d=%d ",Tvresult[nres][cpt],(int)Tresult[nres][cpt]);
- printf(" V%d=%d ",Tvresult[nres][cpt],Tresult[nres][cpt]);fflush(stdout);
+ for (cpt=1; cpt<=cptcovs;cpt++){
+ fprintf(fichtm," V%d=%lg ",Tvresult[nres][cpt],TinvDoQresult[nres][Tvresult[nres][cpt]]);
+ printf(" V%d=%lg ",Tvresult[nres][cpt],TinvDoQresult[nres][Tvresult[nres][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); */
}
- for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
- fprintf(fichtm," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]);
- printf(" V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]);fflush(stdout);
- }
-
/* if(nqfveff+nqtveff 0) */ /* Test to be done */
- fprintf(fichtm," (model=%s) ************\n
",model);
+ fprintf(fichtm," (model=1+age+%s) ************\n
",model);
if(invalidvarcomb[k1]){
fprintf(fichtm,"\nCombination (%d) ignored because no cases
\n",k1);
printf("\nCombination (%d) ignored because no cases \n",k1);
@@ -7664,14 +7695,15 @@ divided by h: hPij
/* Period (forward stable) prevalence in each health state */
for(cpt=1; cpt<=nlstate;cpt++){
fprintf(fichtm,"
\n- Convergence to period (stable) prevalence in state %d. Or probability for a person being in state (1 to %d) at different ages, to be in state %d some years after. %s_%d-%d-%d.svg
", cpt, nlstate, cpt, subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);
- fprintf(fichtm," (data from text file %s.txt)\n
",subdirf2(optionfilefiname,"P_"),subdirf2(optionfilefiname,"P_"));
+ fprintf(fichtm," (data from text file %s.txt)\n
",subdirf2(optionfilefiname,"PIJ_"),subdirf2(optionfilefiname,"PIJ_"));
fprintf(fichtm,"" ,subdirf2(optionfilefiname,"P_"),cpt,k1,nres);
}
if(prevbcast==1){
/* Backward prevalence in each health state */
for(cpt=1; cpt<=nlstate;cpt++){
- fprintf(fichtm,"
\n- Convergence to mixed (stable) back prevalence in state %d. Or probability for a person to be in state %d at a younger age, knowing that she/he was in state (1 to %d) at different older ages. %s_%d-%d-%d.svg
\
-", cpt, cpt, nlstate, subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres);
+ fprintf(fichtm,"
\n- Convergence to mixed (stable) back prevalence in state %d. Or probability for a person to be in state %d at a younger age, knowing that she/he was in state (1 to %d) at different older ages. %s_%d-%d-%d.svg
", cpt, cpt, nlstate, subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres);
+ fprintf(fichtm," (data from text file %s.txt)\n
",subdirf2(optionfilefiname,"PIJB_"),subdirf2(optionfilefiname,"PIJB_"));
+ fprintf(fichtm,"" ,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres);
}
}
if(prevfcast==1){
@@ -7701,7 +7733,7 @@ with weights corresponding to observed p
fprintf(fichtm,"", subdirf2(optionfilefiname,"EXP_"),cpt,k1,nres );
}
/* } /\* end i1 *\/ */
- }/* End k1 */
+ }/* End k1=nres */
fprintf(fichtm,"
");
fprintf(fichtm,"
************ Results for covariates");
- for (cpt=1; cpt<=cptcoveff;cpt++){ /**< cptcoveff number of variables */
- fprintf(fichtm," V%d=%d ",Tvresult[nres][cpt],Tresult[nres][cpt]);
- printf(" V%d=%d ",Tvresult[nres][cpt],Tresult[nres][cpt]);fflush(stdout);
+ for (cpt=1; cpt<=cptcovs;cpt++){ /**< cptcoveff number of variables */
+ fprintf(fichtm," V%d=%lg ",Tvresult[nres][cpt],TinvDoQresult[nres][Tvresult[nres][cpt]]);
+ printf(" V%d=%lg ",Tvresult[nres][cpt],TinvDoQresult[nres][Tvresult[nres][cpt]]);
/* fprintf(fichtm," V%d=%d ",Tvaraff[cpt],nbcode[Tvaraff[cpt]][codtabm(jj1,cpt)]); */
}
- for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
- fprintf(fichtm," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]);
- }
- fprintf(fichtm," (model=%s) ************\n
",model);
+ fprintf(fichtm," (model=1+age+%s) ************\n
",model);
if(invalidvarcomb[k1]){
fprintf(fichtm,"\nCombination (%d) ignored because no cases
\n",k1);
continue;
}
- }
+ } /* If cptcovn >0 */
for(cpt=1; cpt<=nlstate;cpt++) {
fprintf(fichtm,"\n
- Observed (cross-sectional with mov_average=%d) and period (incidence based) \
prevalence (with 95%% confidence interval) in state (%d): %s_%d-%d-%d.svg",mobilav,cpt,subdirf2(optionfilefiname,"V_"),cpt,k1,nres,subdirf2(optionfilefiname,"V_"),cpt,k1,nres);
@@ -7840,7 +7865,6 @@ true period expectancies (those weighted
fprintf(fichtm," (data from text file %s.txt) \n
",subdirf2(optionfilefiname,"T_"),subdirf2(optionfilefiname,"T_"));
fprintf(fichtm,"",subdirf2(optionfilefiname,"E_"),k1,nres);
/* } /\* end i1 *\/ */
- }/* End k1 */
}/* End nres */
fprintf(fichtm,"");
fflush(fichtm);
@@ -7918,31 +7942,37 @@ void printinggnuplot(char fileresu[], ch
strcpy(optfileres,"vpl");
/* 1eme*/
for (cpt=1; cpt<= nlstate ; cpt ++){ /* For each live state */
- for (k1=1; k1<= m ; k1 ++){ /* For each valid combination of covariate */
+ /* for (k1=1; k1<= m ; k1 ++){ /\* For each valid combination of covariate *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
/* plot [100000000000000000000:-100000000000000000000] "mysbiaspar/vplrmysbiaspar.txt to check */
- if(m != 1 && TKresult[nres]!= k1)
- continue;
+ /* if(m != 1 && TKresult[nres]!= k1) */
+ /* continue; */
/* We are interested in selected combination by the resultline */
/* printf("\n# 1st: Period (stable) prevalence with CI: 'VPL_' files and live state =%d ", cpt); */
fprintf(ficgp,"\n# 1st: Forward (stable period) prevalence with CI: 'VPL_' files and live state =%d ", cpt);
strcpy(gplotlabel,"(");
- for (k=1; k<=cptcoveff; k++){ /* For each covariate k get corresponding value lv for combination k1 */
- /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the value of the covariate corresponding to k1 combination *\/ */
- lv=codtabm(k1,TnsdVar[Tvaraff[k]]);
- /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */
- /* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */
- /* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */
- vlv= nbcode[Tvaraff[k]][lv]; /* vlv is the value of the covariate lv, 0 or 1 */
- /* For each combination of covariate k1 (V1=1, V3=0), we printed the current covariate k and its value vlv */
- /* printf(" V%d=%d ",Tvaraff[k],vlv); */
- fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv);
- }
- for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
- /* printf(" V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); */
- fprintf(ficgp," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]);
+ for (k=1; k<=cptcovs; k++){ /* For each covariate k get corresponding value lv for combination k1 */
+ fprintf(ficgp," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ sprintf(gplotlabel+strlen(gplotlabel)," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+
+ /* for (k=1; k<=cptcoveff; k++){ /\* For each covariate k get corresponding value lv for combination k1 *\/ */
+ /* /\* lv= decodtabm(k1,k,cptcoveff); /\\* Should be the value of the covariate corresponding to k1 combination *\\/ *\/ */
+ /* lv=codtabm(k1,TnsdVar[Tvaraff[k]]); */
+ /* /\* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 *\/ */
+ /* /\* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 *\/ */
+ /* /\* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 *\/ */
+ /* vlv= nbcode[Tvaraff[k]][lv]; /\* vlv is the value of the covariate lv, 0 or 1 *\/ */
+ /* /\* For each combination of covariate k1 (V1=1, V3=0), we printed the current covariate k and its value vlv *\/ */
+ /* /\* printf(" V%d=%d ",Tvaraff[k],vlv); *\/ */
+ /* fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv); */
+ /* } */
+ /* for (k4=1; k4<= nsq; k4++){ /\* For each selected (single) quantitative value *\/ */
+ /* /\* printf(" V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); *\/ */
+ /* fprintf(ficgp," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); */
}
strcpy(gplotlabel+strlen(gplotlabel),")");
/* printf("\n#\n"); */
@@ -7956,7 +7986,7 @@ void printinggnuplot(char fileresu[], ch
fprintf(ficgp,"\nset out \"%s_%d-%d-%d.svg\" \n",subdirf2(optionfilefiname,"V_"),cpt,k1,nres);
fprintf(ficgp,"\n#set out \"V_%s_%d-%d-%d.svg\" \n",optionfilefiname,cpt,k1,nres);
/* fprintf(ficgp,"set label \"Alive state %d %s\" at graph 0.98,0.5 center rotate font \"Helvetica,12\"\n",cpt,gplotlabel); */
- fprintf(ficgp,"set title \"Alive state %d %s model=%s\" font \"Helvetica,12\"\n",cpt,gplotlabel,model);
+ fprintf(ficgp,"set title \"Alive state %d %s model=1+age+%s\" font \"Helvetica,12\"\n",cpt,gplotlabel,model);
fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),nres-1,nres-1,nres);
/* fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter svg size 640, 480\nplot [%.f:%.f] \"%s\" every :::%d::%d u 1:($2==%d ? $3:1/0) \"%%lf %%lf",ageminpar,fage,subdirf2(fileresu,"VPL_"),k1-1,k1-1,nres); */
/* k1-1 error should be nres-1*/
@@ -8055,33 +8085,38 @@ void printinggnuplot(char fileresu[], ch
/* fprintf(ficgp,"\nset out ;unset label;\n"); */
fprintf(ficgp,"\nset out ;unset title;\n");
} /* nres */
- } /* k1 */
+ /* } /\* k1 *\/ */
} /* cpt */
/*2 eme*/
- for (k1=1; k1<= m ; k1 ++){
+ /* for (k1=1; k1<= m ; k1 ++){ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
- if(m != 1 && TKresult[nres]!= k1)
- continue;
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
+ /* if(m != 1 && TKresult[nres]!= k1) */
+ /* continue; */
fprintf(ficgp,"\n# 2nd: Total life expectancy with CI: 't' files ");
strcpy(gplotlabel,"(");
- for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */
- /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate number corresponding to k1 combination *\/ */
- lv=codtabm(k1,TnsdVar[Tvaraff[k]]);
- /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */
- /* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */
- /* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */
- /* vlv= nbcode[Tvaraff[k]][lv]; */
- vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])];
- fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv);
- }
- /* for(k=1; k <= ncovds; k++){ */
- for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
- printf(" V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]);
- fprintf(ficgp," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]);
+ for (k=1; k<=cptcovs; k++){ /* For each covariate k get corresponding value lv for combination k1 */
+ fprintf(ficgp," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ sprintf(gplotlabel+strlen(gplotlabel)," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ /* for (k=1; k<=cptcoveff; k++){ /\* For each covariate and each value *\/ */
+ /* /\* lv= decodtabm(k1,k,cptcoveff); /\\* Should be the covariate number corresponding to k1 combination *\\/ *\/ */
+ /* lv=codtabm(k1,TnsdVar[Tvaraff[k]]); */
+ /* /\* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 *\/ */
+ /* /\* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 *\/ */
+ /* /\* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 *\/ */
+ /* /\* vlv= nbcode[Tvaraff[k]][lv]; *\/ */
+ /* vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])]; */
+ /* fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv); */
+ /* } */
+ /* /\* for(k=1; k <= ncovds; k++){ *\/ */
+ /* for (k4=1; k4<= nsq; k4++){ /\* For each selected (single) quantitative value *\/ */
+ /* printf(" V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); */
+ /* fprintf(ficgp," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); */
}
strcpy(gplotlabel+strlen(gplotlabel),")");
fprintf(ficgp,"\n#\n");
@@ -8123,33 +8158,38 @@ void printinggnuplot(char fileresu[], ch
} /* vpopbased */
fprintf(ficgp,"\nset out;set out \"%s_%d-%d.svg\"; replot; set out; unset label;\n",subdirf2(optionfilefiname,"E_"),k1,nres); /* Buggy gnuplot */
} /* end nres */
- } /* k1 end 2 eme*/
+ /* } /\* k1 end 2 eme*\/ */
/*3eme*/
- for (k1=1; k1<= m ; k1 ++){
+ /* for (k1=1; k1<= m ; k1 ++){ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
- if(m != 1 && TKresult[nres]!= k1)
- continue;
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
+ /* if(m != 1 && TKresult[nres]!= k1) */
+ /* continue; */
for (cpt=1; cpt<= nlstate ; cpt ++) { /* Fragile no verification of covariate values */
fprintf(ficgp,"\n\n# 3d: Life expectancy with EXP_ files: combination=%d state=%d",k1, cpt);
strcpy(gplotlabel,"(");
- for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */
- /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate number corresponding to k1 combination *\/ */
- lv= codtabm(k1,TnsdVar[Tvaraff[k]]); /* Should be the covariate value corresponding to combination k1 and covariate k */
- /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */
- /* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */
- /* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */
- /* vlv= nbcode[Tvaraff[k]][lv]; */
- vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])];
- fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv);
- }
- for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
- fprintf(ficgp," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][resultmodel[nres][k4]]);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][resultmodel[nres][k4]]);
- }
+ for (k=1; k<=cptcovs; k++){ /* For each covariate k get corresponding value lv for combination k1 */
+ fprintf(ficgp," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ sprintf(gplotlabel+strlen(gplotlabel)," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ /* for (k=1; k<=cptcoveff; k++){ /\* For each covariate and each value *\/ */
+ /* /\* lv= decodtabm(k1,k,cptcoveff); /\\* Should be the covariate number corresponding to k1 combination *\\/ *\/ */
+ /* lv= codtabm(k1,TnsdVar[Tvaraff[k]]); /\* Should be the covariate value corresponding to combination k1 and covariate k *\/ */
+ /* /\* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 *\/ */
+ /* /\* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 *\/ */
+ /* /\* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 *\/ */
+ /* /\* vlv= nbcode[Tvaraff[k]][lv]; *\/ */
+ /* vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])]; */
+ /* fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv); */
+ /* } */
+ /* for (k4=1; k4<= nsq; k4++){ /\* For each selected (single) quantitative value *\/ */
+ /* fprintf(ficgp," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][resultmodel[nres][k4]]); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][resultmodel[nres][k4]]); */
+ }
strcpy(gplotlabel+strlen(gplotlabel),")");
fprintf(ficgp,"\n#\n");
if(invalidvarcomb[k1]){
@@ -8180,31 +8220,36 @@ plot [%.f:%.f] \"%s\" every :::%d::%d u
}
fprintf(ficgp,"\nunset label;\n");
} /* end nres */
- } /* end kl 3eme */
+ /* } /\* end kl 3eme *\/ */
/* 4eme */
/* Survival functions (period) from state i in state j by initial state i */
- for (k1=1; k1<=m; k1++){ /* For each covariate and each value */
+ /* for (k1=1; k1<=m; k1++){ /\* For each covariate and each value *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
- if(m != 1 && TKresult[nres]!= k1)
- continue;
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
+ /* if(m != 1 && TKresult[nres]!= k1) */
+ /* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state cpt*/
strcpy(gplotlabel,"(");
- fprintf(ficgp,"\n#\n#\n# Survival functions in state j : 'LIJ_' files, cov=%d state=%d",k1, cpt);
- for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */
- lv=codtabm(k1,TnsdVar[Tvaraff[k]]);
- /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate number corresponding to k1 combination *\/ */
- /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */
- /* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */
- /* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */
- /* vlv= nbcode[Tvaraff[k]][lv]; */
- vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])];
- fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv);
- }
- for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
- fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
+ fprintf(ficgp,"\n#\n#\n# Survival functions in state %d : 'LIJ_' files, cov=%d state=%d", cpt, k1, cpt);
+ for (k=1; k<=cptcovs; k++){ /* For each covariate k get corresponding value lv for combination k1 */
+ fprintf(ficgp," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ sprintf(gplotlabel+strlen(gplotlabel)," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ /* for (k=1; k<=cptcoveff; k++){ /\* For each covariate and each value *\/ */
+ /* lv=codtabm(k1,TnsdVar[Tvaraff[k]]); */
+ /* /\* lv= decodtabm(k1,k,cptcoveff); /\\* Should be the covariate number corresponding to k1 combination *\\/ *\/ */
+ /* /\* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 *\/ */
+ /* /\* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 *\/ */
+ /* /\* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 *\/ */
+ /* /\* vlv= nbcode[Tvaraff[k]][lv]; *\/ */
+ /* vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])]; */
+ /* fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv); */
+ /* } */
+ /* for (k4=1; k4<= nsq; k4++){ /\* For each selected (single) quantitative value *\/ */
+ /* fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
}
strcpy(gplotlabel+strlen(gplotlabel),")");
fprintf(ficgp,"\n#\n");
@@ -8233,31 +8278,36 @@ set ter svg size 640, 480\nunset log y\n
fprintf(ficgp,"\nset out; unset label;\n");
} /* end cpt state*/
} /* end nres */
- } /* end covariate k1 */
+ /* } /\* end covariate k1 *\/ */
/* 5eme */
/* Survival functions (period) from state i in state j by final state j */
- for (k1=1; k1<= m ; k1++){ /* For each covariate combination if any */
+ /* for (k1=1; k1<= m ; k1++){ /\* For each covariate combination if any *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
- if(m != 1 && TKresult[nres]!= k1)
- continue;
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
+ /* if(m != 1 && TKresult[nres]!= k1) */
+ /* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each inital state */
strcpy(gplotlabel,"(");
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);
- for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */
- lv=codtabm(k1,TnsdVar[Tvaraff[k]]);
- /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate number corresponding to k1 combination *\/ */
- /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */
- /* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */
- /* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */
- /* vlv= nbcode[Tvaraff[k]][lv]; */
- vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])];
- fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv);
- }
- for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
- fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
+ for (k=1; k<=cptcovs; k++){ /* For each covariate k get corresponding value lv for combination k1 */
+ fprintf(ficgp," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ sprintf(gplotlabel+strlen(gplotlabel)," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ /* for (k=1; k<=cptcoveff; k++){ /\* For each covariate and each value *\/ */
+ /* lv=codtabm(k1,TnsdVar[Tvaraff[k]]); */
+ /* /\* lv= decodtabm(k1,k,cptcoveff); /\\* Should be the covariate number corresponding to k1 combination *\\/ *\/ */
+ /* /\* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 *\/ */
+ /* /\* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 *\/ */
+ /* /\* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 *\/ */
+ /* /\* vlv= nbcode[Tvaraff[k]][lv]; *\/ */
+ /* vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])]; */
+ /* fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv); */
+ /* } */
+ /* for (k4=1; k4<= nsq; k4++){ /\* For each selected (single) quantitative value *\/ */
+ /* fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
}
strcpy(gplotlabel+strlen(gplotlabel),")");
fprintf(ficgp,"\n#\n");
@@ -8293,32 +8343,37 @@ set ter svg size 640, 480\nunset log y\n
}
fprintf(ficgp,"\nset out; unset label;\n");
} /* end cpt state*/
- } /* end covariate */
+ /* } /\* end covariate *\/ */
} /* end nres */
/* 6eme */
/* CV preval stable (period) for each covariate */
- for (k1=1; k1<= m ; k1 ++) /* For each covariate combination if any */
+ /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
- if(m != 1 && TKresult[nres]!= k1)
- continue;
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
+ /* if(m != 1 && TKresult[nres]!= k1) */
+ /* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state of arrival */
strcpy(gplotlabel,"(");
fprintf(ficgp,"\n#\n#\n#CV preval stable (forward): 'pij' files, covariatecombination#=%d state=%d",k1, cpt);
- for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */
- /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate number corresponding to k1 combination *\/ */
- lv=codtabm(k1,TnsdVar[Tvaraff[k]]);
- /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */
- /* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */
- /* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */
- /* vlv= nbcode[Tvaraff[k]][lv]; */
- vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])];
- fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv);
- }
- for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
- fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
+ for (k=1; k<=cptcovs; k++){ /* For each covariate k get corresponding value lv for combination k1 */
+ fprintf(ficgp," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ sprintf(gplotlabel+strlen(gplotlabel)," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ /* for (k=1; k<=cptcoveff; k++){ /\* For each covariate and each value *\/ */
+ /* /\* lv= decodtabm(k1,k,cptcoveff); /\\* Should be the covariate number corresponding to k1 combination *\\/ *\/ */
+ /* lv=codtabm(k1,TnsdVar[Tvaraff[k]]); */
+ /* /\* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 *\/ */
+ /* /\* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 *\/ */
+ /* /\* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 *\/ */
+ /* /\* vlv= nbcode[Tvaraff[k]][lv]; *\/ */
+ /* vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])]; */
+ /* fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv); */
+ /* } */
+ /* for (k4=1; k4<= nsq; k4++){ /\* For each selected (single) quantitative value *\/ */
+ /* fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
}
strcpy(gplotlabel+strlen(gplotlabel),")");
fprintf(ficgp,"\n#\n");
@@ -8351,27 +8406,32 @@ set ter svg size 640, 480\nunset log y\n
/* 7eme */
if(prevbcast == 1){
/* CV backward prevalence for each covariate */
- for (k1=1; k1<= m ; k1 ++) /* For each covariate combination if any */
+ /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
- if(m != 1 && TKresult[nres]!= k1)
- continue;
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
+ /* if(m != 1 && TKresult[nres]!= k1) */
+ /* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life origin state */
strcpy(gplotlabel,"(");
fprintf(ficgp,"\n#\n#\n#CV Backward stable prevalence: 'pijb' files, covariatecombination#=%d state=%d",k1, cpt);
- for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */
- /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate number corresponding to k1 combination *\/ */
- lv=codtabm(k1,TnsdVar[Tvaraff[k]]);
- /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */
- /* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */
- /* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */
- /* vlv= nbcode[Tvaraff[k]][lv]; */
- vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])];
- fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv);
- }
- for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
- fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
+ for (k=1; k<=cptcovs; k++){ /* For each covariate k get corresponding value lv for combination k1 */
+ fprintf(ficgp," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ sprintf(gplotlabel+strlen(gplotlabel)," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ /* for (k=1; k<=cptcoveff; k++){ /\* For each covariate and each value *\/ */
+ /* /\* lv= decodtabm(k1,k,cptcoveff); /\\* Should be the covariate number corresponding to k1 combination *\\/ *\/ */
+ /* lv=codtabm(k1,TnsdVar[Tvaraff[k]]); */
+ /* /\* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 *\/ */
+ /* /\* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 *\/ */
+ /* /\* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 *\/ */
+ /* /\* vlv= nbcode[Tvaraff[k]][lv]; *\/ */
+ /* vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])]; */
+ /* fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv); */
+ /* } */
+ /* for (k4=1; k4<= nsq; k4++){ /\* For each selected (single) quantitative value *\/ */
+ /* fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
}
strcpy(gplotlabel+strlen(gplotlabel),")");
fprintf(ficgp,"\n#\n");
@@ -8409,27 +8469,32 @@ set ter svg size 640, 480\nunset log y\n
if(prevfcast==1){
/* Projection from cross-sectional to forward stable (period) prevalence for each covariate */
- for (k1=1; k1<= m ; k1 ++) /* For each covariate combination if any */
+ /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
- if(m != 1 && TKresult[nres]!= k1)
- continue;
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
+ /* if(m != 1 && TKresult[nres]!= k1) */
+ /* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */
strcpy(gplotlabel,"(");
fprintf(ficgp,"\n#\n#\n#Projection of prevalence to forward stable prevalence (period): 'PROJ_' files, covariatecombination#=%d state=%d",k1, cpt);
- for (k=1; k<=cptcoveff; k++){ /* For each correspondig covariate value */
- /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate value corresponding to k1 combination and kth covariate *\/ */
- lv=codtabm(k1,TnsdVar[Tvaraff[k]]);
- /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */
- /* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */
- /* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */
- /* vlv= nbcode[Tvaraff[k]][lv]; */
- vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])];
- fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv);
- }
- for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
- fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
+ for (k=1; k<=cptcovs; k++){ /* For each covariate k get corresponding value lv for combination k1 */
+ fprintf(ficgp," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ sprintf(gplotlabel+strlen(gplotlabel)," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ /* for (k=1; k<=cptcoveff; k++){ /\* For each correspondig covariate value *\/ */
+ /* /\* lv= decodtabm(k1,k,cptcoveff); /\\* Should be the covariate value corresponding to k1 combination and kth covariate *\\/ *\/ */
+ /* lv=codtabm(k1,TnsdVar[Tvaraff[k]]); */
+ /* /\* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 *\/ */
+ /* /\* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 *\/ */
+ /* /\* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 *\/ */
+ /* /\* vlv= nbcode[Tvaraff[k]][lv]; *\/ */
+ /* vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])]; */
+ /* fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv); */
+ /* } */
+ /* for (k4=1; k4<= nsq; k4++){ /\* For each selected (single) quantitative value *\/ */
+ /* fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
}
strcpy(gplotlabel+strlen(gplotlabel),")");
fprintf(ficgp,"\n#\n");
@@ -8526,27 +8591,32 @@ set ter svg size 640, 480\nunset log y\n
if(prevbcast==1){
/* Back projection from cross-sectional to stable (mixed) for each covariate */
- for (k1=1; k1<= m ; k1 ++) /* For each covariate combination if any */
+ /* for (k1=1; k1<= m ; k1 ++) /\* For each covariate combination if any *\/ */
for(nres=1; nres <= nresult; nres++){ /* For each resultline */
- if(m != 1 && TKresult[nres]!= k1)
- continue;
+ k1=TKresult[nres];
+ if(TKresult[nres]==0) k1=1; /* To be checked for noresult */
+ /* if(m != 1 && TKresult[nres]!= k1) */
+ /* continue; */
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */
strcpy(gplotlabel,"(");
fprintf(ficgp,"\n#\n#\n#Back projection of prevalence to stable (mixed) back prevalence: 'BPROJ_' files, covariatecombination#=%d originstate=%d",k1, cpt);
- for (k=1; k<=cptcoveff; k++){ /* For each correspondig covariate value */
- /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate value corresponding to k1 combination and kth covariate *\/ */
- lv= codtabm(k1,TnsdVar[Tvaraff[k]]); /* Should be the covariate value corresponding to combination k1 and covariate k */
- /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */
- /* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */
- /* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */
- /* vlv= nbcode[Tvaraff[k]][lv]; */
- vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])];
- fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv);
- }
- for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */
- fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
- sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]);
+ for (k=1; k<=cptcovs; k++){ /* For each covariate k get corresponding value lv for combination k1 */
+ fprintf(ficgp," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ sprintf(gplotlabel+strlen(gplotlabel)," V%d=%lg ",Tvresult[nres][k],TinvDoQresult[nres][Tvresult[nres][k]]);
+ /* for (k=1; k<=cptcoveff; k++){ /\* For each correspondig covariate value *\/ */
+ /* /\* lv= decodtabm(k1,k,cptcoveff); /\\* Should be the covariate value corresponding to k1 combination and kth covariate *\\/ *\/ */
+ /* lv= codtabm(k1,TnsdVar[Tvaraff[k]]); /\* Should be the covariate value corresponding to combination k1 and covariate k *\/ */
+ /* /\* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 *\/ */
+ /* /\* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 *\/ */
+ /* /\* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 *\/ */
+ /* /\* vlv= nbcode[Tvaraff[k]][lv]; *\/ */
+ /* vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])]; */
+ /* fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%d ",Tvaraff[k],vlv); */
+ /* } */
+ /* for (k4=1; k4<= nsq; k4++){ /\* For each selected (single) quantitative value *\/ */
+ /* fprintf(ficgp," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
+ /* sprintf(gplotlabel+strlen(gplotlabel)," V%d=%f ",Tvqresult[nres][resultmodel[nres][k4]],Tqresult[nres][resultmodel[nres][k4]]); */
}
strcpy(gplotlabel+strlen(gplotlabel),")");
fprintf(ficgp,"\n#\n");
@@ -8601,19 +8671,25 @@ set ter svg size 640, 480\nunset log y\n
fprintf(ficgp," u %d:(",ioffset);
kl=0;
strcpy(gplotcondition,"(");
- for (k=1; k<=cptcoveff; k++){ /* For each covariate writing the chain of conditions */
- /* lv= decodtabm(k1,k,cptcoveff); /\* Should be the covariate value corresponding to combination k1 and covariate k *\/ */
- lv= codtabm(k1,TnsdVar[Tvaraff[k]]); /* Should be the covariate value corresponding to combination k1 and covariate k */
- /* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */
- /* decodtabm(1,2,4) = 1 because h=1 k= 1 (1) 1 1 */
- /* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */
- /* vlv= nbcode[Tvaraff[k]][lv]; /\* Value of the modality of Tvaraff[k] *\/ */
- vlv= nbcode[Tvaraff[k]][codtabm(k1,TnsdVar[Tvaraff[k]])];
- kl++;
- sprintf(gplotcondition+strlen(gplotcondition),"$%d==%d && $%d==%d " ,kl,Tvaraff[k], kl+1, nbcode[Tvaraff[k]][lv]);
- kl++;
- if(k
\n\
IMaCh-%s
%s \
\n\
-This file: %sTitle=%s
Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=1+age+%s
\n\
+This file: %sTitle=%s
Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=1+age+%s
\n\
\n\
\
Parameter files
\n\
@@ -13782,8 +13904,8 @@ Please run with mle=-1 to get a correct
printf("V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]);
}
for (j=1; j<= nsq; j++){ /* For each selected (single) quantitative value */
- printf(" V%d=%f ",TvarsQ[j], TinvDoQresult[nres][TvarsQ[j]]); /* TvarsQ[j] gives the name of the jth quantitative (fixed or time v) */
- fprintf(ficreseij,"V%d=%f ",TvarsQ[j], TinvDoQresult[nres][TvarsQ[j]]);
+ printf(" V%d=%lg ",TvarsQ[j], TinvDoQresult[nres][TvarsQ[j]]); /* TvarsQ[j] gives the name of the jth quantitative (fixed or time v) */
+ fprintf(ficreseij,"V%d=%lg ",TvarsQ[j], TinvDoQresult[nres][TvarsQ[j]]);
}
fprintf(ficreseij,"******\n");
printf("******\n");
@@ -13875,9 +13997,9 @@ Please run with mle=-1 to get a correct
printf("\n j=%d In computing T_ Dummy[modelresult[%d][%d]]=%d, modelresult[%d][%d]=%d cptcovs=%d, cptcoveff=%d Fixed[modelresult[nres][j]]=%d\n", j, nres, j, Dummy[modelresult[nres][j]],nres,j,modelresult[nres][j],cptcovs, cptcoveff,Fixed[modelresult[nres][j]]); /* end if dummy or quanti */
if(Dummy[modelresult[nres][j]]==0){/* Dummy variable of the variable in position modelresult in the model corresponding to j in resultline */
- printf("V%d=%d ",Tvresult[nres][j],Tresult[nres][j]); /* Output of each value for the combination TKresult[nres], ordere by the covariate values in the resultline */
- fprintf(ficlog,"V%d=%d ",Tvresult[nres][j],Tresult[nres][j]); /* Output of each value for the combination TKresult[nres], ordere by the covariate values in the resultline */
- fprintf(ficrest,"V%d=%d ",Tvresult[nres][j],Tresult[nres][j]); /* Output of each value for the combination TKresult[nres], ordere by the covariate values in the resultline */
+ printf("V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][j]); /* Output of each value for the combination TKresult[nres], ordere by the covariate values in the resultline */
+ fprintf(ficlog,"V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][j]); /* Output of each value for the combination TKresult[nres], ordere by the covariate values in the resultline */
+ fprintf(ficrest,"V%d=%lg ",Tvresult[nres][j],TinvDoQresult[nres][j]); /* Output of each value for the combination TKresult[nres], ordere by the covariate values in the resultline */
if(Fixed[modelresult[nres][j]]==0){ /* Fixed */
printf("fixed ");fprintf(ficlog,"fixed ");fprintf(ficrest,"fixed ");
}else{
@@ -13887,7 +14009,9 @@ Please run with mle=-1 to get a correct
/* fprintf(ficlog,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
}else if(Dummy[modelresult[nres][j]]==1){ /* Quanti variable */
/* For each selected (single) quantitative value */
- printf(" V%d=%f ",Tvqresult[nres][j],Tqresult[nres][j]);
+ printf(" V%d=%lg ",Tvqresult[nres][j],Tqresult[nres][j]);
+ fprintf(ficlog," V%d=%lg ",Tvqresult[nres][j],Tqresult[nres][j]);
+ fprintf(ficrest," V%d=%lg ",Tvqresult[nres][j],Tqresult[nres][j]);
if(Fixed[modelresult[nres][j]]==0){ /* Fixed */
printf("fixed ");fprintf(ficlog,"fixed ");fprintf(ficrest,"fixed ");
}else{
@@ -13910,14 +14034,16 @@ Please run with mle=-1 to get a correct
fprintf(ficresstdeij,"\n#****** ");
fprintf(ficrescveij,"\n#****** ");
+ /* It could have been: for(j=1;j<=cptcoveff;j++) {printf("V=%d=%lg",Tvresult[nres][cpt],TinvDoQresult[nres][Tvresult[nres][cpt]]);} */
+ /* But it won't be sorted and depends on how the resultline is ordered */
for(j=1;j<=cptcoveff;j++) {
fprintf(ficresstdeij,"V%d=%d ",Tvresult[nres][j],Tresult[nres][j]);
/* fprintf(ficresstdeij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
/* fprintf(ficrescveij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[Tvaraff[j]])]); */
}
for (j=1; j<= nsq; j++){ /* For each selected (single) quantitative value, TvarsQind gives the position of a quantitative in model equation */
- fprintf(ficresstdeij," V%d=%f ",Tvar[TvarsQind[j]],Tqresult[nres][resultmodel[nres][TvarsQind[j]]]);
- fprintf(ficrescveij," V%d=%f ",Tvar[TvarsQind[j]],Tqresult[nres][resultmodel[nres][TvarsQind[j]]]);
+ fprintf(ficresstdeij," V%d=%lg ",Tvar[TvarsQind[j]],Tqresult[nres][resultmodel[nres][TvarsQind[j]]]);
+ fprintf(ficrescveij," V%d=%lg ",Tvar[TvarsQind[j]],Tqresult[nres][resultmodel[nres][TvarsQind[j]]]);
}
fprintf(ficresstdeij,"******\n");
fprintf(ficrescveij,"******\n");
@@ -13929,7 +14055,7 @@ Please run with mle=-1 to get a correct
/* fprintf(ficresvij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtabm(k,TnsdVar[TnsdVar[Tvaraff[j]]])]); */
for (j=1; j<= nsq; j++){ /* For each selected (single) quantitative value */
/* fprintf(ficresvij," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][j]); /\* To solve *\/ */
- fprintf(ficresvij," V%d=%f ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]); /* Solved */
+ fprintf(ficresvij," V%d=%lg ",Tvqresult[nres][j],Tqresult[nres][resultmodel[nres][j]]); /* Solved */
}
fprintf(ficresvij,"******\n");
@@ -14086,7 +14212,7 @@ Please run with mle=-1 to get a correct
free_ivector(Tposprod,1,NCOVMAX);
free_ivector(Tprod,1,NCOVMAX);
free_ivector(Tvaraff,1,NCOVMAX);
- free_ivector(invalidvarcomb,1,ncovcombmax);
+ free_ivector(invalidvarcomb,0,ncovcombmax);
free_ivector(Tage,1,NCOVMAX);
free_ivector(Tmodelind,1,NCOVMAX);
free_ivector(TmodelInvind,1,NCOVMAX);