char fullversion[]="$Revision$ $Date$";
char strstart[80];
char optionfilext[10], optionfilefiname[FILENAMELENGTH];
-int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */
+int erreur=0, nberr=0, nbwarn=0, nbinfo=0; /* Error number, number of errors, number of warnings, number of infos */
int debugILK=0; /* debugILK is set by a #d in a comment line */
int nagesqr=0, nforce=0; /* nagesqr=1 if model is including age*age, number of forces */
/* Number of covariates model (1)=V2+V1+ V3*age+V2*V4 */
But if the variable is not in the model TTvar[iv] is the real variable effective in the model:
meaning that decodemodel should be used cotvar[mw[mi+1][i]][TTvar[iv]][i]
*/
- for(mi=1; mi<= wav[i]-1; mi++){ /* Varying with waves */
+ for(mi=firstpass; mi<= wav[i]-1; mi++){ /* mi=1 Varying with waves */
/* Wave varying (but not age varying) */
/* for(k=1; k <= ncovv ; k++){ /\* Varying covariates in the model (single and product but no age )"V5+V4+V3+V4*V3+V5*age+V1*age+V1" +TvarVind 1,2,3,4(V4*V3) Tvar[1]@7{5, 4, 3, 6, 5, 1, 1 ; 6 because the created covar is after V5 and is 6, minus 1+1, 3,2,1,4 positions in cotvar*\/ */
/* /\* cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]][i]; but where is the crossproduct? *\/ */
ioffset=2+nagesqr ;
for (k=1; k<=ncovf;k++)
cov[ioffset+TvarFind[k]]=covar[Tvar[TvarFind[k]]][i];
- for(mi=1; mi<= wav[i]-1; mi++){
+ for(mi=firstpass; mi<= wav[i]-1; mi++){ /* mi=1 */
for(k=1; k <= ncovv ; k++){
cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]][i]; /* because cotvar starts now at first ncovcol+nqv+ (1 to nqtv) */
}
} else if(mle==3){ /* exponential inter-extrapolation */
for (i=1,ipmx=0, sw=0.; i<=imx; i++){
for (k=1; k<=cptcovn;k++) cov[2+nagesqr+k]=covar[Tvar[k]][i];
- for(mi=1; mi<= wav[i]-1; mi++){
+ for(mi=firstpass; mi<= wav[i]-1; mi++){ /* mi=1 */
for (ii=1;ii<=nlstate+ndeath;ii++)
for (j=1;j<=nlstate+ndeath;j++){
oldm[ii][j]=(ii==j ? 1.0 : 0.0);
}else if (mle==4){ /* ml=4 no inter-extrapolation */
for (i=1,ipmx=0, sw=0.; i<=imx; i++){
for (k=1; k<=cptcovn;k++) cov[2+nagesqr+k]=covar[Tvar[k]][i];
- for(mi=1; mi<= wav[i]-1; mi++){
+ for(mi=firstpass; mi<= wav[i]-1; mi++){ /* mi=1 */
for (ii=1;ii<=nlstate+ndeath;ii++)
for (j=1;j<=nlstate+ndeath;j++){
oldm[ii][j]=(ii==j ? 1.0 : 0.0);
}else{ /* ml=5 no inter-extrapolation no jackson =0.8a */
for (i=1,ipmx=0, sw=0.; i<=imx; i++){
for (k=1; k<=cptcovn;k++) cov[2+nagesqr+k]=covar[Tvar[k]][i];
- for(mi=1; mi<= wav[i]-1; mi++){
+ for(mi=firstpass; mi<= wav[i]-1; mi++){
for (ii=1;ii<=nlstate+ndeath;ii++)
for (j=1;j<=nlstate+ndeath;j++){
oldm[ii][j]=(ii==j ? 1.0 : 0.0);
/* } */
- for(mi=1; mi<= wav[i]-1; mi++){ /* Varying with waves */
+ for(mi=firstpass; mi<= wav[i]-1; mi++){ /* mi=1 Varying with waves */
/* Wave varying (but not age varying) *//* V1+V3+age*V1+age*V3+V1*V3 with V4 tv and V5 tvq k= 1 to 5 and extra at V(5+1)=6 for V1*V3 */
/* for(k=1; k <= ncovv ; k++){ /\* Varying covariates (single and product but no age )*\/ */
/* /\* cov[ioffset+TvarVind[k]]=cotvar[mw[mi][i]][Tvar[TvarVind[k]]][i]; *\/ */
}/* end j==0 */
if (bool==1){ /* We selected an individual iind satisfying combination j1 (V4=1 V3=0) or all fixed covariates */
/* for(m=firstpass; m<=lastpass; m++){ */
- for(mi=1; mi<wav[iind];mi++){ /* For each wave */
+ for(mi=firstpass; mi<wav[iind];mi++){ /* mi=1; mi<wav[iind]For each wave */
m=mw[mi][iind];
if(j!=0){
if(anyvaryingduminmodel==1){ /* Some are varying covariates */
for (i=1; i<=imx; i++) { /* Each individual */
bool=1;
/* for(m=firstpass; m<=lastpass; m++){/\* Other selection (we can limit to certain interviews*\/ */
- for(mi=1; mi<wav[i];mi++){ /* For this wave too look where individual can be counted V4=0 V3=0 */
+ for(mi=firstpass; mi<wav[i];mi++){ /* mi=1 For this wave too look where individual can be counted V4=0 V3=0 */
m=mw[mi][i];
/* Tmodelind[z1]=k is the position of the varying covariate in the model, but which # within 1 to ntv? */
/* Tvar[Tmodelind[z1]] is the n of Vn; n-ncovcol-nqv is the first time varying covariate or iv */
{
/* Concatenates waves: wav[i] is the number of effective (useful waves in the sense that a non interview is useless) of individual i.
Death is a valid wave (if date is known).
- mw[mi][i] is the mi (mi=1 to wav[i]) effective wave of individual i
+ mw[mi][i] is the mi (mi=firstpass to firstpass+wav[i]) effective wave of individual i
dh[m][i] or dh[mw[mi][i]][i] is the delay between two effective waves m=mw[mi][i]
and mw[mi+1][i]. dh depends on stepm. s[m][i] exists for any wave from firstpass to lastpass
*/
/* Treating live states */
for(i=1; i<=imx; i++){ /* For simple cases and if state is death */
- mi=0; /* First valid wave */
+ mi=firstpass-1; /* mi=0; *//* First valid wave */
mli=0; /* Last valid wave */
m=firstpass; /* Loop on waves */
while(s[m][i] <= nlstate){ /* a live state or unknown state */
#else
if(s[m][i]==-1 && (int) andc[i] == 9999 && (int)anint[m][i] != 9999){ /* no death date and known date of interview, case -2 (vital status unknown is warned later */
if(firsthree == 0){
- printf("Information! Unknown status for individual %ld line=%d occurred at last wave %d at known date %d/%d. Please, check if your unknown date of death %d/%d means a live state %d at wave %d. This case(%d)/wave(%d) contributes to the likelihood as 1-p_{%d%d} .\nOthers in log file only\n",num[i],i,lastpass,(int)mint[m][i],(int)anint[m][i], (int) moisdc[i], (int) andc[i], s[m][i], m, i, m, s[m][i], nlstate+ndeath);
+ printf("Information (#%d)! Unknown status for individual %ld line=%d occurred at last wave %d at known date %d/%d. Please, check if your unknown date of death %d/%d means a live state %d at wave %d. This case(%d)/wave(%d) contributes to the likelihood as 1-p_{%d%d} .\nOthers in log file only\n",nbinfo,num[i],i,lastpass,(int)mint[m][i],(int)anint[m][i], (int) moisdc[i], (int) andc[i], s[m][i], m, i, m, s[m][i], nlstate+ndeath);
firsthree=1;
}else if(firsthree >=1 && firsthree < 10){
fprintf(ficlog,"Information! Unknown status for individual %ld line=%d occurred at last wave %d at known date %d/%d. Please, check if your unknown date of death %d/%d means a live state %d at wave %d. This case(%d)/wave(%d) contributes to the likelihood as 1-p_{%d%d} .\n",num[i],i,lastpass,(int)mint[m][i],(int)anint[m][i], (int) moisdc[i], (int) andc[i], s[m][i], m, i, m, s[m][i], nlstate+ndeath);
/* if(mi==0) never been interviewed correctly before death */
/* Only death is a correct wave */
mw[mi][i]=m;
+ /* if(mi==firstpass) */
+ /* mw[mi+1][i]=m; */
+ /* s[mw[mi+1][i]][i]=s[m][i]; */
+ /* if(mi==firstpass) never been interviewed correctly before death */
} /* else not in a death state */
#ifndef DISPATCHINGKNOWNDEATHAFTERLASTWAVE
else if ((int) andc[i] != 9999) { /* Date of death is known */
#endif
wav[i]=mi; /* mi should be the last effective wave (or mli), */
/* wav[i]=mw[mi][i]; */
- if(mi==0){
+ if(mi==firstpass-1){ /* was mi==0 */
nbwarn++;
if(first==0){
printf("Warning! No valid information for individual %ld line=%d (skipped) and may be others, see log file\n",num[i],i);
if(first==1){
fprintf(ficlog,"Warning! No valid information for individual %ld line=%d (skipped)\n",num[i],i);
}
- } /* end mi==0 */
+ } /* end mi==firstpass-1 was ==0 */
} /* End individuals */
/* wav and mw are no more changed */
for(i=1; i<=imx; i++){
- for(mi=1; mi<wav[i];mi++){
+ for(mi=firstpass; mi<wav[i];mi++){ /*(mi=1; mi<wav[i];mi++) */
if (stepm <=0)
- dh[mi][i]=1;
+ dh[mi][i]=1; /* be careful dh starts at firstpass to lastpass *//* 1 to lastpass-firstpass */
else{
if (s[mw[mi+1][i]][i] > nlstate) { /* A death, but what if date is unknown? */
if (agedc[i] < 2*AGESUP) {
j= rint(agedc[i]*12-agev[mw[mi][i]][i]*12);
- if(j==0) j=1; /* Survives at least one month after exam */
+ if(j==0) j=1; /* Survives at least one month after exam */ /* To be checked */
else if(j<0){
nberr++;
printf("Error! Negative delay (%d to death) between waves %d and %d of individual %ld (around line %d) who is aged %.1f with statuses from %d to %d\n ",j,mw[mi][i],mw[mi+1][i],num[i], i,agev[mw[mi][i]][i],s[mw[mi][i]][i] ,s[mw[mi+1][i]][i]);
int lstra;
int linei, month, year,iout;
int noffset=0; /* This is the offset if BOM data file */
+ int firstone=0;
char line[MAXLINE], linetmp[MAXLINE];
char stra[MAXLINE], strb[MAXLINE];
char *stratrunc;
}
}
- s[j][i]=lval;
+ s[j][i]=lval; /* status of i at wave j */
/* Date of Interview */
strcpy(line,stra);
printf("Error reading data around '%s' at line number %d for individual %d, '%s'\nShould be a date of birth (mm/yyyy) but at least the year of birth should be given. Exiting.\n",strb, linei,i,line);
fprintf(ficlog,"Error reading data around '%s' at line number %d for individual %d, '%s'\nShould be a date of birth (mm/yyyy) but at least the year of birth should be given. Exiting.\n",strb, linei,i,line);fflush(ficlog);
return 1;
-
}
annais[i]=(double)(year);
moisnais[i]=(double)(month);
num[i]=atol(stra);
/*if((s[2][i]==2) && (s[3][i]==-1)&&(s[4][i]==9)){
printf("%ld %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]),weight[i], (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]), (mint[3][i]), (anint[3][i]), (s[3][i]), (mint[4][i]), (anint[4][i]), (s[4][i])); ij=ij+1;}*/
-
+ /* Should break (individual is skipped) if state at firstpass interview
+ * is death, or dates of interviews between firstpass and lastpass
+ * are unknown */
+ /* This can happen when the firstpass occurs after the death. */
+ if( s[firstpass][i] > nlstate){
+ nbinfo++;
+ /* *nberr = *nberr + 1; */
+ if(firstone == 0){
+ firstone=1;
+ printf("Information (#%d)! Date of death (month %2d and year %4d) of individual %ld on line %d with status %d at wave %d occurred before the firstpass (%d) that you selected: whole information on this individual is skipped.\nOther similar cases in log file\n", nbinfo, (int)moisdc[i],(int)andc[i],num[i],i,s[firstpass][i],firstpass,firstpass);
+ }
+ fprintf(ficlog,"Information (#%d)! Date of death (month %2d and year %4d) of individual %ld on line %d with status %d at wave %d occurred before the firstpass (%d) that you selected: whole information on this individual is skipped.\n", nbinfo, (int)moisdc[i],(int)andc[i],num[i],i,s[firstpass][i],firstpass,firstpass);
+ i--;
+ }
i=i+1;
} /* End loop reading data */
return (1);
}
-int calandcheckages(int imx, int maxwav, double *agemin, double *agemax, int *nberr, int *nbwarn )
+int calandcheckages(int imx, int maxwav, double *agemin, double *agemax)/*, int *nberr, int *nbwarn )*/
{/* Check ages at death */
int i, m;
int firstone=0;
s[m][i]=-1;
}
if((int)moisdc[i]==99 && (int)andc[i]==9999 && s[m][i]>nlstate){
- *nberr = *nberr + 1;
+ nberr = nberr + 1;
if(firstone == 0){
firstone=1;
- printf("Warning (#%d)! Date of death (month %2d and year %4d) of individual %ld on line %d was unknown but status is a death state %d at wave %d. If you don't know the vital status, please enter -2. If he/she is still alive but don't know the state, please code with '-1 or '.'. Here, we do not believe in a death, skipped.\nOther similar cases in log file\n", *nberr,(int)moisdc[i],(int)andc[i],num[i],i,s[m][i],m);
+ printf("Warning (#%d)! Date of death (month %2d and year %4d) of individual %ld on line %d was unknown but status is a death state %d at wave %d. If you don't know the vital status, please enter -2. If he/she is still alive but don't know the state, please code with '-1 or '.'. Here, we do not believe in a death, skipped.\nOther similar cases in log file\n", nberr,(int)moisdc[i],(int)andc[i],num[i],i,s[m][i],m);
}
- fprintf(ficlog,"Warning (#%d)! Date of death (month %2d and year %4d) of individual %ld on line %d was unknown but status is a death state %d at wave %d. If you don't know the vital status, please enter -2. If he/she is still alive but don't know the state, please code with '-1 or '.'. Here, we do not believe in a death, skipped.\n", *nberr,(int)moisdc[i],(int)andc[i],num[i],i,s[m][i],m);
+ fprintf(ficlog,"Warning (#%d)! Date of death (month %2d and year %4d) of individual %ld on line %d was unknown but status is a death state %d at wave %d. If you don't know the vital status, please enter -2. If he/she is still alive but don't know the state, please code with '-1 or '.'. Here, we do not believe in a death, skipped.\n", nberr,(int)moisdc[i],(int)andc[i],num[i],i,s[m][i],m);
s[m][i]=-1; /* Droping the death status */
}
if((int)moisdc[i]==99 && (int)andc[i]!=9999 && s[m][i]>nlstate){
- (*nberr)++;
- printf("Error (#%d)! Month of death of individual %ld on line %d was unknown (%2d) (year of death is %4d) and status is a death state %d at wave %d. Please impute an arbitrary (or not) month and rerun. Currently this transition to death will be skipped (status is set to -2).\nOther similar cases in log file\n", *nberr, num[i],i,(int)moisdc[i],(int)andc[i],s[m][i],m);
- fprintf(ficlog,"Error (#%d)! Month of death of individual %ld on line %d was unknown (%2d) (year of death is %4d) and status is a death state %d at wave %d. Please impute an arbitrary (or not) month and rerun. Currently this transition to death will be skipped (status is set to -2).\n", *nberr, num[i],i,(int)moisdc[i],(int)andc[i],s[m][i],m);
+ nberr++;
+ printf("Error (#%d)! Month of death of individual %ld on line %d was unknown (%2d) (year of death is %4d) and status is a death state %d at wave %d. Please impute an arbitrary (or not) month and rerun. Currently this transition to death will be skipped (status is set to -2).\nOther similar cases in log file\n", nberr, num[i],i,(int)moisdc[i],(int)andc[i],s[m][i],m);
+ fprintf(ficlog,"Error (#%d)! Month of death of individual %ld on line %d was unknown (%2d) (year of death is %4d) and status is a death state %d at wave %d. Please impute an arbitrary (or not) month and rerun. Currently this transition to death will be skipped (status is set to -2).\n", nberr, num[i],i,(int)moisdc[i],(int)andc[i],s[m][i],m);
s[m][i]=-2; /* We prefer to skip it (and to skip it in version 0.8a1 too */
}
}
for (i=1; i<=imx; i++) {
for(m=firstpass; (m<=lastpass); m++){
if (s[m][i] > (nlstate+ndeath)) {
- (*nberr)++;
- printf("Error: on wave %d of individual %d status %d > (nlstate+ndeath)=(%d+%d)=%d\n",m,i,s[m][i],nlstate, ndeath, nlstate+ndeath);
- fprintf(ficlog,"Error: on wave %d of individual %d status %d > (nlstate+ndeath)=(%d+%d)=%d\n",m,i,s[m][i],nlstate, ndeath, nlstate+ndeath);
+ nberr++;
+ printf("Error (#%d): on wave %d of individual %d status %d > (nlstate+ndeath)=(%d+%d)=%d\n",nberr,m,i,s[m][i],nlstate, ndeath, nlstate+ndeath);
+ fprintf(ficlog,"Error (#%d): on wave %d of individual %d status %d > (nlstate+ndeath)=(%d+%d)=%d\n",nberr,m,i,s[m][i],nlstate, ndeath, nlstate+ndeath);
return 1;
}
}
*/
nberr=0; /* Number of errors and warnings */
- nbwarn=0;
+ nbwarn=0;nbinfo=0;
#ifdef WIN32
_getcwd(pathcd, size);
#else
/*-calculation of age at interview from date of interview and age at death -*/
agev=matrix(1,maxwav,1,imx);
- if(calandcheckages(imx, maxwav, &agemin, &agemax, &nberr, &nbwarn) == 1)
+ if(calandcheckages(imx, maxwav, &agemin, &agemax)==1) /*, &nberr, &nbwarn) == 1)*/
goto end;
/* dh=imatrix(1,lastpass-firstpass+1,1,imx); */
/* bh=imatrix(1,lastpass-firstpass+1,1,imx); */
/* mw=imatrix(1,lastpass-firstpass+1,1,imx); */
- dh=imatrix(1,lastpass-firstpass+2,1,imx); /* We are adding a wave if status is unknown at last wave but death occurs after last wave.*/
- bh=imatrix(1,lastpass-firstpass+2,1,imx);
- mw=imatrix(1,lastpass-firstpass+2,1,imx);
-
+ /*dh=imatrix(1,lastpass-firstpass+2,1,imx);*/ /* We are adding a wave if status is unknown at last wave but death occurs after last wave.*/
+ dh=imatrix(firstpass,lastpass+1,1,imx); /* We are adding a wave if status is unknown at last wave but death occurs after last wave.*/
+ /* bh=imatrix(1,lastpass-firstpass+2,1,imx); */
+ /* mw=imatrix(1,lastpass-firstpass+2,1,imx); */
+ bh=imatrix(firstpass,lastpass+1,1,imx);
+ mw=imatrix(firstpass,lastpass+1,1,imx);
/* Concatenates waves */
/* Concatenates waves: wav[i] is the number of effective (useful waves) of individual i.
Death is a valid wave (if date is known).
- mw[mi][i] is the number of (mi=1 to wav[i]) effective wave out of mi of individual i
+ mw[mi][i] is the number of (mi=firstpass to wav[i]) effective wave out of mi of individual i
dh[m][i] or dh[mw[mi][i]][i] is the delay between two effective waves m=mw[mi][i]
and mw[mi+1][i]. dh depends on stepm.
*/
/* ------ Other prevalence ratios------------ */
free_ivector(wav,1,imx);
- free_imatrix(dh,1,lastpass-firstpass+2,1,imx);
- free_imatrix(bh,1,lastpass-firstpass+2,1,imx);
- free_imatrix(mw,1,lastpass-firstpass+2,1,imx);
-
+ /* free_imatrix(dh,1,lastpass-firstpass+2,1,imx); */
+ /* free_imatrix(bh,1,lastpass-firstpass+2,1,imx); */
+ /* free_imatrix(mw,1,lastpass-firstpass+2,1,imx); */
+ free_imatrix(dh,firstpass,lastpass+1,1,imx);
+ free_imatrix(bh,firstpass,lastpass+1,1,imx);
+ free_imatrix(mw,firstpass,lastpass+1,1,imx);
/*---------- Health expectancies, no variances ------------*/
fflush(ficgp);
- if((nberr >0) || (nbwarn>0)){
- printf("End of Imach with %d errors and/or %d warnings. Please look at the log file for details.\n",nberr,nbwarn);
- fprintf(ficlog,"End of Imach with %d errors and/or warnings %d. Please look at the log file for details.\n",nberr,nbwarn);
+ if((nberr >0) || (nbwarn>0) || (nbinfo>0)){
+ printf("End of Imach with %d errors and/or %d warnings and/or infos %d. Please look at the log file for details.\n",nberr,nbwarn,nbinfo);
+ fprintf(ficlog,"End of Imach with %d errors and/or %d warnings and/or infos %d. Please look at the log file for details.\n",nberr,nbwarn,nbinfo);
}else{
printf("End of Imach\n");
fprintf(ficlog,"End of Imach\n");