Diff for /imach/src/imach.c between versions 1.248 and 1.249

version 1.248, 2016/09/07 14:10:18 version 1.249, 2016/09/07 17:14:18
Line 1 Line 1
 /* $Id$  /* $Id$
   $State$    $State$
   $Log$    $Log$
     Revision 1.249  2016/09/07 17:14:18  brouard
     Summary: Starting values from frequencies
   
   Revision 1.248  2016/09/07 14:10:18  brouard    Revision 1.248  2016/09/07 14:10:18  brouard
   *** empty log message ***    *** empty log message ***
   
Line 4249  Title=%s <br>Datafile=%s Firstpass=%d La Line 4252  Title=%s <br>Datafile=%s Firstpass=%d La
   j=cptcoveff;  /* Only dummy covariates of the model */    j=cptcoveff;  /* Only dummy covariates of the model */
   if (cptcovn<1) {j=1;ncodemax[1]=1;}    if (cptcovn<1) {j=1;ncodemax[1]=1;}
       
   first=1;  
       
   /* Detects if a combination j1 is empty: for a multinomial variable like 3 education levels:    /* Detects if a combination j1 is empty: for a multinomial variable like 3 education levels:
      reference=low_education V1=0,V2=0       reference=low_education V1=0,V2=0
Line 4257  Title=%s <br>Datafile=%s Firstpass=%d La Line 4259  Title=%s <br>Datafile=%s Firstpass=%d La
      high_educ               V1=0 V2=1       high_educ               V1=0 V2=1
      Then V1=1 and V2=1 is a noisy combination that we want to exclude for the list 2**cptcoveff        Then V1=1 and V2=1 is a noisy combination that we want to exclude for the list 2**cptcoveff 
   */    */
       dateintsum=0;
     k2cpt=0;
   
     for (j = 0; j <= cptcoveff; j+=cptcoveff){   
     first=1;
   for (j1 = 1; j1 <= (int) pow(2,j); j1++){ /* Loop on covariates combination in order of model, excluding quantitatives V4=0, V3=0 for example, fixed or varying covariates */    for (j1 = 1; j1 <= (int) pow(2,j); j1++){ /* Loop on covariates combination in order of model, excluding quantitatives V4=0, V3=0 for example, fixed or varying covariates */
     posproptt=0.;      posproptt=0.;
     /*printf("cptcoveff=%d Tvaraff=%d", cptcoveff,Tvaraff[1]);      /*printf("cptcoveff=%d Tvaraff=%d", cptcoveff,Tvaraff[1]);
Line 4280  Title=%s <br>Datafile=%s Firstpass=%d La Line 4286  Title=%s <br>Datafile=%s Firstpass=%d La
     /*   } */      /*   } */
     /* } */      /* } */
           
     dateintsum=0;      /* dateintsum=0; */
     k2cpt=0;      /* k2cpt=0; */
   
     /* For that combination of covariate j1, we count and print the frequencies in one pass */      /* For that combination of covariate j1, we count and print the frequencies in one pass */
     for (iind=1; iind<=imx; iind++) { /* For each individual iind */      for (iind=1; iind<=imx; iind++) { /* For each individual iind */
       bool=1;        bool=1;
         if(j !=0){
       if(anyvaryingduminmodel==0){ /* If All fixed covariates */        if(anyvaryingduminmodel==0){ /* If All fixed covariates */
         if (cptcoveff >0) { /* Filter is here: Must be looked at for model=V1+V2+V3+V4 */          if (cptcoveff >0) { /* Filter is here: Must be looked at for model=V1+V2+V3+V4 */
           /* for (z1=1; z1<= nqfveff; z1++) {   */            /* for (z1=1; z1<= nqfveff; z1++) {   */
Line 4307  Title=%s <br>Datafile=%s Firstpass=%d La Line 4315  Title=%s <br>Datafile=%s Firstpass=%d La
           } /* end z1 */            } /* end z1 */
         } /* cptcovn > 0 */          } /* cptcovn > 0 */
       } /* end any */        } /* end any */
         }/* end j==0 */
       if (bool==1){ /* We selected an individual iind satisfying combination j1 or all fixed */        if (bool==1){ /* We selected an individual iind satisfying combination j1 or all fixed */
         /* for(m=firstpass; m<=lastpass; m++){ */          /* for(m=firstpass; m<=lastpass; m++){ */
         for(mi=1; mi<wav[iind];mi++){ /* For that wave */          for(mi=1; mi<wav[iind];mi++){ /* For that wave */
           m=mw[mi][iind];            m=mw[mi][iind];
             if(j!=0){
           if(anyvaryingduminmodel==1){ /* Some are varying covariates */            if(anyvaryingduminmodel==1){ /* Some are varying covariates */
             for (z1=1; z1<=cptcoveff; z1++) {              for (z1=1; z1<=cptcoveff; z1++) {
               if( Fixed[Tmodelind[z1]]==1){                if( Fixed[Tmodelind[z1]]==1){
                 iv= Tvar[Tmodelind[z1]]-ncovcol-nqv;                  iv= Tvar[Tmodelind[z1]]-ncovcol-nqv;
                 if (cotvar[m][iv][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,z1)]) /* iv=1 to ntv, right modality */                  if (cotvar[m][iv][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,z1)]) /* iv=1 to ntv, right modality */
                   bool=0;                    bool=0; /* not selected */
               }else if( Fixed[Tmodelind[z1]]== 0) { /* fixed */                }else if( Fixed[Tmodelind[z1]]== 0) { /* fixed */
                 if (covar[Tvaraff[z1]][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,z1)]) {                  if (covar[Tvaraff[z1]][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,z1)]) {
                   bool=0;                    bool=0;
Line 4324  Title=%s <br>Datafile=%s Firstpass=%d La Line 4334  Title=%s <br>Datafile=%s Firstpass=%d La
               }                }
             }              }
           }/* Some are varying covariates, we tried to speed up if all fixed covariates in the model, avoiding waves loop  */            }/* Some are varying covariates, we tried to speed up if all fixed covariates in the model, avoiding waves loop  */
             } /* end j==0 */
           /* bool =0 we keep that guy which corresponds to the combination of dummy values */            /* bool =0 we keep that guy which corresponds to the combination of dummy values */
           if(bool==1){            if(bool==1){
             /* dh[m][iind] or dh[mw[mi][iind]][iind] is the delay between two effective (mi) waves m=mw[mi][iind]              /* dh[m][iind] or dh[mw[mi][iind]][iind] is the delay between two effective (mi) waves m=mw[mi][iind]
Line 4347  Title=%s <br>Datafile=%s Firstpass=%d La Line 4358  Title=%s <br>Datafile=%s Firstpass=%d La
                 freq[s[m][iind]][s[m+1][iind]][iagemax+3] += weight[iind]; /* Total is in iagemax+3 *//* At age of beginning of transition, where status is known */                  freq[s[m][iind]][s[m+1][iind]][iagemax+3] += weight[iind]; /* Total is in iagemax+3 *//* At age of beginning of transition, where status is known */
               }                }
             } /* end if between passes */                } /* end if between passes */  
             if ((agev[m][iind]>1) && (agev[m][iind]< (iagemax+3)) && (anint[m][iind]!=9999) && (mint[m][iind]!=99)) {              if ((agev[m][iind]>1) && (agev[m][iind]< (iagemax+3)) && (anint[m][iind]!=9999) && (mint[m][iind]!=99) && (j==0)) {
               dateintsum=dateintsum+k2;                dateintsum=dateintsum+k2; /* on all covariates ?*/
               k2cpt++;                k2cpt++;
               /* printf("iind=%ld dateintmean = %lf dateintsum=%lf k2cpt=%lf k2=%lf\n",iind, dateintsum/k2cpt, dateintsum,k2cpt, k2); */                /* printf("iind=%ld dateintmean = %lf dateintsum=%lf k2cpt=%lf k2=%lf\n",iind, dateintsum/k2cpt, dateintsum,k2cpt, k2); */
             }              }
Line 4362  Title=%s <br>Datafile=%s Firstpass=%d La Line 4373  Title=%s <br>Datafile=%s Firstpass=%d La
           
     /*      fprintf(ficresp, "#Count between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2);*/      /*      fprintf(ficresp, "#Count between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2);*/
     pstamp(ficresp);      pstamp(ficresp);
     if  (cptcoveff>0){      if  (cptcoveff>0 && j!=0){
       fprintf(ficresp, "\n#********** Variable ");         fprintf(ficresp, "\n#********** Variable "); 
       fprintf(ficresphtm, "\n<br/><br/><h3>********** Variable ");         fprintf(ficresphtm, "\n<br/><br/><h3>********** Variable "); 
       fprintf(ficresphtmfr, "\n<br/><br/><h3>********** Variable ");         fprintf(ficresphtmfr, "\n<br/><br/><h3>********** Variable "); 
Line 4528  Title=%s <br>Datafile=%s Firstpass=%d La Line 4539  Title=%s <br>Datafile=%s Firstpass=%d La
     }      }
     fprintf(ficresphtmfr,"</table>\n");      fprintf(ficresphtmfr,"</table>\n");
   } /* end selected combination of covariate j1 */    } /* end selected combination of covariate j1 */
     if(j==0){ /* We can estimate starting values from the occurences in each case */
       for(jk=-1; jk <=nlstate+ndeath; jk++){
         for(m=-1; m <=nlstate+ndeath; m++){
           /* param[i]|j][k]= freq[jk][m][iagemax+3] */
           if(freq[jk][m][iage] !=0 ) { /* minimizing output */
             if(first==1){
               printf(" %d%d=%.0f",jk,m,freq[jk][m][iage]);
             }
             fprintf(ficlog," %d%d=%.0f",jk,m,freq[jk][m][iage]);
           }
         }
       } /* end loop jk */
     }
     } /* end j */
   dateintmean=dateintsum/k2cpt;     dateintmean=dateintsum/k2cpt; 
       
   fclose(ficresp);    fclose(ficresp);

Removed from v.1.248  
changed lines
  Added in v.1.249


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