Diff for /imach/src/imach.c between versions 1.286 and 1.287

version 1.286, 2018/04/27 14:27:04 version 1.287, 2018/05/01 17:57:25
Line 1 Line 1
 /* $Id$  /* $Id$
   $State$    $State$
   $Log$    $Log$
     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    Revision 1.286  2018/04/27 14:27:04  brouard
   Summary: some minor bugs    Summary: some minor bugs
   
Line 5366  void  concatwav(int wav[], int **dh, int Line 5369  void  concatwav(int wav[], int **dh, int
        nbcode[k][j]=0; /* Valgrind */         nbcode[k][j]=0; /* Valgrind */
   
    /* Loop on covariates without age and products and no quantitative variable */     /* 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 (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;       for (j=-1; (j < maxncov); j++) Ndum[j]=0;
      if(Dummy[k]==0 && Typevar[k] !=1){ /* Dummy covariate and not age product */        if(Dummy[k]==0 && Typevar[k] !=1){ /* Dummy covariate and not age product */ 
Line 5384  void  concatwav(int wav[], int **dh, int Line 5386  void  concatwav(int wav[], int **dh, int
              modmaxcovj=ij;                modmaxcovj=ij; 
            else if (ij < modmincovj)              else if (ij < modmincovj) 
              modmincovj=ij;                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 );               printf( "Error: minimal is less than -1 or maximal is bigger than %d. Exiting. \n", NCOVMAX );
              exit(1);               exit(1);
            }else             }else
Line 5430  void  concatwav(int wav[], int **dh, int Line 5436  void  concatwav(int wav[], int **dh, int
          /* nbcode[Tvar[j]][3]=2; */           /* nbcode[Tvar[j]][3]=2; */
          /* To be continued (not working yet). */           /* To be continued (not working yet). */
          ij=0; /* ij is similar to i but can jump over null modalities */           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 */             if (Ndum[i] == 0) { /* If nobody responded to this modality k */
              break;               break;
            }             }
            ij++;             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 */             cptcode = ij; /* New max modality for covar j */
          } /* end of loop on modality i=-1 to 1 or more */           } /* end of loop on modality i=-1 to 1 or more */
          break;           break;
Line 5451  void  concatwav(int wav[], int **dh, int Line 5463  void  concatwav(int wav[], int **dh, int
          break;           break;
        } /* end switch */         } /* end switch */
      } /* end dummy test */       } /* end dummy test */
          } /* 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=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*/    
       
    for (k=-1; k< maxncov; k++) Ndum[k]=0;      for (k=-1; k< maxncov; k++) Ndum[k]=0; 
    /* Look at fixed dummy (single or product) covariates to check empty modalities */     /* Look at fixed dummy (single or product) covariates to check empty modalities */

Removed from v.1.286  
changed lines
  Added in v.1.287


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>