--- imach/src/imach.c 2018/04/21 21:02:16 1.285
+++ imach/src/imach.c 2018/05/01 17:57:25 1.287
@@ -1,6 +1,12 @@
-/* $Id: imach.c,v 1.285 2018/04/21 21:02:16 brouard Exp $
+/* $Id: imach.c,v 1.287 2018/05/01 17:57:25 brouard Exp $
$State: Exp $
$Log: imach.c,v $
+ Revision 1.287 2018/05/01 17:57:25 brouard
+ Summary: Bug fixed by providing frequencies only for non missing covariates
+
+ Revision 1.286 2018/04/27 14:27:04 brouard
+ Summary: some minor bugs
+
Revision 1.285 2018/04/21 21:02:16 brouard
Summary: Some bugs fixed, valgrind tested
@@ -1060,12 +1066,12 @@ typedef struct {
#define ODIRSEPARATOR '\\'
#endif
-/* $Id: imach.c,v 1.285 2018/04/21 21:02:16 brouard Exp $ */
+/* $Id: imach.c,v 1.287 2018/05/01 17:57:25 brouard Exp $ */
/* $State: Exp $ */
#include "version.h"
char version[]=__IMACH_VERSION__;
char copyright[]="April 2018,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015-2018";
-char fullversion[]="$Revision: 1.285 $ $Date: 2018/04/21 21:02:16 $";
+char fullversion[]="$Revision: 1.287 $ $Date: 2018/05/01 17:57:25 $";
char strstart[80];
char optionfilext[10], optionfilefiname[FILENAMELENGTH];
int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */
@@ -5363,7 +5369,6 @@ void concatwav(int wav[], int **dh, int
nbcode[k][j]=0; /* Valgrind */
/* Loop on covariates without age and products and no quantitative variable */
- /* for (j=1; j<=(cptcovs); j++) { /\* From model V1 + V2*age+ V3 + V3*V4 keeps V1 + V3 = 2 only *\/ */
for (k=1; k<=cptcovt; k++) { /* From model V1 + V2*age + V3 + V3*V4 keeps V1 + V3 = 2 only */
for (j=-1; (j < maxncov); j++) Ndum[j]=0;
if(Dummy[k]==0 && Typevar[k] !=1){ /* Dummy covariate and not age product */
@@ -5381,7 +5386,11 @@ void concatwav(int wav[], int **dh, int
modmaxcovj=ij;
else if (ij < modmincovj)
modmincovj=ij;
- if ((ij < -1) && (ij > NCOVMAX)){
+ if (ij <0 || ij >1 ){
+ printf("Information, IMaCh doesn't treat covariate with missing values (-1), individual %d will be skipped.\n",i);
+ fprintf(ficlog,"Information, currently IMaCh doesn't treat covariate with missing values (-1), individual %d will be skipped.\n",i);
+ }
+ if ((ij < -1) || (ij > NCOVMAX)){
printf( "Error: minimal is less than -1 or maximal is bigger than %d. Exiting. \n", NCOVMAX );
exit(1);
}else
@@ -5427,12 +5436,18 @@ void concatwav(int wav[], int **dh, int
/* nbcode[Tvar[j]][3]=2; */
/* To be continued (not working yet). */
ij=0; /* ij is similar to i but can jump over null modalities */
- for (i=modmincovj; i<=modmaxcovj; i++) { /* i= 1 to 2 for dichotomous, or from 1 to 3 or from -1 or 0 to 1 currently*/
+
+ /* for (i=modmincovj; i<=modmaxcovj; i++) { */ /* i= 1 to 2 for dichotomous, or from 1 to 3 or from -1 or 0 to 1 currently*/
+ /* Skipping the case of missing values by reducing nbcode to 0 and 1 and not -1, 0, 1 */
+ /* model=V1+V2+V3, if V2=-1, 0 or 1, then nbcode[2][1]=0 and nbcode[2][2]=1 instead of
+ * nbcode[2][1]=-1, nbcode[2][2]=0 and nbcode[2][3]=1 */
+ /*, could be restored in the future */
+ for (i=0; i<=1; i++) { /* i= 1 to 2 for dichotomous, or from 1 to 3 or from -1 or 0 to 1 currently*/
if (Ndum[i] == 0) { /* If nobody responded to this modality k */
break;
}
ij++;
- nbcode[Tvar[k]][ij]=i; /* stores the original value of modality i in an array nbcode, ij modality from 1 to last non-nul modality. nbcode[1][1]=0 nbcode[1][2]=1*/
+ nbcode[Tvar[k]][ij]=i; /* stores the original value of modality i in an array nbcode, ij modality from 1 to last non-nul modality. nbcode[1][1]=0 nbcode[1][2]=1 . Could be -1*/
cptcode = ij; /* New max modality for covar j */
} /* end of loop on modality i=-1 to 1 or more */
break;
@@ -5448,21 +5463,7 @@ void concatwav(int wav[], int **dh, int
break;
} /* end switch */
} /* end dummy test */
-
- /* for (k=0; k<= cptcode; k++) { /\* k=-1 ? k=0 to 1 *\//\* Could be 1 to 4 *\//\* cptcode=modmaxcovj *\/ */
- /* /\*recode from 0 *\/ */
- /* k is a modality. If we have model=V1+V1*sex */
- /* then: nbcode[1][1]=0 ; nbcode[1][2]=1; nbcode[2][1]=0 ; nbcode[2][2]=1; */
- /* But if some modality were not used, it is recoded from 0 to a newer modmaxcovj=cptcode *\/ */
- /* } */
- /* /\* cptcode = ij; *\/ /\* New max modality for covar j *\/ */
- /* if (ij > ncodemax[j]) { */
- /* printf( " Error ij=%d > ncodemax[%d]=%d\n", ij, j, ncodemax[j]); */
- /* fprintf(ficlog, " Error ij=%d > ncodemax[%d]=%d\n", ij, j, ncodemax[j]); */
- /* break; */
- /* } */
- /* } /\* end of loop on modality k *\/ */
- } /* end of loop on model-covariate j. nbcode[Tvarj][1]=0 and nbcode[Tvarj][2]=1 sets the value of covariate j*/
+ } /* end of loop on model-covariate k. nbcode[Tvark][1]=-1, nbcode[Tvark][1]=0 and nbcode[Tvark][2]=1 sets the value of covariate k*/
for (k=-1; k< maxncov; k++) Ndum[k]=0;
/* Look at fixed dummy (single or product) covariates to check empty modalities */
@@ -10302,7 +10303,7 @@ void syscompilerinfo(int logged)
#endif
#endif
- // void main()
+ // void main ()
// {
#if defined(_MSC_VER)
if (IsWow64()){
@@ -11026,9 +11027,15 @@ int main(int argc, char *argv[])
fprintf(ficlog,"Not 11 parameters, for example:ftol=1.e-8 stepm=12 ncovcol=2 nqv=1 ntv=2 nqtv=1 nlstate=2 ndeath=1 maxwav=3 mle=1 weight=1\n");
fprintf(ficlog,"but line=%s\n",line);
}
- printf("ftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, mle, weightopt);
+ if( lastpass > maxwav){
+ printf("Error (lastpass = %d) > (maxwav = %d)\n",lastpass, maxwav);
+ fprintf(ficlog,"Error (lastpass = %d) > (maxwav = %d)\n",lastpass, maxwav);
+ fflush(ficlog);
+ goto end;
+ }
+ printf("ftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, mle, weightopt);
fprintf(ficparo,"ftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, mle, weightopt);
- fprintf(ficres,"ftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, mle, weightopt);
+ fprintf(ficres,"ftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, 0, weightopt);
fprintf(ficlog,"ftol=%e stepm=%d ncovcol=%d nqv=%d ntv=%d nqtv=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nqv, ntv, nqtv, nlstate, ndeath, maxwav, mle, weightopt);
}
/* ftolpl=6*ftol*1.e5; /\* 6.e-3 make convergences in less than 80 loops for the prevalence limit *\/ */
@@ -11637,7 +11644,7 @@ Title=%s
Datafile=%s Firstpass=%d La
firstpass, lastpass, stepm, weightopt, model);
fprintf(fichtm,"\n");
- fprintf(fichtm,"