version 1.132, 2009/07/06 08:22:05
|
version 1.135, 2009/10/29 15:33:14
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.135 2009/10/29 15:33:14 brouard |
|
(Module): Now imach stops if date of birth, at least year of birth, is not given. Some cleaning of the code. |
|
|
|
Revision 1.134 2009/10/29 13:18:53 brouard |
|
(Module): Now imach stops if date of birth, at least year of birth, is not given. Some cleaning of the code. |
|
|
|
Revision 1.133 2009/07/06 10:21:25 brouard |
|
just nforces |
|
|
Revision 1.132 2009/07/06 08:22:05 brouard |
Revision 1.132 2009/07/06 08:22:05 brouard |
Many tings |
Many tings |
|
|
Line 171
|
Line 180
|
|
|
The same imach parameter file can be used but the option for mle should be -3. |
The same imach parameter file can be used but the option for mle should be -3. |
|
|
Agnès, who wrote this part of the code, tried to keep most of the |
Agnès, who wrote this part of the code, tried to keep most of the |
former routines in order to include the new code within the former code. |
former routines in order to include the new code within the former code. |
|
|
The output is very simple: only an estimate of the intercept and of |
The output is very simple: only an estimate of the intercept and of |
Line 304
|
Line 313
|
Also this programme outputs the covariance matrix of the parameters but also |
Also this programme outputs the covariance matrix of the parameters but also |
of the life expectancies. It also computes the period (stable) prevalence. |
of the life expectancies. It also computes the period (stable) prevalence. |
|
|
Authors: Nicolas Brouard (brouard@ined.fr) and Agnès Lièvre (lievre@ined.fr). |
Authors: Nicolas Brouard (brouard@ined.fr) and Agnès Lièvre (lievre@ined.fr). |
Institut national d'études démographiques, Paris. |
Institut national d'études démographiques, Paris. |
This software have been partly granted by Euro-REVES, a concerted action |
This software have been partly granted by Euro-REVES, a concerted action |
from the European Union. |
from the European Union. |
It is copyrighted identically to a GNU software product, ie programme and |
It is copyrighted identically to a GNU software product, ie programme and |
Line 403 extern int errno;
|
Line 412 extern int errno;
|
/* $Id$ */ |
/* $Id$ */ |
/* $State$ */ |
/* $State$ */ |
|
|
char version[]="Imach version 0.98k, June 2006, INED-EUROREVES-Institut de longevite "; |
char version[]="Imach version 0.98l, October 2009, INED-EUROREVES-Institut de longevite "; |
char fullversion[]="$Revision$ $Date$"; |
char fullversion[]="$Revision$ $Date$"; |
char strstart[80]; |
char strstart[80]; |
char optionfilext[10], optionfilefiname[FILENAMELENGTH]; |
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; /* Error number, number of errors number of warnings */ |
int nvar=0; |
int nvar=0, nforce=0; /* Number of variables, number of forces */ |
int cptcovn=0, cptcovage=0, cptcoveff=0,cptcov=0; /* Number of covariates, of covariates with '*age' */ |
int cptcovn=0, cptcovage=0, cptcoveff=0,cptcov=0; /* Number of covariates, of covariates with '*age' */ |
int npar=NPARMAX; |
int npar=NPARMAX; |
int nlstate=2; /* Number of live states */ |
int nlstate=2; /* Number of live states */ |
Line 3479 To be simple, these graphs help to under
|
Line 3488 To be simple, these graphs help to under
|
/* Computing eigen value of matrix of covariance */ |
/* Computing eigen value of matrix of covariance */ |
lc1=((v1+v2)+sqrt((v1+v2)*(v1+v2) - 4*(v1*v2-cv12*cv12)))/2.; |
lc1=((v1+v2)+sqrt((v1+v2)*(v1+v2) - 4*(v1*v2-cv12*cv12)))/2.; |
lc2=((v1+v2)-sqrt((v1+v2)*(v1+v2) - 4*(v1*v2-cv12*cv12)))/2.; |
lc2=((v1+v2)-sqrt((v1+v2)*(v1+v2) - 4*(v1*v2-cv12*cv12)))/2.; |
|
if ((lc2 <0) || (lc1 <0) ){ |
|
printf("Error: One eigen value of 2x2 matrix of covariance is negative, lc1=%11.3e, lc2=%11.3e, v1=%11.3e, v2=%11.3e, cv12=%11.3e.\n It means that the matrix was not well estimated (varpij), for i=%2d, j=%2d, age=%4d .\n See files %s and %s. Continuing by making them positive: WRONG RESULTS.\n", lc1, lc2, v1, v2, cv12, i, j, (int)age,fileresprobcov, fileresprobcor); |
|
fprintf(ficlog,"Error: One eigen value of 2x2 matrix of covariance is negative, lc1=%11.3e, lc2=%11.3e, v1=%11.3e, v2=%11.3e, cv12=%11.3e\n", lc1, lc2, v1, v2, cv12);fflush(ficlog); |
|
lc1=fabs(lc1); |
|
lc2=fabs(lc2); |
|
} |
|
|
/* Eigen vectors */ |
/* Eigen vectors */ |
v11=(1./sqrt(1+(v1-lc1)*(v1-lc1)/cv12/cv12)); |
v11=(1./sqrt(1+(v1-lc1)*(v1-lc1)/cv12/cv12)); |
/*v21=sqrt(1.-v11*v11); *//* error */ |
/*v21=sqrt(1.-v11*v11); *//* error */ |
Line 4660 int main(int argc, char *argv[])
|
Line 4676 int main(int argc, char *argv[])
|
/* where is ncovprod ?*/ |
/* where is ncovprod ?*/ |
ncovmodel=2+cptcovn; /*Number of variables = cptcovn + intercept + age : v1+v2+v3+v2*v4+v5*age makes 5+2=7*/ |
ncovmodel=2+cptcovn; /*Number of variables = cptcovn + intercept + age : v1+v2+v3+v2*v4+v5*age makes 5+2=7*/ |
nvar=ncovmodel-1; /* Suppressing age as a basic covariate */ |
nvar=ncovmodel-1; /* Suppressing age as a basic covariate */ |
nforces= (nlstate+ndeath-1)*nlstate; /* Number of forces ij from state i to j */ |
nforce= (nlstate+ndeath-1)*nlstate; /* Number of forces ij from state i to j */ |
npar= (nlstate+ndeath-1)*nlstate*ncovmodel; /* Number of parameters like aij*/ |
npar= nforce*ncovmodel; /* Number of parameters like aij*/ |
if(npar >MAXPARM || nlstate >NLSTATEMAX || ndeath >NDEATHMAX || ncovmodel>NCOVMAX){ |
if(npar >MAXPARM || nlstate >NLSTATEMAX || ndeath >NDEATHMAX || ncovmodel>NCOVMAX){ |
printf("Too complex model for current IMaCh: npar=(nlstate+ndeath-1)*nlstate*ncovmodel=%d >= %d(MAXPARM) or nlstate=%d >= %d(NLSTATEMAX) or ndeath=%d >= %d(NDEATHMAX) or ncovmodel=(k+age+#of+signs)=%d(NCOVMAX) >= %d\n",npar, MAXPARM, nlstate, NLSTATEMAX, ndeath, NDEATHMAX, ncovmodel, NCOVMAX); |
printf("Too complex model for current IMaCh: npar=(nlstate+ndeath-1)*nlstate*ncovmodel=%d >= %d(MAXPARM) or nlstate=%d >= %d(NLSTATEMAX) or ndeath=%d >= %d(NDEATHMAX) or ncovmodel=(k+age+#of+signs)=%d(NCOVMAX) >= %d\n",npar, MAXPARM, nlstate, NLSTATEMAX, ndeath, NDEATHMAX, ncovmodel, NCOVMAX); |
fprintf(ficlog,"Too complex model for current IMaCh: %d >=%d(MAXPARM) or %d >=%d(NLSTATEMAX) or %d >=%d(NDEATHMAX) or %d(NCOVMAX) >=%d\n",npar, MAXPARM, nlstate, NLSTATEMAX, ndeath, NDEATHMAX, ncovmodel, NCOVMAX); |
fprintf(ficlog,"Too complex model for current IMaCh: %d >=%d(MAXPARM) or %d >=%d(NLSTATEMAX) or %d >=%d(NDEATHMAX) or %d(NCOVMAX) >=%d\n",npar, MAXPARM, nlstate, NLSTATEMAX, ndeath, NDEATHMAX, ncovmodel, NCOVMAX); |
Line 4942 run imach with mle=-1 to get a correct t
|
Line 4958 run imach with mle=-1 to get a correct t
|
month=99; |
month=99; |
year=9999; |
year=9999; |
}else{ |
}else{ |
printf("Error reading data around '%s' at line number %ld %s for individual %d, '%s'\nShould be a date of birth (mm/yyyy or .). Exiting.\n",strb, linei,i,line,j); |
printf("Error reading data around '%s' at line number %ld for individual %d, '%s'\nShould be a date of birth (mm/yyyy or .). Exiting.\n",strb, linei,i,line); |
fprintf(ficlog,"Error reading data around '%s' at line number %ld %s for individual %d, '%s'\nShould be a date of birth (mm/yyyy or .). Exiting.\n",strb, linei,i,line,j);fflush(ficlog); |
fprintf(ficlog,"Error reading data around '%s' at line number %ld for individual %d, '%s'\nShould be a date of birth (mm/yyyy or .). Exiting.\n",strb, linei,i,line);fflush(ficlog); |
|
goto end; |
|
} |
|
if (year==9999) { |
|
printf("Error reading data around '%s' at line number %ld 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 %ld 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); |
goto end; |
goto end; |
|
|
} |
} |
annais[i]=(double)(year); |
annais[i]=(double)(year); |
moisnais[i]=(double)(month); |
moisnais[i]=(double)(month); |
Line 5169 run imach with mle=-1 to get a correct t
|
Line 5191 run imach with mle=-1 to get a correct t
|
agev[m][i]=1; |
agev[m][i]=1; |
else if(agev[m][i] <agemin){ |
else if(agev[m][i] <agemin){ |
agemin=agev[m][i]; |
agemin=agev[m][i]; |
/*printf(" Min anint[%d][%d]=%.2f annais[%d]=%.2f, agemin=%.2f\n",m,i,anint[m][i], i,annais[i], agemin);*/ |
printf(" Min anint[%d][%d]=%.2f annais[%d]=%.2f, agemin=%.2f\n",m,i,anint[m][i], i,annais[i], agemin); |
} |
} |
else if(agev[m][i] >agemax){ |
else if(agev[m][i] >agemax){ |
agemax=agev[m][i]; |
agemax=agev[m][i]; |