version 1.205, 2015/10/23 15:50:53
|
version 1.207, 2015/10/27 17:36:57
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.207 2015/10/27 17:36:57 brouard |
|
*** empty log message *** |
|
|
|
Revision 1.206 2015/10/24 07:14:11 brouard |
|
*** empty log message *** |
|
|
Revision 1.205 2015/10/23 15:50:53 brouard |
Revision 1.205 2015/10/23 15:50:53 brouard |
Summary: 0.98r3 some clarification for graphs on likelihood contributions |
Summary: 0.98r3 some clarification for graphs on likelihood contributions |
|
|
Line 1960 double **prevalim(double **prlim, int nl
|
Line 1966 double **prevalim(double **prlim, int nl
|
{ |
{ |
/* Computes the prevalence limit in each live state at age x by left multiplying the unit |
/* Computes the prevalence limit in each live state at age x by left multiplying the unit |
matrix by transitions matrix until convergence is reached with precision ftolpl */ |
matrix by transitions matrix until convergence is reached with precision ftolpl */ |
|
/* Wx= Wx-1 Px-1= Wx-2 Px-2 Px-1 = Wx-n Px-n ... Px-2 Px-1 I */ |
|
/* Wx is row vector: population in state 1, population in state 2, population dead */ |
|
/* or prevalence in state 1, prevalence in state 2, 0 */ |
|
/* newm is the matrix after multiplications, its rows are identical at a factor */ |
|
/* Initial matrix pimij */ |
|
/* {0.85204250825084937, 0.13044499163996345, 0.017512500109187184, */ |
|
/* 0.090851990222114765, 0.88271245433047185, 0.026435555447413338, */ |
|
/* 0, 0 , 1} */ |
|
/* |
|
* and after some iteration: */ |
|
/* {0.45504275246439968, 0.42731458730878791, 0.11764266022681241, */ |
|
/* 0.45201005341706885, 0.42865420071559901, 0.11933574586733192, */ |
|
/* 0, 0 , 1} */ |
|
/* And prevalence by suppressing the deaths are close to identical rows in prlim: */ |
|
/* {0.51571254859325999, 0.4842874514067399, */ |
|
/* 0.51326036147820708, 0.48673963852179264} */ |
|
/* If we start from prlim again, prlim tends to a constant matrix */ |
|
|
int i, ii,j,k; |
int i, ii,j,k; |
double min, max, maxmin, maxmax,sumnew=0.; |
double min, max, maxmin, maxmax,sumnew=0.; |
/* double **matprod2(); */ /* test */ |
/* double **matprod2(); */ /* test */ |
Line 2016 double **prevalim(double **prlim, int nl
|
Line 2039 double **prevalim(double **prlim, int nl
|
prlim[i][j]= newm[i][j]/(1-sumnew); |
prlim[i][j]= newm[i][j]/(1-sumnew); |
max=FMAX(max,prlim[i][j]); |
max=FMAX(max,prlim[i][j]); |
min=FMIN(min,prlim[i][j]); |
min=FMIN(min,prlim[i][j]); |
/* printf(" age= %d prevalim i=%d, j=%d, prmlim[%d][%d]=%f, agefin=%d max=%f min=%f\n", (int)age, i, j, i, j, prlim[i][j],(int)agefin, max, min); */ |
printf(" age= %d prevalim i=%d, j=%d, prmlim[%d][%d]=%f, agefin=%d max=%f min=%f\n", (int)age, i, j, i, j, prlim[i][j],(int)agefin, max, min); |
} |
} |
maxmin=(max-min)/(max+min)*2; |
maxmin=(max-min)/(max+min)*2; |
maxmax=FMAX(maxmax,maxmin); |
maxmax=FMAX(maxmax,maxmin); |
} /* j loop */ |
} /* j loop */ |
*ncvyear= (int)age- (int)agefin; |
*ncvyear= (int)age- (int)agefin; |
/* printf("maxmax=%lf maxmin=%lf ncvloop=%ld, age=%d, agefin=%d ncvyear=%d \n", maxmax, maxmin, ncvloop, (int)age, (int)agefin, *ncvyear); */ |
printf("maxmax=%lf maxmin=%lf ncvloop=%d, age=%d, agefin=%d ncvyear=%d \n", maxmax, maxmin, ncvloop, (int)age, (int)agefin, *ncvyear); |
if(maxmax < ftolpl){ |
if(maxmax < ftolpl){ |
/* printf("maxmax=%lf maxmin=%lf ncvloop=%ld, age=%d, agefin=%d ncvyear=%d \n", maxmax, maxmin, ncvloop, (int)age, (int)agefin, *ncvyear); */ |
/* printf("maxmax=%lf maxmin=%lf ncvloop=%ld, age=%d, agefin=%d ncvyear=%d \n", maxmax, maxmin, ncvloop, (int)age, (int)agefin, *ncvyear); */ |
return prlim; |
return prlim; |
Line 2647 void likelione(FILE *ficres,double p[],
|
Line 2670 void likelione(FILE *ficres,double p[],
|
fprintf(ficlog,"Problem with resultfile: %s\n", fileresilk); |
fprintf(ficlog,"Problem with resultfile: %s\n", fileresilk); |
} |
} |
fprintf(ficresilk, "#individual(line's_record) count age s1 s2 wave# effective_wave# number_of_matrices_product pij weight weight/gpw -2ln(pij)*weight 0pij_x 0pij_(x-stepm) cumulating_loglikeli_by_health_state(reweighted=-2ll*weightXnumber_of_contribs/sum_of_weights) and_total\n"); |
fprintf(ficresilk, "#individual(line's_record) count age s1 s2 wave# effective_wave# number_of_matrices_product pij weight weight/gpw -2ln(pij)*weight 0pij_x 0pij_(x-stepm) cumulating_loglikeli_by_health_state(reweighted=-2ll*weightXnumber_of_contribs/sum_of_weights) and_total\n"); |
fprintf(ficresilk, "#num_i age i s1 s2 mi mw dh likeli weight %weight 2wlli out sav "); |
fprintf(ficresilk, "#num_i age i s1 s2 mi mw dh likeli weight %%weight 2wlli out sav "); |
/* i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],2*weight[i]*lli,out[s1][s2],savm[s1][s2]); */ |
/* i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],2*weight[i]*lli,out[s1][s2],savm[s1][s2]); */ |
for(k=1; k<=nlstate; k++) |
for(k=1; k<=nlstate; k++) |
fprintf(ficresilk," -2*gipw/gsw*weight*ll[%d]++",k); |
fprintf(ficresilk," -2*gipw/gsw*weight*ll[%d]++",k); |
Line 2662 void likelione(FILE *ficres,double p[],
|
Line 2685 void likelione(FILE *ficres,double p[],
|
else if(mle >=1) |
else if(mle >=1) |
fprintf(fichtm,"\n<br>File of contributions to the likelihood computed with optimized parameters mle = %d.",mle); |
fprintf(fichtm,"\n<br>File of contributions to the likelihood computed with optimized parameters mle = %d.",mle); |
fprintf(fichtm," You should at least run with mle >= 1 to get starting values corresponding to the optimized parameters in order to visualize the real contribution of each individual/wave: <a href=\"%s\">%s</a><br>\n",subdirf(fileresilk),subdirf(fileresilk)); |
fprintf(fichtm," You should at least run with mle >= 1 to get starting values corresponding to the optimized parameters in order to visualize the real contribution of each individual/wave: <a href=\"%s\">%s</a><br>\n",subdirf(fileresilk),subdirf(fileresilk)); |
|
|
fprintf(fichtm,"<br>- The function drawn is -2Log(L) in Log scale: by state of origin <a href=\"%s-ori.png\">%s-ori.png</a><br> \ |
fprintf(fichtm,"<br>- The function drawn is -2Log(L) in Log scale: by state of origin <a href=\"%s-ori.png\">%s-ori.png</a><br> \ |
<img src=\"%s-ori.png\">",subdirf2(optionfilefiname,"ILK_"),subdirf2(optionfilefiname,"ILK_"),subdirf2(optionfilefiname,"ILK_")); |
<img src=\"%s-ori.png\">",subdirf2(optionfilefiname,"ILK_"),subdirf2(optionfilefiname,"ILK_"),subdirf2(optionfilefiname,"ILK_")); |
fprintf(fichtm,"<br>- and by state of destination <a href=\"%s-dest.png\">%s-dest.png</a><br> \ |
fprintf(fichtm,"<br>- and by state of destination <a href=\"%s-dest.png\">%s-dest.png</a><br> \ |
<img src=\"%s-dest.png\">",subdirf2(optionfilefiname,"ILK_"),subdirf2(optionfilefiname,"ILK_"),subdirf2(optionfilefiname,"ILK_")); |
<img src=\"%s-dest.png\">",subdirf2(optionfilefiname,"ILK_"),subdirf2(optionfilefiname,"ILK_"),subdirf2(optionfilefiname,"ILK_")); |
fflush(fichtm); |
fflush(fichtm); |
|
|
for (k=1; k<= nlstate ; k++) { |
for (k=1; k<= nlstate ; k++) { |
fprintf(fichtm,"<br>- Probability p%dj by origin %d and destination j <a href=\"%s-p%dj.png\">%s-p%dj.png</a><br> \ |
fprintf(fichtm,"<br>- Probability p%dj by origin %d and destination j <a href=\"%s-p%dj.png\">%s-p%dj.png</a><br> \ |
<img src=\"%s-p%dj.png\">",k,k,subdirf2(optionfilefiname,"ILK_"),k,subdirf2(optionfilefiname,"ILK_"),k,subdirf2(optionfilefiname,"ILK_"),k); |
<img src=\"%s-p%dj.png\">",k,k,subdirf2(optionfilefiname,"ILK_"),k,subdirf2(optionfilefiname,"ILK_"),k,subdirf2(optionfilefiname,"ILK_"),k); |
} |
} |
} |
} |
return; |
return; |
} |
} |