version 1.103, 2005/09/30 15:54:49
|
version 1.104, 2005/09/30 16:11:43
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.104 2005/09/30 16:11:43 lievre |
|
(Module): sump fixed, loop imx fixed, and simplifications. |
|
(Module): If the status is missing at the last wave but we know |
|
that the person is alive, then we can code his/her status as -2 |
|
(instead of missing=-1 in earlier versions) and his/her |
|
contributions to the likelihood is 1 - Prob of dying from last |
|
health status (= 1-p13= p11+p12 in the easiest case of somebody in |
|
the healthy state at last known wave). Version is 0.98 |
|
|
Revision 1.103 2005/09/30 15:54:49 lievre |
Revision 1.103 2005/09/30 15:54:49 lievre |
(Module): sump fixed, loop imx fixed, and simplifications. |
(Module): sump fixed, loop imx fixed, and simplifications. |
|
|
Line 250
|
Line 259
|
/* $Id$ */ |
/* $Id$ */ |
/* $State$ */ |
/* $State$ */ |
|
|
char version[]="Imach version 0.97c, September 2004, INED-EUROREVES "; |
char version[]="Imach version 0.98, September 2005, INED-EUROREVES "; |
char fullversion[]="$Revision$ $Date$"; |
char fullversion[]="$Revision$ $Date$"; |
int erreur, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ |
int erreur, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ |
int nvar; |
int nvar; |
Line 1264 double func( double *x)
|
Line 1273 double func( double *x)
|
*/ |
*/ |
/* lli= (savm[s1][s2]>1.e-8 ?(1.+bbh)*log(out[s1][s2])- bbh*log(savm[s1][s2]):log((1.+bbh)*out[s1][s2]));*/ |
/* lli= (savm[s1][s2]>1.e-8 ?(1.+bbh)*log(out[s1][s2])- bbh*log(savm[s1][s2]):log((1.+bbh)*out[s1][s2]));*/ |
if( s2 > nlstate){ |
if( s2 > nlstate){ |
/* i.e. if s2 is a death state and if the date of death is known then the contribution |
/* i.e. if s2 is a death state and if the date of death is known |
to the likelihood is the probability to die between last step unit time and current |
then the contribution to the likelihood is the probability to |
step unit time, which is also equal to probability to die before dh |
die between last step unit time and current step unit time, |
|
which is also equal to probability to die before dh |
minus probability to die before dh-stepm . |
minus probability to die before dh-stepm . |
In version up to 0.92 likelihood was computed |
In version up to 0.92 likelihood was computed |
as if date of death was unknown. Death was treated as any other |
as if date of death was unknown. Death was treated as any other |
Line 1287 double func( double *x)
|
Line 1297 double func( double *x)
|
lower mortality. |
lower mortality. |
*/ |
*/ |
lli=log(out[s1][s2] - savm[s1][s2]); |
lli=log(out[s1][s2] - savm[s1][s2]); |
}else{ |
|
|
|
|
} else if (s2==-2) { |
|
for (j=1,survp=0. ; j<=nlstate; j++) |
|
survp += out[s1][j]; |
|
lli= survp; |
|
} |
|
|
|
|
|
else{ |
lli= log((1.+bbh)*out[s1][s2]- bbh*savm[s1][s2]); /* linear interpolation */ |
lli= log((1.+bbh)*out[s1][s2]- bbh*savm[s1][s2]); /* linear interpolation */ |
/* lli= (savm[s1][s2]>(double)1.e-8 ?log((1.+bbh)*out[s1][s2]- bbh*(savm[s1][s2])):log((1.+bbh)*out[s1][s2]));*/ /* linear interpolation */ |
/* lli= (savm[s1][s2]>(double)1.e-8 ?log((1.+bbh)*out[s1][s2]- bbh*(savm[s1][s2])):log((1.+bbh)*out[s1][s2]));*/ /* linear interpolation */ |
} |
} |
Line 1871 void freqsummary(char fileres[], int ia
|
Line 1890 void freqsummary(char fileres[], int ia
|
fprintf(ficlog,"Problem with prevalence resultfile: %s\n", fileresp); |
fprintf(ficlog,"Problem with prevalence resultfile: %s\n", fileresp); |
exit(0); |
exit(0); |
} |
} |
freq= ma3x(-1,nlstate+ndeath,-1,nlstate+ndeath,iagemin,iagemax+3); |
freq= ma3x(-2,nlstate+ndeath,-2,nlstate+ndeath,iagemin,iagemax+3); |
j1=0; |
j1=0; |
|
|
j=cptcoveff; |
j=cptcoveff; |
Line 1884 void freqsummary(char fileres[], int ia
|
Line 1903 void freqsummary(char fileres[], int ia
|
j1++; |
j1++; |
/*printf("cptcoveff=%d Tvaraff=%d", cptcoveff,Tvaraff[1]); |
/*printf("cptcoveff=%d Tvaraff=%d", cptcoveff,Tvaraff[1]); |
scanf("%d", i);*/ |
scanf("%d", i);*/ |
for (i=-1; i<=nlstate+ndeath; i++) |
for (i=-2; i<=nlstate+ndeath; i++) |
for (jk=-1; jk<=nlstate+ndeath; jk++) |
for (jk=-2; jk<=nlstate+ndeath; jk++) |
for(m=iagemin; m <= iagemax+3; m++) |
for(m=iagemin; m <= iagemax+3; m++) |
freq[i][jk][m]=0; |
freq[i][jk][m]=0; |
|
|
Line 2010 void freqsummary(char fileres[], int ia
|
Line 2029 void freqsummary(char fileres[], int ia
|
dateintmean=dateintsum/k2cpt; |
dateintmean=dateintsum/k2cpt; |
|
|
fclose(ficresp); |
fclose(ficresp); |
free_ma3x(freq,-1,nlstate+ndeath,-1,nlstate+ndeath, iagemin, iagemax+3); |
free_ma3x(freq,-2,nlstate+ndeath,-2,nlstate+ndeath, iagemin, iagemax+3); |
free_vector(pp,1,nlstate); |
free_vector(pp,1,nlstate); |
free_matrix(prop,1,nlstate,iagemin, iagemax+3); |
free_matrix(prop,1,nlstate,iagemin, iagemax+3); |
/* End of Freq */ |
/* End of Freq */ |
Line 2119 void concatwav(int wav[], int **dh, int
|
Line 2138 void concatwav(int wav[], int **dh, int
|
mi=0; |
mi=0; |
m=firstpass; |
m=firstpass; |
while(s[m][i] <= nlstate){ |
while(s[m][i] <= nlstate){ |
if(s[m][i]>=1) |
if(s[m][i]>=1 || s[m][i]==-2) |
mw[++mi][i]=m; |
mw[++mi][i]=m; |
if(m >=lastpass) |
if(m >=lastpass) |
break; |
break; |
Line 2173 void concatwav(int wav[], int **dh, int
|
Line 2192 void concatwav(int wav[], int **dh, int
|
} |
} |
else{ |
else{ |
j= rint( (agev[mw[mi+1][i]][i]*12 - agev[mw[mi][i]][i]*12)); |
j= rint( (agev[mw[mi+1][i]][i]*12 - agev[mw[mi][i]][i]*12)); |
/* printf("%d %d %d %d\n", s[mw[mi][i]][i] ,s[mw[mi+1][i]][i],j,i);*/ |
/* if (j<0) printf("%d %lf %lf %d %d %d\n", i,agev[mw[mi+1][i]][i], agev[mw[mi][i]][i],j,s[mw[mi][i]][i] ,s[mw[mi+1][i]][i]); */ |
|
|
k=k+1; |
k=k+1; |
if (j >= jmax) jmax=j; |
if (j >= jmax) jmax=j; |
else if (j <= jmin)jmin=j; |
else if (j <= jmin)jmin=j; |
Line 2266 void tricode(int *Tvar, int **nbcode, in
|
Line 2286 void tricode(int *Tvar, int **nbcode, in
|
for (k=0; k< maxncov; k++) Ndum[k]=0; |
for (k=0; k< maxncov; k++) Ndum[k]=0; |
|
|
for (i=1; i<=ncovmodel-2; i++) { |
for (i=1; i<=ncovmodel-2; i++) { |
/* Listing of all covariables in staement model to see if some covariates appear twice. For example, V1 appears twice in V1+V1*V2.*/ |
/* Listing of all covariables in statement model to see if some covariates appear twice. For example, V1 appears twice in V1+V1*V2.*/ |
ij=Tvar[i]; |
ij=Tvar[i]; |
Ndum[ij]++; |
Ndum[ij]++; |
} |
} |
Line 4569 int main(int argc, char *argv[])
|
Line 4589 int main(int argc, char *argv[])
|
for (i=1; i<=imx; i++) { |
for (i=1; i<=imx; i++) { |
agedc[i]=(moisdc[i]/12.+andc[i])-(moisnais[i]/12.+annais[i]); |
agedc[i]=(moisdc[i]/12.+andc[i])-(moisnais[i]/12.+annais[i]); |
for(m=firstpass; (m<= lastpass); m++){ |
for(m=firstpass; (m<= lastpass); m++){ |
if(s[m][i] >0){ |
if(s[m][i] >0 || s[m][i]==-2){ |
if (s[m][i] >= nlstate+1) { |
if (s[m][i] >= nlstate+1) { |
if(agedc[i]>0) |
if(agedc[i]>0) |
if((int)moisdc[i]!=99 && (int)andc[i]!=9999) |
if((int)moisdc[i]!=99 && (int)andc[i]!=9999) |