version 1.101, 2004/09/15 10:38:38
|
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 |
|
(Module): sump fixed, loop imx fixed, and simplifications. |
|
|
|
Revision 1.102 2004/09/15 17:31:30 brouard |
|
Add the possibility to read data file including tab characters. |
|
|
Revision 1.101 2004/09/15 10:38:38 brouard |
Revision 1.101 2004/09/15 10:38:38 brouard |
Fix on curr_time |
Fix on curr_time |
|
|
Line 244
|
Line 259
|
/* $Id$ */ |
/* $Id$ */ |
/* $State$ */ |
/* $State$ */ |
|
|
char version[]="Imach version 0.97b, May 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 439 int nbocc(char *s, char occ)
|
Line 454 int nbocc(char *s, char occ)
|
|
|
void cutv(char *u,char *v, char*t, char occ) |
void cutv(char *u,char *v, char*t, char occ) |
{ |
{ |
/* cuts string t into u and v where u is ended by char occ excluding it |
/* cuts string t into u and v where u ends before first occurence of char 'occ' |
and v is after occ excluding it too : ex cutv(u,v,"abcdef2ghi2j",2) |
and v starts after first occurence of char 'occ' : ex cutv(u,v,"abcdef2ghi2j",'2') |
gives u="abcedf" and v="ghi2j" */ |
gives u="abcedf" and v="ghi2j" */ |
int i,lg,j,p=0; |
int i,lg,j,p=0; |
i=0; |
i=0; |
Line 1258 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 1281 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 1865 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 1878 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 2004 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 2113 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 2167 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 2260 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 3918 double gompertz(double x[])
|
Line 3944 double gompertz(double x[])
|
int i,n=0; /* n is the size of the sample */ |
int i,n=0; /* n is the size of the sample */ |
for (i=0;i<=imx-1 ; i++) { |
for (i=0;i<=imx-1 ; i++) { |
sump=sump+weight[i]; |
sump=sump+weight[i]; |
sump=sump+1; |
/* sump=sump+1;*/ |
num=num+1; |
num=num+1; |
} |
} |
|
|
|
|
/* for (i=1; i<=imx; i++) |
/* for (i=0; i<=imx; i++) |
if (wav[i]>0) printf("i=%d ageex=%lf agecens=%lf agedc=%lf cens=%d %d\n" ,i,ageexmed[i],agecens[i],agedc[i],cens[i],wav[i]);*/ |
if (wav[i]>0) printf("i=%d ageex=%lf agecens=%lf agedc=%lf cens=%d %d\n" ,i,ageexmed[i],agecens[i],agedc[i],cens[i],wav[i]);*/ |
|
|
for (i=0;i<=imx-1 ; i++) |
for (i=1;i<=imx ; i++) |
{ |
{ |
if (cens[i]==1 & wav[i]>1) |
if (cens[i]==1 & wav[i]>1) |
A=-x[1]/(x[2])* |
A=-x[1]/(x[2])*(exp(x[2]*(agecens[i]-agegomp))-exp(x[2]*(ageexmed[i]-agegomp))); |
(exp(x[2]/YEARM*(agecens[i]*12-agegomp*12))-exp(x[2]/YEARM*(ageexmed[i]*12-agegomp*12))); |
|
|
|
if (cens[i]==0 & wav[i]>1) |
if (cens[i]==0 & wav[i]>1) |
A=-x[1]/(x[2])* |
A=-x[1]/(x[2])*(exp(x[2]*(agedc[i]-agegomp))-exp(x[2]*(ageexmed[i]-agegomp))) |
(exp(x[2]/YEARM*(agedc[i]*12-agegomp*12))-exp(x[2]/YEARM*(ageexmed[i]*12-agegomp*12))) |
+log(x[1]/YEARM)+x[2]*(agedc[i]-agegomp)+log(YEARM); |
+log(x[1]/YEARM)+x[2]/YEARM*(agedc[i]*12-agegomp*12)+log(YEARM); |
|
|
|
if (wav[i]>1 & agecens[i]>15) { |
if (wav[i]>1 & agecens[i]>15) { |
L=L+A*weight[i]; |
L=L+A*weight[i]; |
Line 4399 int main(int argc, char *argv[])
|
Line 4423 int main(int argc, char *argv[])
|
i=1; |
i=1; |
while (fgets(line, MAXLINE, fic) != NULL) { |
while (fgets(line, MAXLINE, fic) != NULL) { |
if ((i >= firstobs) && (i <=lastobs)) { |
if ((i >= firstobs) && (i <=lastobs)) { |
|
for(j=0; line[j] != '\n';j++){ /* Untabifies line */ |
|
if(line[j] == '\t') |
|
line[j] = ' '; |
|
} |
for (j=maxwav;j>=1;j--){ |
for (j=maxwav;j>=1;j--){ |
cutv(stra, strb,line,' '); s[j][i]=atoi(strb); |
cutv(stra, strb,line,' '); s[j][i]=atoi(strb); |
strcpy(line,stra); |
strcpy(line,stra); |
Line 4562 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) |