|
|
| version 1.127, 2006/04/28 18:11:50 | version 1.130, 2009/05/26 06:44:34 |
|---|---|
| Line 1 | Line 1 |
| /* $Id$ | /* $Id$ |
| $State$ | $State$ |
| $Log$ | $Log$ |
| Revision 1.130 2009/05/26 06:44:34 brouard | |
| (Module): Max Covariate is now set to 20 instead of 8. A | |
| lot of cleaning with variables initialized to 0. Trying to make | |
| V2+V3*age+V1+V4 strb=V3*age+V1+V4 working better. | |
| Revision 1.129 2007/08/31 13:49:27 lievre | |
| Modification of the way of exiting when the covariate is not binary in order to see on the window the error message before exiting | |
| Revision 1.128 2006/06/30 13:02:05 brouard | |
| (Module): Clarifications on computing e.j | |
| Revision 1.127 2006/04/28 18:11:50 brouard | Revision 1.127 2006/04/28 18:11:50 brouard |
| (Module): Yes the sum of survivors was wrong since | (Module): Yes the sum of survivors was wrong since |
| imach-114 because nhstepm was no more computed in the age | imach-114 because nhstepm was no more computed in the age |
| Line 367 extern int errno; | Line 378 extern int errno; |
| #define NINTERVMAX 8 | #define NINTERVMAX 8 |
| #define NLSTATEMAX 8 /* Maximum number of live states (for func) */ | #define NLSTATEMAX 8 /* Maximum number of live states (for func) */ |
| #define NDEATHMAX 8 /* Maximum number of dead states (for func) */ | #define NDEATHMAX 8 /* Maximum number of dead states (for func) */ |
| #define NCOVMAX 8 /* Maximum number of covariates */ | #define NCOVMAX 20 /* Maximum number of covariates */ |
| #define MAXN 20000 | #define MAXN 20000 |
| #define YEARM 12. /* Number of months per year */ | #define YEARM 12. /* Number of months per year */ |
| #define AGESUP 130 | #define AGESUP 130 |
| Line 386 extern int errno; | Line 397 extern int errno; |
| /* $Id$ */ | /* $Id$ */ |
| /* $State$ */ | /* $State$ */ |
| char version[]="Imach version 0.98h, April 2006, INED-EUROREVES-Institut de longevite "; | char version[]="Imach version 0.98i, June 2006, 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, 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; | int nvar=0; |
| int cptcovn=0, cptcovage=0, cptcoveff=0,cptcov; | 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 */ |
| int ndeath=1; /* Number of dead states */ | int ndeath=1; /* Number of dead states */ |
| int ncovmodel, ncovcol; /* Total number of covariables including constant a12*1 +b12*x ncovmodel=2 */ | int ncovmodel=0, ncovcol=0; /* Total number of covariables including constant a12*1 +b12*x ncovmodel=2 */ |
| int popbased=0; | int popbased=0; |
| int *wav; /* Number of waves for this individuual 0 is possible */ | int *wav; /* Number of waves for this individuual 0 is possible */ |
| int maxwav; /* Maxim number of waves */ | int maxwav=0; /* Maxim number of waves */ |
| int jmin, jmax; /* min, max spacing between 2 waves */ | int jmin=0, jmax=0; /* min, max spacing between 2 waves */ |
| int ijmin, ijmax; /* Individuals having jmin and jmax */ | int ijmin=0, ijmax=0; /* Individuals having jmin and jmax */ |
| int gipmx, gsw; /* Global variables on the number of contributions | int gipmx=0, gsw=0; /* Global variables on the number of contributions |
| to the likelihood and the sum of weights (done by funcone)*/ | to the likelihood and the sum of weights (done by funcone)*/ |
| int mle, weightopt; | int mle=1, weightopt=0; |
| int **mw; /* mw[mi][i] is number of the mi wave for this individual */ | int **mw; /* mw[mi][i] is number of the mi wave for this individual */ |
| int **dh; /* dh[mi][i] is number of steps between mi,mi+1 for this individual */ | int **dh; /* dh[mi][i] is number of steps between mi,mi+1 for this individual */ |
| int **bh; /* bh[mi][i] is the bias (+ or -) for this individual if the delay between | int **bh; /* bh[mi][i] is the bias (+ or -) for this individual if the delay between |
| * wave mi and wave mi+1 is not an exact multiple of stepm. */ | * wave mi and wave mi+1 is not an exact multiple of stepm. */ |
| double jmean; /* Mean space between 2 waves */ | double jmean=1; /* Mean space between 2 waves */ |
| double **oldm, **newm, **savm; /* Working pointers to matrices */ | double **oldm, **newm, **savm; /* Working pointers to matrices */ |
| double **oldms, **newms, **savms; /* Fixed working pointers to matrices */ | double **oldms, **newms, **savms; /* Fixed working pointers to matrices */ |
| FILE *fic,*ficpar, *ficparo,*ficres, *ficresp, *ficrespl, *ficrespij, *ficrest,*ficresf,*ficrespop; | FILE *fic,*ficpar, *ficparo,*ficres, *ficresp, *ficrespl, *ficrespij, *ficrest,*ficresf,*ficrespop; |
| FILE *ficlog, *ficrespow; | FILE *ficlog, *ficrespow; |
| int globpr; /* Global variable for printing or not */ | int globpr=0; /* Global variable for printing or not */ |
| double fretone; /* Only one call to likelihood */ | double fretone; /* Only one call to likelihood */ |
| long ipmx; /* Number of contributions */ | long ipmx=0; /* Number of contributions */ |
| double sw; /* Sum of weights */ | double sw; /* Sum of weights */ |
| char filerespow[FILENAMELENGTH]; | char filerespow[FILENAMELENGTH]; |
| char fileresilk[FILENAMELENGTH]; /* File of individual contributions to the likelihood */ | char fileresilk[FILENAMELENGTH]; /* File of individual contributions to the likelihood */ |
| Line 1344 double ***hpxij(double ***po, int nhstep | Line 1355 double ***hpxij(double ***po, int nhstep |
| for(i=1; i<=nlstate+ndeath; i++) | for(i=1; i<=nlstate+ndeath; i++) |
| for(j=1;j<=nlstate+ndeath;j++) { | for(j=1;j<=nlstate+ndeath;j++) { |
| po[i][j][h]=newm[i][j]; | po[i][j][h]=newm[i][j]; |
| /*printf("i=%d j=%d h=%d po[i][j][h]=%f ",i,j,h,po[i][j][h]); | /*if(h==nhstepm) printf("po[%d][%d][%d]=%f ",i,j,h,po[i][j][h]);*/ |
| */ | |
| } | } |
| /*printf("h=%d ",h);*/ | |
| } /* end h */ | } /* end h */ |
| /* printf("\n H=%d \n",h); */ | |
| return po; | return po; |
| } | } |
| Line 2037 void pstamp(FILE *fichier) | Line 2049 void pstamp(FILE *fichier) |
| void freqsummary(char fileres[], int iagemin, int iagemax, int **s, double **agev, int nlstate, int imx, int *Tvaraff, int **nbcode, int *ncodemax,double **mint,double **anint, char strstart[]) | void freqsummary(char fileres[], int iagemin, int iagemax, int **s, double **agev, int nlstate, int imx, int *Tvaraff, int **nbcode, int *ncodemax,double **mint,double **anint, char strstart[]) |
| { /* Some frequencies */ | { /* Some frequencies */ |
| int i, m, jk, k1,i1, j1, bool, z1,z2,j; | int i, m, jk, k1,i1, j1, bool, z1,j; |
| int first; | int first; |
| double ***freq; /* Frequencies */ | double ***freq; /* Frequencies */ |
| double *pp, **prop; | double *pp, **prop; |
| Line 2206 void prevalence(double ***probs, double | Line 2218 void prevalence(double ***probs, double |
| We still use firstpass and lastpass as another selection. | We still use firstpass and lastpass as another selection. |
| */ | */ |
| int i, m, jk, k1, i1, j1, bool, z1,z2,j; | int i, m, jk, k1, i1, j1, bool, z1,j; |
| double ***freq; /* Frequencies */ | double ***freq; /* Frequencies */ |
| double *pp, **prop; | double *pp, **prop; |
| double pos,posprop; | double pos,posprop; |
| Line 2264 void prevalence(double ***probs, double | Line 2276 void prevalence(double ***probs, double |
| if( i <= iagemax){ | if( i <= iagemax){ |
| if(posprop>=1.e-5){ | if(posprop>=1.e-5){ |
| probs[i][jk][j1]= prop[jk][i]/posprop; | probs[i][jk][j1]= prop[jk][i]/posprop; |
| } | } else |
| printf("Warning Observed prevalence probs[%d][%d][%d]=%lf because of lack of cases\n",jk,i,j1,probs[i][jk][j1]); | |
| } | } |
| }/* end jk */ | }/* end jk */ |
| }/* end i */ | }/* end i */ |
| Line 2422 void concatwav(int wav[], int **dh, int | Line 2435 void concatwav(int wav[], int **dh, int |
| void tricode(int *Tvar, int **nbcode, int imx) | void tricode(int *Tvar, int **nbcode, int imx) |
| { | { |
| int Ndum[20],ij=1, k, j, i, maxncov=19; | /* Tvar[i]=atoi(stre); /* find 'n' in Vn and stores in Tvar. If model=V2+V1 Tvar[1]=2 and Tvar[2]=1 */ |
| int Ndum[20],ij=1, k=0, j=0, i=0, maxncov=19; | |
| int cptcode=0; | int cptcode=0; |
| cptcoveff=0; | cptcoveff=0; |
| Line 2868 void varevsij(char optionfilefiname[], d | Line 2883 void varevsij(char optionfilefiname[], d |
| pstamp(ficresvij); | pstamp(ficresvij); |
| fprintf(ficresvij,"# Variance and covariance of health expectancies e.j \n# (weighted average of eij where weights are "); | fprintf(ficresvij,"# Variance and covariance of health expectancies e.j \n# (weighted average of eij where weights are "); |
| if(popbased==1) | if(popbased==1) |
| fprintf(ficresvij,"the age specific prevalence observed in the population i.e cross-sectionally\n in each health state (popbased=1)"); | fprintf(ficresvij,"the age specific prevalence observed (cross-sectionally) in the population i.e cross-sectionally\n in each health state (popbased=1) (mobilav=%d\n",mobilav); |
| else | else |
| fprintf(ficresvij,"the age specific period (stable) prevalences in each health state \n"); | fprintf(ficresvij,"the age specific period (stable) prevalences in each health state \n"); |
| fprintf(ficresvij,"# Age"); | fprintf(ficresvij,"# Age"); |
| Line 2896 void varevsij(char optionfilefiname[], d | Line 2911 void varevsij(char optionfilefiname[], d |
| /* hstepm beeing the number of stepms, if hstepm=1 the length of hstepm is stepm. | /* hstepm beeing the number of stepms, if hstepm=1 the length of hstepm is stepm. |
| nhstepm is the number of hstepm from age to agelim | nhstepm is the number of hstepm from age to agelim |
| nstepm is the number of stepm from age to agelin. | nstepm is the number of stepm from age to agelin. |
| Look at hpijx to understand the reason of that which relies in memory size | Look at function hpijx to understand why (it is linked to memory size questions) */ |
| and note for a fixed period like k years */ | |
| /* We decided (b) to get a life expectancy respecting the most precise curvature of the | /* We decided (b) to get a life expectancy respecting the most precise curvature of the |
| survival function given by stepm (the optimization length). Unfortunately it | survival function given by stepm (the optimization length). Unfortunately it |
| means that if the survival funtion is printed every two years of age and if | means that if the survival funtion is printed every two years of age and if |
| Line 2963 void varevsij(char optionfilefiname[], d | Line 2977 void varevsij(char optionfilefiname[], d |
| } | } |
| } | } |
| for(j=1; j<= nlstate; j++){ | for(j=1; j<= nlstate; j++){ /* Sum of wi * eij = e.j */ |
| for(h=0; h<=nhstepm; h++){ | for(h=0; h<=nhstepm; h++){ |
| for(i=1, gm[h][j]=0.;i<=nlstate;i++) | for(i=1, gm[h][j]=0.;i<=nlstate;i++) |
| gm[h][j] += prlim[i][i]*p3mat[i][j][h]; | gm[h][j] += prlim[i][i]*p3mat[i][j][h]; |
| Line 3523 void printinghtml(char fileres[], char t | Line 3537 void printinghtml(char fileres[], char t |
| - Period (stable) prevalence in each health state: <a href=\"%s\">%s</a> <br>\n", | - Period (stable) prevalence in each health state: <a href=\"%s\">%s</a> <br>\n", |
| subdirf2(fileres,"pl"),subdirf2(fileres,"pl")); | subdirf2(fileres,"pl"),subdirf2(fileres,"pl")); |
| fprintf(fichtm,"\ | fprintf(fichtm,"\ |
| - (a) Life expectancies by health status at initial age, (b) health expectancies by health status at initial age: ei., eij . If one or more covariate are included, specific tables for each value of the covariate are output in sequences within the same file (estepm=%2d months): \ | - (a) Life expectancies by health status at initial age, ei. (b) health expectancies by health status at initial age, eij . If one or more covariates are included, specific tables for each value of the covariate are output in sequences within the same file (estepm=%2d months): \ |
| <a href=\"%s\">%s</a> <br>\n", | <a href=\"%s\">%s</a> <br>\n", |
| estepm,subdirf2(fileres,"e"),subdirf2(fileres,"e")); | estepm,subdirf2(fileres,"e"),subdirf2(fileres,"e")); |
| fprintf(fichtm,"\ | fprintf(fichtm,"\ |
| Line 3588 fprintf(fichtm," \n<ul><li><b>Graphs</b> | Line 3602 fprintf(fichtm," \n<ul><li><b>Graphs</b> |
| <a href=\"%s\">%s</a> <br>\n</li>", | <a href=\"%s\">%s</a> <br>\n</li>", |
| estepm,subdirf2(fileres,"stde"),subdirf2(fileres,"stde")); | estepm,subdirf2(fileres,"stde"),subdirf2(fileres,"stde")); |
| fprintf(fichtm,"\ | fprintf(fichtm,"\ |
| - Variances and covariances of health expectancies by age. Status (i) based health expectancies (in state j), eij are weighted by the period prevalences in each state i (if popbased=1, an additional computation is done using the cross-sectional prevalences (i.e population based) (estepm=%d months): <a href=\"%s\">%s</a><br>\n", | - Variances and covariances of health expectancies by age. Status (i) based health expectancies (in state j), e<sup>ij</sup> are weighted by the period prevalences in each state i (if popbased=1, an additional computation is done using the cross-sectional prevalences, i.e population based) (estepm=%d months): <a href=\"%s\">%s</a><br>\n", |
| estepm, subdirf2(fileres,"v"),subdirf2(fileres,"v")); | estepm, subdirf2(fileres,"v"),subdirf2(fileres,"v")); |
| fprintf(fichtm,"\ | fprintf(fichtm,"\ |
| - Total life expectancy and total health expectancies to be spent in each health state e<sup>.j</sup> with their standard errors: <a href=\"%s\">%s</a> <br>\n", | - Total life expectancy and total health expectancies to be spent in each health state e<sup>.j</sup> with their standard errors (if popbased=1, an additional computation is done using the cross-sectional prevalences, i.e population based) (estepm=%d months): <a href=\"%s\">%s</a> <br>\n", |
| subdirf2(fileres,"t"),subdirf2(fileres,"t")); | estepm, subdirf2(fileres,"t"),subdirf2(fileres,"t")); |
| fprintf(fichtm,"\ | fprintf(fichtm,"\ |
| - Standard deviation of period (stable) prevalences: <a href=\"%s\">%s</a> <br>\n",\ | - Standard deviation of period (stable) prevalences: <a href=\"%s\">%s</a> <br>\n",\ |
| subdirf2(fileres,"vpl"),subdirf2(fileres,"vpl")); | subdirf2(fileres,"vpl"),subdirf2(fileres,"vpl")); |
| Line 3625 prevalence (with 95%% confidence interva | Line 3639 prevalence (with 95%% confidence interva |
| <img src=\"%s%d%d.png\">",cpt,subdirf2(optionfilefiname,"v"),cpt,jj1,subdirf2(optionfilefiname,"v"),cpt,jj1); | <img src=\"%s%d%d.png\">",cpt,subdirf2(optionfilefiname,"v"),cpt,jj1,subdirf2(optionfilefiname,"v"),cpt,jj1); |
| } | } |
| fprintf(fichtm,"\n<br>- Total life expectancy by age and \ | fprintf(fichtm,"\n<br>- Total life expectancy by age and \ |
| health expectancies in states (1) and (2): %s%d.png<br>\ | health expectancies in states (1) and (2). If popbased=1 the smooth (due to the model) \ |
| true period expectancies (those weighted with period prevalences are also\ | |
| drawn in addition to the population based expectancies computed using\ | |
| observed and cahotic prevalences: %s%d.png<br>\ | |
| <img src=\"%s%d.png\">",subdirf2(optionfilefiname,"e"),jj1,subdirf2(optionfilefiname,"e"),jj1); | <img src=\"%s%d.png\">",subdirf2(optionfilefiname,"e"),jj1,subdirf2(optionfilefiname,"e"),jj1); |
| } /* end i1 */ | } /* end i1 */ |
| }/* End k1 */ | }/* End k1 */ |
| Line 3637 health expectancies in states (1) and (2 | Line 3654 health expectancies in states (1) and (2 |
| void printinggnuplot(char fileres[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){ | void printinggnuplot(char fileres[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){ |
| char dirfileres[132],optfileres[132]; | char dirfileres[132],optfileres[132]; |
| int m,cpt,k1,i,k,j,jk,k2,k3,ij,l; | int m0,cpt=0,k1=0,i=0,k=0,j=0,jk=0,k2=0,k3=0,ij=0,l=0; |
| int ng; | int ng=0; |
| /* if((ficgp=fopen(optionfilegnuplot,"a"))==NULL) { */ | /* if((ficgp=fopen(optionfilegnuplot,"a"))==NULL) { */ |
| /* printf("Problem with file %s",optionfilegnuplot); */ | /* printf("Problem with file %s",optionfilegnuplot); */ |
| /* fprintf(ficlog,"Problem with file %s",optionfilegnuplot); */ | /* fprintf(ficlog,"Problem with file %s",optionfilegnuplot); */ |
| Line 4388 int main(int argc, char *argv[]) | Line 4405 int main(int argc, char *argv[]) |
| int numlinepar=0; /* Current linenumber of parameter file */ | int numlinepar=0; /* Current linenumber of parameter file */ |
| int itimes; | int itimes; |
| int NDIM=2; | int NDIM=2; |
| int vpopbased=0; | |
| char ca[32], cb[32], cc[32]; | char ca[32], cb[32], cc[32]; |
| char dummy[]=" "; | char dummy[]=" "; |
| Line 4907 run imach with mle=-1 to get a correct t | Line 4925 run imach with mle=-1 to get a correct t |
| and V1=0 V2=1 for (3). V1=1 V2=1 should not exist and the corresponding\n \ | and V1=0 V2=1 for (3). V1=1 V2=1 should not exist and the corresponding\n \ |
| output of IMaCh is often meaningless.\n \ | output of IMaCh is often meaningless.\n \ |
| Exiting.\n",lval,linei, i,line,j); | Exiting.\n",lval,linei, i,line,j); |
| exit(1); | goto end; |
| } | } |
| covar[j][i]=(double)(lval); | covar[j][i]=(double)(lval); |
| strcpy(line,stra); | strcpy(line,stra); |
| } | } |
| lstra=strlen(stra); | lstra=strlen(stra); |
| if(lstra > 9){ /* More than 2**32 or max of what printf can write with %ld */ | if(lstra > 9){ /* More than 2**32 or max of what printf can write with %ld */ |
| stratrunc = &(stra[lstra-9]); | stratrunc = &(stra[lstra-9]); |
| num[i]=atol(stratrunc); | num[i]=atol(stratrunc); |
| Line 4955 run imach with mle=-1 to get a correct t | Line 4973 run imach with mle=-1 to get a correct t |
| j=0, j1=0, k1=1, k2=1; | j=0, j1=0, k1=1, k2=1; |
| j=nbocc(model,'+'); /* j=Number of '+' */ | j=nbocc(model,'+'); /* j=Number of '+' */ |
| j1=nbocc(model,'*'); /* j1=Number of '*' */ | j1=nbocc(model,'*'); /* j1=Number of '*' */ |
| cptcovn=j+1; | cptcovn=j+1; /* Number of covariates V1+V2+V3 =>2+1=3 */ |
| cptcovprod=j1; /*Number of products */ | cptcovprod=j1; /*Number of products V1*V2 =1 */ |
| strcpy(modelsav,model); | strcpy(modelsav,model); |
| if ((strcmp(model,"age")==0) || (strcmp(model,"age*age")==0)){ | if ((strcmp(model,"age")==0) || (strcmp(model,"age*age")==0)){ |
| Line 4966 run imach with mle=-1 to get a correct t | Line 4984 run imach with mle=-1 to get a correct t |
| } | } |
| /* This loop fills the array Tvar from the string 'model'.*/ | /* This loop fills the array Tvar from the string 'model'.*/ |
| /* j is the number of + signs in the model V1+V2+V3 j=2 i=3 to 1 */ | |
| for(i=(j+1); i>=1;i--){ | for(i=(j+1); i>=1;i--){ |
| cutv(stra,strb,modelsav,'+'); /* keeps in strb after the last + */ | cutv(stra,strb,modelsav,'+'); /* keeps in strb after the first '+' |
| modelsav=V2+V3*age+V1+V4 strb=V3*age+V1+V4 | |
| stra=V2 | |
| */ | |
| if (nbocc(modelsav,'+')==0) strcpy(strb,modelsav); /* and analyzes it */ | if (nbocc(modelsav,'+')==0) strcpy(strb,modelsav); /* and analyzes it */ |
| /* printf("i=%d a=%s b=%s sav=%s\n",i, stra,strb,modelsav);*/ | /* printf("i=%d a=%s b=%s sav=%s\n",i, stra,strb,modelsav);*/ |
| /*scanf("%d",i);*/ | /*scanf("%d",i);*/ |
| if (strchr(strb,'*')) { /* Model includes a product */ | if (strchr(strb,'*')) { /* Model includes a product V1+V3*age+V2 strb=V3*age*/ |
| cutv(strd,strc,strb,'*'); /* strd*strc Vm*Vn (if not *age)*/ | cutv(strd,strc,strb,'*'); /* strd*strc Vm*Vn: V3*age strc=age strd=V3 ; V3*V2 strc=V2, strd=V3 */ |
| if (strcmp(strc,"age")==0) { /* Vn*age */ | if (strcmp(strc,"age")==0) { /* Vn*age */ |
| cptcovprod--; | cptcovprod--; |
| cutv(strb,stre,strd,'V'); | cutv(strb,stre,strd,'V'); |
| Tvar[i]=atoi(stre); /* computes n in Vn and stores in Tvar*/ | Tvar[i]=atoi(stre); /* V1+V3*age+V2 Tvar[2]=3 */ |
| cptcovage++; | cptcovage++; /* Sum the number of covariates including ages as a product */ |
| Tage[cptcovage]=i; | Tage[cptcovage]=i; /* Tage[1] =2 */ |
| /*printf("stre=%s ", stre);*/ | /*printf("stre=%s ", stre);*/ |
| } | } |
| else if (strcmp(strd,"age")==0) { /* or age*Vn */ | else if (strcmp(strd,"age")==0) { /* or age*Vn */ |
| cptcovprod--; | cptcovprod--; |
| Line 4989 run imach with mle=-1 to get a correct t | Line 5010 run imach with mle=-1 to get a correct t |
| cptcovage++; | cptcovage++; |
| Tage[cptcovage]=i; | Tage[cptcovage]=i; |
| } | } |
| else { /* Age is not in the model */ | else { /* Age is not in the model V1+V3*V2+V2 strb=V3*V2*/ |
| cutv(strb,stre,strc,'V'); /* strc= Vn, stre is n*/ | cutv(strb,stre,strc,'V'); /* strc= Vn, stre is n; strb=V3*V2 stre=3 strc=*/ |
| Tvar[i]=ncovcol+k1; | Tvar[i]=ncovcol+k1; /* find 'n' in Vn and stores in Tvar. |
| If already ncovcol=2 and model=V2*V1 Tvar[1]=2+1 and Tvar[2]=2+2 etc */ | |
| cutv(strb,strc,strd,'V'); /* strd was Vm, strc is m */ | cutv(strb,strc,strd,'V'); /* strd was Vm, strc is m */ |
| Tprod[k1]=i; | Tprod[k1]=i; /* Tprod[1] */ |
| Tvard[k1][1]=atoi(strc); /* m*/ | Tvard[k1][1]=atoi(strc); /* m*/ |
| Tvard[k1][2]=atoi(stre); /* n */ | Tvard[k1][2]=atoi(stre); /* n */ |
| Tvar[cptcovn+k2]=Tvard[k1][1]; | Tvar[cptcovn+k2]=Tvard[k1][1]; |
| Line 5010 run imach with mle=-1 to get a correct t | Line 5032 run imach with mle=-1 to get a correct t |
| cutv(strd,strc,strb,'V'); | cutv(strd,strc,strb,'V'); |
| Tvar[i]=atoi(strc); | Tvar[i]=atoi(strc); |
| } | } |
| strcpy(modelsav,stra); | strcpy(modelsav,stra); /* modelsav=V2+V3*age+V1+V4 strb=V3*age+V1+V4 */ |
| /*printf("a=%s b=%s sav=%s\n", stra,strb,modelsav); | /*printf("a=%s b=%s sav=%s\n", stra,strb,modelsav); |
| scanf("%d",i);*/ | scanf("%d",i);*/ |
| } /* end of loop + */ | } /* end of loop + */ |
| Line 5156 run imach with mle=-1 to get a correct t | Line 5178 run imach with mle=-1 to get a correct t |
| for(cpt=1; cpt <=(m/pow(2,cptcoveff+1-k)); cpt++){ | for(cpt=1; cpt <=(m/pow(2,cptcoveff+1-k)); cpt++){ |
| h++; | h++; |
| if (h>m) h=1;codtab[h][k]=j;codtab[h][Tvar[k]]=j; | if (h>m) h=1;codtab[h][k]=j;codtab[h][Tvar[k]]=j; |
| /* printf("h=%d k=%d j=%d codtab[h][k]=%d tvar[k]=%d \n",h, k,j,codtab[h][k],Tvar[k]);*/ | printf("h=%d k=%d j=%d codtab[h][k]=%d Tvar[k]=%d codtab[h][Tvar[k]]=%d \n",h, k,j,codtab[h][k],Tvar[k],codtab[h][Tvar[k]]); |
| } | } |
| } | } |
| } | } |
| Line 5863 Interval (in months) between two waves: | Line 5885 Interval (in months) between two waves: |
| cvevsij(eij, p, nlstate, stepm, (int) bage, (int)fage, oldm, savm, k, estepm, delti, matcov, strstart); | cvevsij(eij, p, nlstate, stepm, (int) bage, (int)fage, oldm, savm, k, estepm, delti, matcov, strstart); |
| vareij=ma3x(1,nlstate,1,nlstate,(int) bage, (int) fage); | vareij=ma3x(1,nlstate,1,nlstate,(int) bage, (int) fage); |
| oldm=oldms;savm=savms; | |
| varevsij(optionfilefiname, vareij, matcov, p, delti, nlstate, stepm, (int) bage, (int) fage, oldm, savm, prlim, ftolpl,k, estepm, cptcov,cptcod,0, mobilav, strstart); | |
| if(popbased==1){ | |
| varevsij(optionfilefiname, vareij, matcov, p, delti, nlstate, stepm, (int) bage, (int) fage, oldm, savm, prlim, ftolpl,k, estepm, cptcov,cptcod,popbased,mobilav, strstart); | |
| } | |
| pstamp(ficrest); | pstamp(ficrest); |
| fprintf(ficrest,"# Total life expectancy with std error and decomposition into time to be expected in each health state\n# Age ( e.. (std) "); | for(vpopbased=0; vpopbased <= popbased; vpopbased++){ /* Done for vpopbased=0 and vpopbased=1 if popbased==1*/ |
| for (i=1;i<=nlstate;i++) fprintf(ficrest,"e.%d (std) ",i); | oldm=oldms;savm=savms; |
| fprintf(ficrest,"\n"); | varevsij(optionfilefiname, vareij, matcov, p, delti, nlstate, stepm, (int) bage, (int) fage, oldm, savm, prlim, ftolpl,k, estepm, cptcov,cptcod,vpopbased,mobilav, strstart); fprintf(ficrest,"# Total life expectancy with std error and decomposition into time to be expected in each health state\n# (weighted average of eij where weights are "); |
| if(vpopbased==1) | |
| fprintf(ficrest,"the age specific prevalence observed (cross-sectionally) in the population i.e cross-sectionally\n in each health state (popbased=1) (mobilav=%d)\n",mobilav); | |
| else | |
| fprintf(ficrest,"the age specific period (stable) prevalences in each health state \n"); | |
| fprintf(ficrest,"# Age e.. (std) "); | |
| for (i=1;i<=nlstate;i++) fprintf(ficrest,"e.%d (std) ",i); | |
| fprintf(ficrest,"\n"); | |
| epj=vector(1,nlstate+1); | epj=vector(1,nlstate+1); |
| for(age=bage; age <=fage ;age++){ | for(age=bage; age <=fage ;age++){ |
| prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k); | prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k); |
| if (popbased==1) { | if (vpopbased==1) { |
| if(mobilav ==0){ | if(mobilav ==0){ |
| for(i=1; i<=nlstate;i++) | for(i=1; i<=nlstate;i++) |
| prlim[i][i]=probs[(int)age][i][k]; | prlim[i][i]=probs[(int)age][i][k]; |
| }else{ /* mobilav */ | }else{ /* mobilav */ |
| for(i=1; i<=nlstate;i++) | for(i=1; i<=nlstate;i++) |
| prlim[i][i]=mobaverage[(int)age][i][k]; | prlim[i][i]=mobaverage[(int)age][i][k]; |
| } | |
| } | } |
| } | |
| fprintf(ficrest," %4.0f",age); | fprintf(ficrest," %4.0f",age); |
| for(j=1, epj[nlstate+1]=0.;j <=nlstate;j++){ | for(j=1, epj[nlstate+1]=0.;j <=nlstate;j++){ |
| for(i=1, epj[j]=0.;i <=nlstate;i++) { | for(i=1, epj[j]=0.;i <=nlstate;i++) { |
| epj[j] += prlim[i][i]*eij[i][j][(int)age]; | epj[j] += prlim[i][i]*eij[i][j][(int)age]; |
| /* printf("%lf %lf ", prlim[i][i] ,eij[i][j][(int)age]);*/ | /* printf("%lf %lf ", prlim[i][i] ,eij[i][j][(int)age]);*/ |
| } | |
| epj[nlstate+1] +=epj[j]; | |
| } | } |
| epj[nlstate+1] +=epj[j]; | |
| } | |
| for(i=1, vepp=0.;i <=nlstate;i++) | for(i=1, vepp=0.;i <=nlstate;i++) |
| for(j=1;j <=nlstate;j++) | for(j=1;j <=nlstate;j++) |
| vepp += vareij[i][j][(int)age]; | vepp += vareij[i][j][(int)age]; |
| fprintf(ficrest," %7.3f (%7.3f)", epj[nlstate+1],sqrt(vepp)); | fprintf(ficrest," %7.3f (%7.3f)", epj[nlstate+1],sqrt(vepp)); |
| for(j=1;j <=nlstate;j++){ | for(j=1;j <=nlstate;j++){ |
| fprintf(ficrest," %7.3f (%7.3f)", epj[j],sqrt(vareij[j][j][(int)age])); | fprintf(ficrest," %7.3f (%7.3f)", epj[j],sqrt(vareij[j][j][(int)age])); |
| } | |
| fprintf(ficrest,"\n"); | |
| } | } |
| fprintf(ficrest,"\n"); | |
| } | } |
| free_ma3x(eij,1,nlstate,1,nlstate,(int) bage, (int)fage); | free_ma3x(eij,1,nlstate,1,nlstate,(int) bage, (int)fage); |
| free_ma3x(vareij,1,nlstate,1,nlstate,(int) bage, (int)fage); | free_ma3x(vareij,1,nlstate,1,nlstate,(int) bage, (int)fage); |