--- imach/src/imach.c 2018/04/27 14:27:04 1.286 +++ imach/src/imach.c 2018/05/01 17:57:25 1.287 @@ -1,6 +1,9 @@ -/* $Id: imach.c,v 1.286 2018/04/27 14:27:04 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 @@ -1063,12 +1066,12 @@ typedef struct { #define ODIRSEPARATOR '\\' #endif -/* $Id: imach.c,v 1.286 2018/04/27 14:27:04 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.286 $ $Date: 2018/04/27 14:27:04 $"; +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 */ @@ -5366,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 */ @@ -5384,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 @@ -5430,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; @@ -5451,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 */