version 1.244, 2016/09/02 07:17:34
|
version 1.249, 2016/09/07 17:14:18
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.249 2016/09/07 17:14:18 brouard |
|
Summary: Starting values from frequencies |
|
|
|
Revision 1.248 2016/09/07 14:10:18 brouard |
|
*** empty log message *** |
|
|
|
Revision 1.247 2016/09/02 11:11:21 brouard |
|
*** empty log message *** |
|
|
|
Revision 1.246 2016/09/02 08:49:22 brouard |
|
*** empty log message *** |
|
|
|
Revision 1.245 2016/09/02 07:25:01 brouard |
|
*** empty log message *** |
|
|
Revision 1.244 2016/09/02 07:17:34 brouard |
Revision 1.244 2016/09/02 07:17:34 brouard |
*** empty log message *** |
*** empty log message *** |
|
|
Line 2578 Earliest age to start was %d-%d=%d, ncvl
|
Line 2593 Earliest age to start was %d-%d=%d, ncvl
|
/* If we start from prlim again, prlim tends to a constant matrix */ |
/* If we start from prlim again, prlim tends to a constant matrix */ |
|
|
int i, ii,j,k; |
int i, ii,j,k; |
|
int first=0; |
double *min, *max, *meandiff, maxmax,sumnew=0.; |
double *min, *max, *meandiff, maxmax,sumnew=0.; |
/* double **matprod2(); */ /* test */ |
/* double **matprod2(); */ /* test */ |
double **out, cov[NCOVMAX+1], **bmij(); |
double **out, cov[NCOVMAX+1], **bmij(); |
Line 2703 Earliest age to start was %d-%d=%d, ncvl
|
Line 2719 Earliest age to start was %d-%d=%d, ncvl
|
} |
} |
} /* age loop */ |
} /* age loop */ |
/* After some age loop it doesn't converge */ |
/* After some age loop it doesn't converge */ |
printf("Warning: the back stable prevalence at age %d did not converge with the required precision (%g > ftolpl=%g) within %.0f years. Try to lower 'ftolpl'. \n\ |
if(first){ |
|
first=1; |
|
printf("Warning: the back stable prevalence at age %d did not converge with the required precision (%g > ftolpl=%g) within %.0f years. Try to lower 'ftolpl'. Others in log file only...\n\ |
|
Oldest age to start was %d-%d=%d, ncvloop=%d, ncvyear=%d\n", (int)age, maxmax, ftolpl, delaymax, (int)age, (int)delaymax, (int)agefin, ncvloop, *ncvyear); |
|
} |
|
fprintf(ficlog,"Warning: the back stable prevalence at age %d did not converge with the required precision (%g > ftolpl=%g) within %.0f years. Try to lower 'ftolpl'. \n\ |
Oldest age to start was %d-%d=%d, ncvloop=%d, ncvyear=%d\n", (int)age, maxmax, ftolpl, delaymax, (int)age, (int)delaymax, (int)agefin, ncvloop, *ncvyear); |
Oldest age to start was %d-%d=%d, ncvloop=%d, ncvyear=%d\n", (int)age, maxmax, ftolpl, delaymax, (int)age, (int)delaymax, (int)agefin, ncvloop, *ncvyear); |
/* Try to lower 'ftol', for example from 1.e-8 to 6.e-9.\n", ftolpl, (int)age, (int)delaymax, (int)agefin, ncvloop, (int)age-(int)agefin); */ |
/* Try to lower 'ftol', for example from 1.e-8 to 6.e-9.\n", ftolpl, (int)age, (int)delaymax, (int)agefin, ncvloop, (int)age-(int)agefin); */ |
free_vector(min,1,nlstate); |
free_vector(min,1,nlstate); |
Line 3590 double funcone( double *x)
|
Line 3611 double funcone( double *x)
|
agebegin=agev[mw[mi][i]][i]; /* Age at beginning of effective wave */ |
agebegin=agev[mw[mi][i]][i]; /* Age at beginning of effective wave */ |
ageend=agev[mw[mi][i]][i] + (dh[mi][i])*stepm/YEARM; /* Age at end of effective wave and at the end of transition */ |
ageend=agev[mw[mi][i]][i] + (dh[mi][i])*stepm/YEARM; /* Age at end of effective wave and at the end of transition */ |
for(d=0; d<dh[mi][i]; d++){ /* Delay between two effective waves */ |
for(d=0; d<dh[mi][i]; d++){ /* Delay between two effective waves */ |
|
/* for(d=0; d<=0; d++){ /\* Delay between two effective waves Only one matrix to speed up*\/ */ |
/*dh[m][i] or dh[mw[mi][i]][i] is the delay between two effective waves m=mw[mi][i] |
/*dh[m][i] or dh[mw[mi][i]][i] is the delay between two effective waves m=mw[mi][i] |
and mw[mi+1][i]. dh depends on stepm.*/ |
and mw[mi+1][i]. dh depends on stepm.*/ |
newm=savm; |
newm=savm; |
agexact=agev[mw[mi][i]][i]+d*stepm/YEARM; |
agexact=agev[mw[mi][i]][i]+d*stepm/YEARM; /* Here d is needed */ |
cov[2]=agexact; |
cov[2]=agexact; |
if(nagesqr==1) |
if(nagesqr==1) |
cov[3]= agexact*agexact; |
cov[3]= agexact*agexact; |
Line 3646 double funcone( double *x)
|
Line 3668 double funcone( double *x)
|
ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; |
ll[s[mw[mi][i]][i]] += 2*weight[i]*lli; |
/*printf("i=%6d s1=%1d s2=%1d mi=%1d mw=%1d dh=%3d prob=%10.6f w=%6.4f out=%10.6f sav=%10.6f\n",i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],out[s1][s2],savm[s1][s2]); */ |
/*printf("i=%6d s1=%1d s2=%1d mi=%1d mw=%1d dh=%3d prob=%10.6f w=%6.4f out=%10.6f sav=%10.6f\n",i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],out[s1][s2],savm[s1][s2]); */ |
if(globpr){ |
if(globpr){ |
fprintf(ficresilk,"%9ld %6.1f %6.1f %6d %2d %2d %2d %2d %3d %15.6f %8.4f %8.3f\ |
fprintf(ficresilk,"%09ld %6.1f %6.1f %6d %2d %2d %2d %2d %3d %15.6f %8.4f %8.3f\ |
%11.6f %11.6f %11.6f ", \ |
%11.6f %11.6f %11.6f ", \ |
num[i], agebegin, ageend, i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],weight[i]*gipmx/gsw, |
num[i], agebegin, ageend, i,s1,s2,mi,mw[mi][i],dh[mi][i],exp(lli),weight[i],weight[i]*gipmx/gsw, |
2*weight[i]*lli,out[s1][s2],savm[s1][s2]); |
2*weight[i]*lli,out[s1][s2],savm[s1][s2]); |
Line 4004 double hessij( double x[], double **hess
|
Line 4026 double hessij( double x[], double **hess
|
kmax=kmax+10; |
kmax=kmax+10; |
} |
} |
if(kmax >=10 || firstime ==1){ |
if(kmax >=10 || firstime ==1){ |
printf("Warning: directions %d-%d, you are not estimating the Hessian at the exact maximum likelihood; you may increase ftol=%.2e\n",thetai,thetaj, ftol); |
printf("Warning: directions %d-%d, you are not estimating the Hessian at the exact maximum likelihood; you could increase ftol=%.2e\n",thetai,thetaj, ftol); |
fprintf(ficlog,"Warning: directions %d-%d, you are not estimating the Hessian at the exact maximum likelihood; you may increase ftol=%.2e\n",thetai,thetaj, ftol); |
fprintf(ficlog,"Warning: directions %d-%d, you are not estimating the Hessian at the exact maximum likelihood; you could increase ftol=%.2e\n",thetai,thetaj, ftol); |
printf("%d %d k=%d, k1=%.12e k2=%.12e k3=%.12e k4=%.12e delti*k=%.12e deltj*k=%.12e, xi-de*k=%.12e xj-de*k=%.12e res=%.12e k1234=%.12e,k1-2=%.12e,k3-4=%.12e\n",thetai,thetaj,k,k1,k2,k3,k4,delti[thetai]/k,delti[thetaj]/k,x[thetai]-delti[thetai]/k,x[thetaj]-delti[thetaj]/k, res,k1-k2-k3+k4,k1-k2,k3-k4); |
printf("%d %d k=%d, k1=%.12e k2=%.12e k3=%.12e k4=%.12e delti*k=%.12e deltj*k=%.12e, xi-de*k=%.12e xj-de*k=%.12e res=%.12e k1234=%.12e,k1-2=%.12e,k3-4=%.12e\n",thetai,thetaj,k,k1,k2,k3,k4,delti[thetai]/k,delti[thetaj]/k,x[thetai]-delti[thetai]/k,x[thetaj]-delti[thetaj]/k, res,k1-k2-k3+k4,k1-k2,k3-k4); |
fprintf(ficlog,"%d %d k=%d, k1=%.12e k2=%.12e k3=%.12e k4=%.12e delti*k=%.12e deltj*k=%.12e, xi-de*k=%.12e xj-de*k=%.12e res=%.12e k1234=%.12e,k1-2=%.12e,k3-4=%.12e\n",thetai,thetaj,k,k1,k2,k3,k4,delti[thetai]/k,delti[thetaj]/k,x[thetai]-delti[thetai]/k,x[thetaj]-delti[thetaj]/k, res,k1-k2-k3+k4,k1-k2,k3-k4); |
fprintf(ficlog,"%d %d k=%d, k1=%.12e k2=%.12e k3=%.12e k4=%.12e delti*k=%.12e deltj*k=%.12e, xi-de*k=%.12e xj-de*k=%.12e res=%.12e k1234=%.12e,k1-2=%.12e,k3-4=%.12e\n",thetai,thetaj,k,k1,k2,k3,k4,delti[thetai]/k,delti[thetaj]/k,x[thetai]-delti[thetai]/k,x[thetaj]-delti[thetaj]/k, res,k1-k2-k3+k4,k1-k2,k3-k4); |
} |
} |
Line 4230 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4252 Title=%s <br>Datafile=%s Firstpass=%d La
|
j=cptcoveff; /* Only dummy covariates of the model */ |
j=cptcoveff; /* Only dummy covariates of the model */ |
if (cptcovn<1) {j=1;ncodemax[1]=1;} |
if (cptcovn<1) {j=1;ncodemax[1]=1;} |
|
|
first=1; |
|
|
|
/* Detects if a combination j1 is empty: for a multinomial variable like 3 education levels: |
/* Detects if a combination j1 is empty: for a multinomial variable like 3 education levels: |
reference=low_education V1=0,V2=0 |
reference=low_education V1=0,V2=0 |
Line 4238 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4259 Title=%s <br>Datafile=%s Firstpass=%d La
|
high_educ V1=0 V2=1 |
high_educ V1=0 V2=1 |
Then V1=1 and V2=1 is a noisy combination that we want to exclude for the list 2**cptcoveff |
Then V1=1 and V2=1 is a noisy combination that we want to exclude for the list 2**cptcoveff |
*/ |
*/ |
|
dateintsum=0; |
|
k2cpt=0; |
|
|
|
for (j = 0; j <= cptcoveff; j+=cptcoveff){ |
|
first=1; |
for (j1 = 1; j1 <= (int) pow(2,j); j1++){ /* Loop on covariates combination in order of model, excluding quantitatives V4=0, V3=0 for example, fixed or varying covariates */ |
for (j1 = 1; j1 <= (int) pow(2,j); j1++){ /* Loop on covariates combination in order of model, excluding quantitatives V4=0, V3=0 for example, fixed or varying covariates */ |
posproptt=0.; |
posproptt=0.; |
/*printf("cptcoveff=%d Tvaraff=%d", cptcoveff,Tvaraff[1]); |
/*printf("cptcoveff=%d Tvaraff=%d", cptcoveff,Tvaraff[1]); |
Line 4261 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4286 Title=%s <br>Datafile=%s Firstpass=%d La
|
/* } */ |
/* } */ |
/* } */ |
/* } */ |
|
|
dateintsum=0; |
/* dateintsum=0; */ |
k2cpt=0; |
/* k2cpt=0; */ |
|
|
/* For that combination of covariate j1, we count and print the frequencies in one pass */ |
/* For that combination of covariate j1, we count and print the frequencies in one pass */ |
for (iind=1; iind<=imx; iind++) { /* For each individual iind */ |
for (iind=1; iind<=imx; iind++) { /* For each individual iind */ |
bool=1; |
bool=1; |
|
if(j !=0){ |
if(anyvaryingduminmodel==0){ /* If All fixed covariates */ |
if(anyvaryingduminmodel==0){ /* If All fixed covariates */ |
if (cptcoveff >0) { /* Filter is here: Must be looked at for model=V1+V2+V3+V4 */ |
if (cptcoveff >0) { /* Filter is here: Must be looked at for model=V1+V2+V3+V4 */ |
/* for (z1=1; z1<= nqfveff; z1++) { */ |
/* for (z1=1; z1<= nqfveff; z1++) { */ |
Line 4288 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4315 Title=%s <br>Datafile=%s Firstpass=%d La
|
} /* end z1 */ |
} /* end z1 */ |
} /* cptcovn > 0 */ |
} /* cptcovn > 0 */ |
} /* end any */ |
} /* end any */ |
|
}/* end j==0 */ |
if (bool==1){ /* We selected an individual iind satisfying combination j1 or all fixed */ |
if (bool==1){ /* We selected an individual iind satisfying combination j1 or all fixed */ |
/* for(m=firstpass; m<=lastpass; m++){ */ |
/* for(m=firstpass; m<=lastpass; m++){ */ |
for(mi=1; mi<wav[iind];mi++){ /* For that wave */ |
for(mi=1; mi<wav[iind];mi++){ /* For that wave */ |
m=mw[mi][iind]; |
m=mw[mi][iind]; |
|
if(j!=0){ |
if(anyvaryingduminmodel==1){ /* Some are varying covariates */ |
if(anyvaryingduminmodel==1){ /* Some are varying covariates */ |
for (z1=1; z1<=cptcoveff; z1++) { |
for (z1=1; z1<=cptcoveff; z1++) { |
if( Fixed[Tmodelind[z1]]==1){ |
if( Fixed[Tmodelind[z1]]==1){ |
iv= Tvar[Tmodelind[z1]]-ncovcol-nqv; |
iv= Tvar[Tmodelind[z1]]-ncovcol-nqv; |
if (cotvar[m][iv][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,z1)]) /* iv=1 to ntv, right modality */ |
if (cotvar[m][iv][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,z1)]) /* iv=1 to ntv, right modality */ |
bool=0; |
bool=0; /* not selected */ |
}else if( Fixed[Tmodelind[z1]]== 0) { /* fixed */ |
}else if( Fixed[Tmodelind[z1]]== 0) { /* fixed */ |
if (covar[Tvaraff[z1]][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,z1)]) { |
if (covar[Tvaraff[z1]][iind]!= nbcode[Tvaraff[z1]][codtabm(j1,z1)]) { |
bool=0; |
bool=0; |
Line 4305 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4334 Title=%s <br>Datafile=%s Firstpass=%d La
|
} |
} |
} |
} |
}/* Some are varying covariates, we tried to speed up if all fixed covariates in the model, avoiding waves loop */ |
}/* Some are varying covariates, we tried to speed up if all fixed covariates in the model, avoiding waves loop */ |
|
} /* end j==0 */ |
/* bool =0 we keep that guy which corresponds to the combination of dummy values */ |
/* bool =0 we keep that guy which corresponds to the combination of dummy values */ |
if(bool==1){ |
if(bool==1){ |
/* dh[m][iind] or dh[mw[mi][iind]][iind] is the delay between two effective (mi) waves m=mw[mi][iind] |
/* dh[m][iind] or dh[mw[mi][iind]][iind] is the delay between two effective (mi) waves m=mw[mi][iind] |
Line 4328 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4358 Title=%s <br>Datafile=%s Firstpass=%d La
|
freq[s[m][iind]][s[m+1][iind]][iagemax+3] += weight[iind]; /* Total is in iagemax+3 *//* At age of beginning of transition, where status is known */ |
freq[s[m][iind]][s[m+1][iind]][iagemax+3] += weight[iind]; /* Total is in iagemax+3 *//* At age of beginning of transition, where status is known */ |
} |
} |
} /* end if between passes */ |
} /* end if between passes */ |
if ((agev[m][iind]>1) && (agev[m][iind]< (iagemax+3)) && (anint[m][iind]!=9999) && (mint[m][iind]!=99)) { |
if ((agev[m][iind]>1) && (agev[m][iind]< (iagemax+3)) && (anint[m][iind]!=9999) && (mint[m][iind]!=99) && (j==0)) { |
dateintsum=dateintsum+k2; |
dateintsum=dateintsum+k2; /* on all covariates ?*/ |
k2cpt++; |
k2cpt++; |
/* printf("iind=%ld dateintmean = %lf dateintsum=%lf k2cpt=%lf k2=%lf\n",iind, dateintsum/k2cpt, dateintsum,k2cpt, k2); */ |
/* printf("iind=%ld dateintmean = %lf dateintsum=%lf k2cpt=%lf k2=%lf\n",iind, dateintsum/k2cpt, dateintsum,k2cpt, k2); */ |
} |
} |
Line 4343 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4373 Title=%s <br>Datafile=%s Firstpass=%d La
|
|
|
/* fprintf(ficresp, "#Count between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2);*/ |
/* fprintf(ficresp, "#Count between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2);*/ |
pstamp(ficresp); |
pstamp(ficresp); |
if (cptcoveff>0){ |
if (cptcoveff>0 && j!=0){ |
fprintf(ficresp, "\n#********** Variable "); |
fprintf(ficresp, "\n#********** Variable "); |
fprintf(ficresphtm, "\n<br/><br/><h3>********** Variable "); |
fprintf(ficresphtm, "\n<br/><br/><h3>********** Variable "); |
fprintf(ficresphtmfr, "\n<br/><br/><h3>********** Variable "); |
fprintf(ficresphtmfr, "\n<br/><br/><h3>********** Variable "); |
Line 4509 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4539 Title=%s <br>Datafile=%s Firstpass=%d La
|
} |
} |
fprintf(ficresphtmfr,"</table>\n"); |
fprintf(ficresphtmfr,"</table>\n"); |
} /* end selected combination of covariate j1 */ |
} /* end selected combination of covariate j1 */ |
|
if(j==0){ /* We can estimate starting values from the occurences in each case */ |
|
for(jk=-1; jk <=nlstate+ndeath; jk++){ |
|
for(m=-1; m <=nlstate+ndeath; m++){ |
|
/* param[i]|j][k]= freq[jk][m][iagemax+3] */ |
|
if(freq[jk][m][iage] !=0 ) { /* minimizing output */ |
|
if(first==1){ |
|
printf(" %d%d=%.0f",jk,m,freq[jk][m][iage]); |
|
} |
|
fprintf(ficlog," %d%d=%.0f",jk,m,freq[jk][m][iage]); |
|
} |
|
} |
|
} /* end loop jk */ |
|
} |
|
} /* end j */ |
dateintmean=dateintsum/k2cpt; |
dateintmean=dateintsum/k2cpt; |
|
|
fclose(ficresp); |
fclose(ficresp); |
Line 6398 void printinggnuplot(char fileresu[], ch
|
Line 6442 void printinggnuplot(char fileresu[], ch
|
if(TKresult[nres]!= k1) |
if(TKresult[nres]!= k1) |
continue; |
continue; |
/* We are interested in selected combination by the resultline */ |
/* We are interested in selected combination by the resultline */ |
printf("\n# 1st: Period (stable) prevalence with CI: 'VPL_' files and live state =%d ", cpt); |
/* printf("\n# 1st: Period (stable) prevalence with CI: 'VPL_' files and live state =%d ", cpt); */ |
fprintf(ficgp,"\n# 1st: Period (stable) prevalence with CI: 'VPL_' files and live state =%d ", cpt); |
fprintf(ficgp,"\n# 1st: Period (stable) prevalence with CI: 'VPL_' files and live state =%d ", cpt); |
for (k=1; k<=cptcoveff; k++){ /* For each covariate k get corresponding value lv for combination k1 */ |
for (k=1; k<=cptcoveff; k++){ /* For each covariate k get corresponding value lv for combination k1 */ |
lv= decodtabm(k1,k,cptcoveff); /* Should be the value of the covariate corresponding to k1 combination */ |
lv= decodtabm(k1,k,cptcoveff); /* Should be the value of the covariate corresponding to k1 combination */ |
Line 6407 void printinggnuplot(char fileresu[], ch
|
Line 6451 void printinggnuplot(char fileresu[], ch
|
/* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */ |
/* decodtabm(13,3,4)= 2 because h=13 k= 1 1 (2) 2 */ |
vlv= nbcode[Tvaraff[k]][lv]; /* vlv is the value of the covariate lv, 0 or 1 */ |
vlv= nbcode[Tvaraff[k]][lv]; /* vlv is the value of the covariate lv, 0 or 1 */ |
/* For each combination of covariate k1 (V1=1, V3=0), we printed the current covariate k and its value vlv */ |
/* For each combination of covariate k1 (V1=1, V3=0), we printed the current covariate k and its value vlv */ |
printf(" V%d=%d ",Tvaraff[k],vlv); |
/* printf(" V%d=%d ",Tvaraff[k],vlv); */ |
fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv); |
fprintf(ficgp," V%d=%d ",Tvaraff[k],vlv); |
} |
} |
for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */ |
for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */ |
printf(" V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); |
/* printf(" V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); */ |
fprintf(ficgp," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); |
fprintf(ficgp," V%d=%f ",Tvqresult[nres][k4],Tqresult[nres][k4]); |
} |
} |
printf("\n#\n"); |
/* printf("\n#\n"); */ |
fprintf(ficgp,"\n#\n"); |
fprintf(ficgp,"\n#\n"); |
if(invalidvarcomb[k1]){ |
if(invalidvarcomb[k1]){ |
fprintf(ficgp,"#Combination (%d) ignored because no cases \n",k1); |
fprintf(ficgp,"#Combination (%d) ignored because no cases \n",k1); |
Line 6444 void printinggnuplot(char fileresu[], ch
|
Line 6488 void printinggnuplot(char fileresu[], ch
|
/* fprintf(ficgp,",\"%s\" every :::%d::%d u 1:($%d) t\"Backward stable prevalence\" w l lt 3",subdirf2(fileresu,"PLB_"),k1-1,k1-1,1+cpt); */ |
/* fprintf(ficgp,",\"%s\" every :::%d::%d u 1:($%d) t\"Backward stable prevalence\" w l lt 3",subdirf2(fileresu,"PLB_"),k1-1,k1-1,1+cpt); */ |
fprintf(ficgp,",\"%s\" u 1:((",subdirf2(fileresu,"PLB_")); /* Age is in 1, nres in 2 to be fixed */ |
fprintf(ficgp,",\"%s\" u 1:((",subdirf2(fileresu,"PLB_")); /* Age is in 1, nres in 2 to be fixed */ |
if(cptcoveff ==0){ |
if(cptcoveff ==0){ |
fprintf(ficgp,"$%d)) t 'Backward prevalence in state %d' with line ", 2+(cpt-1), cpt ); |
fprintf(ficgp,"$%d)) t 'Backward prevalence in state %d' with line lt 3", 2+(cpt-1), cpt ); |
}else{ |
}else{ |
kl=0; |
kl=0; |
for (k=1; k<=cptcoveff; k++){ /* For each combination of covariate */ |
for (k=1; k<=cptcoveff; k++){ /* For each combination of covariate */ |
Line 6459 void printinggnuplot(char fileresu[], ch
|
Line 6503 void printinggnuplot(char fileresu[], ch
|
/*6+1+(i-1)+(nlstate+1)*nlstate; 6+1+(1-1) +(2+1)*2=13 */ |
/*6+1+(i-1)+(nlstate+1)*nlstate; 6+1+(1-1) +(2+1)*2=13 */ |
/* '' u 6:(($1==1 && $2==0 && $3==2 && $4==0)? $9/(1.-$15) : 1/0):($5==2000? 3:2) t 'p.1' with line lc variable*/ |
/* '' u 6:(($1==1 && $2==0 && $3==2 && $4==0)? $9/(1.-$15) : 1/0):($5==2000? 3:2) t 'p.1' with line lc variable*/ |
if(k==cptcoveff){ |
if(k==cptcoveff){ |
fprintf(ficgp,"$%d==%d && $%d==%d)? $%d : 1/0) t 'Backward prevalence in state %d' ",kl+1, Tvaraff[k],kl+1+1,nbcode[Tvaraff[k]][lv], \ |
fprintf(ficgp,"$%d==%d && $%d==%d)? $%d : 1/0) t 'Backward prevalence in state %d' w l lt 3",kl+1, Tvaraff[k],kl+1+1,nbcode[Tvaraff[k]][lv], \ |
2+cptcoveff*2+(cpt-1), cpt ); /* 4 or 6 ?*/ |
2+cptcoveff*2+(cpt-1), cpt ); /* 4 or 6 ?*/ |
}else{ |
}else{ |
fprintf(ficgp,"$%d==%d && $%d==%d && ",kl+1, Tvaraff[k],kl+1+1,nbcode[Tvaraff[k]][lv]); |
fprintf(ficgp,"$%d==%d && $%d==%d && ",kl+1, Tvaraff[k],kl+1+1,nbcode[Tvaraff[k]][lv]); |
Line 8827 Dummy[k] 0=dummy (0 1), 1 quantitative (
|
Line 8871 Dummy[k] 0=dummy (0 1), 1 quantitative (
|
} |
} |
|
|
int calandcheckages(int imx, int maxwav, double *agemin, double *agemax, int *nberr, int *nbwarn ) |
int calandcheckages(int imx, int maxwav, double *agemin, double *agemax, int *nberr, int *nbwarn ) |
{ |
{/* Check ages at death */ |
int i, m; |
int i, m; |
int firstone=0; |
int firstone=0; |
|
|
Line 9871 int main(int argc, char *argv[])
|
Line 9915 int main(int argc, char *argv[])
|
delti=delti3[1][1]; |
delti=delti3[1][1]; |
/*delti=vector(1,npar); *//* Scale of each paramater (output from hesscov)*/ |
/*delti=vector(1,npar); *//* Scale of each paramater (output from hesscov)*/ |
if(mle==-1){ /* Print a wizard for help writing covariance matrix */ |
if(mle==-1){ /* Print a wizard for help writing covariance matrix */ |
|
/* We could also provide initial parameters values giving by simple logistic regression |
|
* only one way, that is without matrix product. We will have nlstate maximizations */ |
|
/* for(i=1;i<nlstate;i++){ */ |
|
/* /\*reducing xi for 1 to npar to 1 to ncovmodel; *\/ */ |
|
/* mlikeli(ficres,p, ncovmodel, ncovmodel, nlstate, ftol, funcnoprod); */ |
|
/* } */ |
prwizard(ncovmodel, nlstate, ndeath, model, ficparo); |
prwizard(ncovmodel, nlstate, ndeath, model, ficparo); |
printf(" You chose mle=-1, look at file %s for a template of covariance matrix \n",filereso); |
printf(" You chose mle=-1, look at file %s for a template of covariance matrix \n",filereso); |
fprintf(ficlog," You chose mle=-1, look at file %s for a template of covariance matrix \n",filereso); |
fprintf(ficlog," You chose mle=-1, look at file %s for a template of covariance matrix \n",filereso); |
Line 9879 int main(int argc, char *argv[])
|
Line 9929 int main(int argc, char *argv[])
|
fclose (ficlog); |
fclose (ficlog); |
goto end; |
goto end; |
exit(0); |
exit(0); |
|
} else if(mle==-2) { /* Guessing from means */ |
|
prwizard(ncovmodel, nlstate, ndeath, model, ficparo); |
|
printf(" You chose mle=-2, look at file %s for a template of covariance matrix \n",filereso); |
|
fprintf(ficlog," You chose mle=-2, look at file %s for a template of covariance matrix \n",filereso); |
|
|
} else if(mle==-5) { /* Main Wizard */ |
} else if(mle==-5) { /* Main Wizard */ |
prwizard(ncovmodel, nlstate, ndeath, model, ficparo); |
prwizard(ncovmodel, nlstate, ndeath, model, ficparo); |
printf(" You chose mle=-3, look at file %s for a template of covariance matrix \n",filereso); |
printf(" You chose mle=-3, look at file %s for a template of covariance matrix \n",filereso); |
Line 10202 Please run with mle=-1 to get a correct
|
Line 10257 Please run with mle=-1 to get a correct
|
*/ |
*/ |
|
|
concatwav(wav, dh, bh, mw, s, agedc, agev, firstpass, lastpass, imx, nlstate, stepm); |
concatwav(wav, dh, bh, mw, s, agedc, agev, firstpass, lastpass, imx, nlstate, stepm); |
/* */ |
/* Concatenates waves */ |
|
|
free_vector(moisdc,1,n); |
free_vector(moisdc,1,n); |
free_vector(andc,1,n); |
free_vector(andc,1,n); |
Line 10405 Interval (in months) between two waves:
|
Line 10460 Interval (in months) between two waves:
|
/* For mortality only */ |
/* For mortality only */ |
if (mle==-3){ |
if (mle==-3){ |
ximort=matrix(1,NDIM,1,NDIM); |
ximort=matrix(1,NDIM,1,NDIM); |
for(i=1;i<=NDIM;i++) |
for(i=1;i<=NDIM;i++) |
for(j=1;j<=NDIM;j++) |
for(j=1;j<=NDIM;j++) |
ximort[i][j]=0.; |
ximort[i][j]=0.; |
/* ximort=gsl_matrix_alloc(1,NDIM,1,NDIM); */ |
/* ximort=gsl_matrix_alloc(1,NDIM,1,NDIM); */ |
cens=ivector(1,n); |
cens=ivector(1,n); |
ageexmed=vector(1,n); |
ageexmed=vector(1,n); |
Line 10643 Please run with mle=-1 to get a correct
|
Line 10698 Please run with mle=-1 to get a correct
|
printf("\n"); |
printf("\n"); |
if(mle>=1){ /* Could be 1 or 2, Real Maximization */ |
if(mle>=1){ /* Could be 1 or 2, Real Maximization */ |
/* mlikeli uses func not funcone */ |
/* mlikeli uses func not funcone */ |
|
/* for(i=1;i<nlstate;i++){ */ |
|
/* /\*reducing xi for 1 to npar to 1 to ncovmodel; *\/ */ |
|
/* mlikeli(ficres,p, ncovmodel, ncovmodel, nlstate, ftol, funcnoprod); */ |
|
/* } */ |
mlikeli(ficres,p, npar, ncovmodel, nlstate, ftol, func); |
mlikeli(ficres,p, npar, ncovmodel, nlstate, ftol, func); |
} |
} |
if(mle==0) {/* No optimization, will print the likelihoods for the datafile */ |
if(mle==0) {/* No optimization, will print the likelihoods for the datafile */ |