--- imach/src/imach.c 2018/04/20 05:22:13 1.284
+++ imach/src/imach.c 2018/05/01 17:57:25 1.287
@@ -1,6 +1,15 @@
-/* $Id: imach.c,v 1.284 2018/04/20 05:22:13 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
+
Revision 1.284 2018/04/20 05:22:13 brouard
Summary: Computing mean and stdeviation of fixed quantitative variables
@@ -1057,12 +1066,12 @@ typedef struct {
#define ODIRSEPARATOR '\\'
#endif
-/* $Id: imach.c,v 1.284 2018/04/20 05:22:13 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.284 $ $Date: 2018/04/20 05:22:13 $";
+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 */
@@ -4640,16 +4649,16 @@ Title=%s
Datafile=%s Firstpass=%d La
Printing means of quantitative variables if any
*/
for (z1=1; z1<= nqfveff; z1++) {
- fprintf(ficlog,"Mean of quantitative variable V%d on %.0f individuals sum=%f", ncovcol+z1, idq[z1], meanq[z1]);
+ fprintf(ficlog,"Mean of fixed quantitative variable V%d on %.0f individuals sum=%f", ncovcol+z1, idq[z1], meanq[z1]);
fprintf(ficlog,", mean=%.3g\n",meanq[z1]/idq[z1]);
if(weightopt==1){
printf(" Weighted mean and standard deviation of");
fprintf(ficlog," Weighted mean and standard deviation of");
fprintf(ficresphtmfr," Weighted mean and standard deviation of");
}
- printf(" quantitative variable V%d on %.0f representatives of the population : %6.3g (%6.3g)\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt((stdq[z1]-meanq[z1]*meanq[z1]/idq[z1])/idq[z1]));
- fprintf(ficlog," quantitative variable V%d on %.0f representatives of the population : %6.3g (%6.3g)\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt((stdq[z1]-meanq[z1]*meanq[z1]/idq[z1])/idq[z1]));
- fprintf(ficresphtmfr," quantitative variable V%d on %.0f representatives of the population : %6.3g (%6.3g)
\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt((stdq[z1]-meanq[z1]*meanq[z1]/idq[z1])/idq[z1])); + printf(" fixed quantitative variable V%d on %.0f representatives of the population : %6.3g (%6.3g)\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt((stdq[z1]-meanq[z1]*meanq[z1]/idq[z1])/idq[z1])); + fprintf(ficlog," fixed quantitative variable V%d on %.0f representatives of the population : %6.3g (%6.3g)\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt((stdq[z1]-meanq[z1]*meanq[z1]/idq[z1])/idq[z1])); + fprintf(ficresphtmfr," fixed quantitative variable V%d on %.0f representatives of the population : %6.3g (%6.3g)
\n", ncovcol+z1, idq[z1],meanq[z1]/idq[z1], sqrt((stdq[z1]-meanq[z1]*meanq[z1]/idq[z1])/idq[z1]));
}
/* for (z1=1; z1<= nqtveff; z1++) { */
/* for(m=1;m<=lastpass;m++){ */
@@ -5355,9 +5364,11 @@ void concatwav(int wav[], int **dh, int
/* *cptcov=0; */
for (k=1; k <= maxncov; k++) ncodemax[k]=0; /* Horrible constant again replaced by NCOVMAX */
+ for (k=1; k <= maxncov; k++)
+ for(j=1; j<=2; j++)
+ 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 */
@@ -5375,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
@@ -5421,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;
@@ -5442,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 */
@@ -9730,7 +9737,7 @@ Dummy[k] 0=dummy (0 1), 1 quantitative (
Typevar: 0 for simple covariate (dummy, quantitative, fixed or varying), 1 for age product, 2 for product \n\
Fixed[k] 0=fixed (product or simple), 1 varying, 2 fixed with age product, 3 varying with age product \n\
Dummy[k] 0=dummy (0 1), 1 quantitative (single or product without age), 2 dummy with age product, 3 quant with age product\n",model);
- for(k=1;k<=cptcovt; k++){ Fixed[k]=0; Dummy[k]=0;}
+ for(k=-1;k<=cptcovt; k++){ Fixed[k]=0; Dummy[k]=0;}
for(k=1, ncovf=0, nsd=0, nsq=0, ncovv=0, ncova=0, ncoveff=0, nqfveff=0, ntveff=0, nqtveff=0;k<=cptcovt; k++){ /* or cptocvt */
if (Tvar[k] <=ncovcol && Typevar[k]==0 ){ /* Simple fixed dummy (<=ncovcol) covariates */
Fixed[k]= 0;
@@ -9980,11 +9987,12 @@ Dummy[k] 0=dummy (0 1), 1 quantitative (
/* Searching for doublons in the model */
for(k1=1; k1<= cptcovt;k1++){
for(k2=1; k2
Datafile=%s Firstpass=%d La
firstpass, lastpass, stepm, weightopt, model);
fprintf(fichtm,"\n");
- fprintf(fichtm,"Parameter line 2
Parameter line 2