version 1.251, 2016/09/15 15:01:13
|
version 1.256, 2017/03/27 05:50:23
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.256 2017/03/27 05:50:23 brouard |
|
Summary: Temporary |
|
|
|
Revision 1.255 2017/03/08 16:02:28 brouard |
|
Summary: IMaCh version 0.99r10 bugs in gnuplot fixed |
|
|
|
Revision 1.254 2017/03/08 07:13:00 brouard |
|
Summary: Fixing data parameter line |
|
|
|
Revision 1.253 2016/12/15 11:59:41 brouard |
|
Summary: 0.99 in progress |
|
|
|
Revision 1.252 2016/09/15 21:15:37 brouard |
|
*** empty log message *** |
|
|
Revision 1.251 2016/09/15 15:01:13 brouard |
Revision 1.251 2016/09/15 15:01:13 brouard |
Summary: not working |
Summary: not working |
|
|
Line 128
|
Line 143
|
Author: Nicolas Brouard |
Author: Nicolas Brouard |
|
|
Revision 1.210 2015/11/18 17:41:20 brouard |
Revision 1.210 2015/11/18 17:41:20 brouard |
Summary: Start working on projected prevalences |
Summary: Start working on projected prevalences Revision 1.209 2015/11/17 22:12:03 brouard |
|
|
Revision 1.209 2015/11/17 22:12:03 brouard |
|
Summary: Adding ftolpl parameter |
Summary: Adding ftolpl parameter |
Author: N Brouard |
Author: N Brouard |
|
|
Line 2393 void powell(double p[], double **xi, int
|
Line 2406 void powell(double p[], double **xi, int
|
flatd++; |
flatd++; |
} |
} |
if(flatd >0){ |
if(flatd >0){ |
printf("%d flat directions\n",flatd); |
printf("%d flat directions: ",flatd); |
fprintf(ficlog,"%d flat directions\n",flatd); |
fprintf(ficlog,"%d flat directions :",flatd); |
for (j=1;j<=n;j++) { |
for (j=1;j<=n;j++) { |
if(flatdir[j]>0){ |
if(flatdir[j]>0){ |
printf("%d ",j); |
printf("%d ",j); |
Line 4122 void ludcmp(double **a, int n, int *indx
|
Line 4135 void ludcmp(double **a, int n, int *indx
|
big=0.0; |
big=0.0; |
for (j=1;j<=n;j++) |
for (j=1;j<=n;j++) |
if ((temp=fabs(a[i][j])) > big) big=temp; |
if ((temp=fabs(a[i][j])) > big) big=temp; |
if (big == 0.0) nrerror("Singular matrix in routine ludcmp"); |
if (big == 0.0){ |
|
printf(" Singular Hessian matrix at row %d:\n",i); |
|
for (j=1;j<=n;j++) { |
|
printf(" a[%d][%d]=%f,",i,j,a[i][j]); |
|
fprintf(ficlog," a[%d][%d]=%f,",i,j,a[i][j]); |
|
} |
|
fflush(ficlog); |
|
fclose(ficlog); |
|
nrerror("Singular matrix in routine ludcmp"); |
|
} |
vv[i]=1.0/big; |
vv[i]=1.0/big; |
} |
} |
for (j=1;j<=n;j++) { |
for (j=1;j<=n;j++) { |
Line 4188 void pstamp(FILE *fichier)
|
Line 4210 void pstamp(FILE *fichier)
|
fprintf(fichier,"# %s.%s\n#IMaCh version %s, %s\n#%s\n# %s", optionfilefiname,optionfilext,version,copyright, fullversion, strstart); |
fprintf(fichier,"# %s.%s\n#IMaCh version %s, %s\n#%s\n# %s", optionfilefiname,optionfilext,version,copyright, fullversion, strstart); |
} |
} |
|
|
|
int linreg(int ifi, int ila, int *no, const double x[], const double y[], double* a, double* b, double* r, double* sa, double * sb) { |
|
|
|
/* y=a+bx regression */ |
|
double sumx = 0.0; /* sum of x */ |
|
double sumx2 = 0.0; /* sum of x**2 */ |
|
double sumxy = 0.0; /* sum of x * y */ |
|
double sumy = 0.0; /* sum of y */ |
|
double sumy2 = 0.0; /* sum of y**2 */ |
|
double sume2; /* sum of square or residuals */ |
|
double yhat; |
|
|
|
double denom=0; |
|
int i; |
|
int ne=*no; |
|
|
|
for ( i=ifi, ne=0;i<=ila;i++) { |
|
if(!isfinite(x[i]) || !isfinite(y[i])){ |
|
/* printf(" x[%d]=%f, y[%d]=%f\n",i,x[i],i,y[i]); */ |
|
continue; |
|
} |
|
ne=ne+1; |
|
sumx += x[i]; |
|
sumx2 += x[i]*x[i]; |
|
sumxy += x[i] * y[i]; |
|
sumy += y[i]; |
|
sumy2 += y[i]*y[i]; |
|
denom = (ne * sumx2 - sumx*sumx); |
|
/* printf("ne=%d, i=%d,x[%d]=%f, y[%d]=%f sumx=%f, sumx2=%f, sumxy=%f, sumy=%f, sumy2=%f, denom=%f\n",ne,i,i,x[i],i,y[i], sumx, sumx2,sumxy, sumy, sumy2,denom); */ |
|
} |
|
|
|
denom = (ne * sumx2 - sumx*sumx); |
|
if (denom == 0) { |
|
// vertical, slope m is infinity |
|
*b = INFINITY; |
|
*a = 0; |
|
if (r) *r = 0; |
|
return 1; |
|
} |
|
|
|
*b = (ne * sumxy - sumx * sumy) / denom; |
|
*a = (sumy * sumx2 - sumx * sumxy) / denom; |
|
if (r!=NULL) { |
|
*r = (sumxy - sumx * sumy / ne) / /* compute correlation coeff */ |
|
sqrt((sumx2 - sumx*sumx/ne) * |
|
(sumy2 - sumy*sumy/ne)); |
|
} |
|
*no=ne; |
|
for ( i=ifi, ne=0;i<=ila;i++) { |
|
if(!isfinite(x[i]) || !isfinite(y[i])){ |
|
/* printf(" x[%d]=%f, y[%d]=%f\n",i,x[i],i,y[i]); */ |
|
continue; |
|
} |
|
ne=ne+1; |
|
yhat = y[i] - *a -*b* x[i]; |
|
sume2 += yhat * yhat ; |
|
|
|
denom = (ne * sumx2 - sumx*sumx); |
|
/* printf("ne=%d, i=%d,x[%d]=%f, y[%d]=%f sumx=%f, sumx2=%f, sumxy=%f, sumy=%f, sumy2=%f, denom=%f\n",ne,i,i,x[i],i,y[i], sumx, sumx2,sumxy, sumy, sumy2,denom); */ |
|
} |
|
*sb = sqrt(sume2/(ne-2)/(sumx2 - sumx * sumx /ne)); |
|
*sa= *sb * sqrt(sumx2/ne); |
|
|
|
return 0; |
|
} |
|
|
/************ Frequencies ********************/ |
/************ Frequencies ********************/ |
void freqsummary(char fileres[], double p[], double pstart[], int iagemin, int iagemax, int **s, double **agev, int nlstate, int imx, \ |
void freqsummary(char fileres[], double p[], double pstart[], int iagemin, int iagemax, int **s, double **agev, int nlstate, int imx, \ |
int *Tvaraff, int *invalidvarcomb, int **nbcode, int *ncodemax,double **mint,double **anint, char strstart[], \ |
int *Tvaraff, int *invalidvarcomb, int **nbcode, int *ncodemax,double **mint,double **anint, char strstart[], \ |
int firstpass, int lastpass, int stepm, int weightopt, char model[]) |
int firstpass, int lastpass, int stepm, int weightopt, char model[]) |
{ /* Some frequencies as well as proposing some starting values */ |
{ /* Some frequencies as well as proposing some starting values */ |
|
|
int i, m, jk, j1, bool, z1,j, k, iv, jj=0; |
int i, m, jk, j1, bool, z1,j, nj, nl, k, iv, jj=0; |
int iind=0, iage=0; |
int iind=0, iage=0; |
int mi; /* Effective wave */ |
int mi; /* Effective wave */ |
int first; |
int first; |
double ***freq; /* Frequencies */ |
double ***freq; /* Frequencies */ |
|
double *x, *y, a,b,r, sa, sb; /* for regression, y=b+m*x and r is the correlation coefficient */ |
|
int no; |
double *meanq; |
double *meanq; |
double **meanqt; |
double **meanqt; |
double *pp, **prop, *posprop, *pospropt; |
double *pp, **prop, *posprop, *pospropt; |
Line 4251 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4340 Title=%s <br>Datafile=%s Firstpass=%d La
|
} |
} |
fprintf(ficresphtmfr,"Current page is file <a href=\"%s\">%s</a><br>\n\n<h4>Frequencies of all effective transitions of the model, by age at begin of transition, and covariate value at the begin of transition (if the covariate is a varying covariate) </h4>Unknown status is -1<br/>\n",fileresphtmfr, fileresphtmfr); |
fprintf(ficresphtmfr,"Current page is file <a href=\"%s\">%s</a><br>\n\n<h4>Frequencies of all effective transitions of the model, by age at begin of transition, and covariate value at the begin of transition (if the covariate is a varying covariate) </h4>Unknown status is -1<br/>\n",fileresphtmfr, fileresphtmfr); |
|
|
|
y= vector(iagemin-AGEMARGE,iagemax+4+AGEMARGE); |
|
x= vector(iagemin-AGEMARGE,iagemax+4+AGEMARGE); |
freq= ma3x(-5,nlstate+ndeath,-5,nlstate+ndeath,iagemin-AGEMARGE,iagemax+4+AGEMARGE); |
freq= ma3x(-5,nlstate+ndeath,-5,nlstate+ndeath,iagemin-AGEMARGE,iagemax+4+AGEMARGE); |
j1=0; |
j1=0; |
|
|
Line 4268 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4359 Title=%s <br>Datafile=%s Firstpass=%d La
|
dateintsum=0; |
dateintsum=0; |
k2cpt=0; |
k2cpt=0; |
|
|
for (j = 0; j <= cptcoveff; j+=cptcoveff){ /* j= 0 constant model */ |
if(cptcoveff == 0 ) |
|
nl=1; /* Constant model only */ |
|
else |
|
nl=2; |
|
for (nj = 1; nj <= nl; nj++){ /* nj= 1 constant model, nl number of loops. */ |
|
if(nj==1) |
|
j=0; /* First pass for the constant */ |
|
else |
|
j=cptcoveff; /* Other passes for the covariate values */ |
first=1; |
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.; |
Line 4514 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4613 Title=%s <br>Datafile=%s Firstpass=%d La
|
if(first==1){ |
if(first==1){ |
printf(" %d%d=%.0f",jk,m,freq[jk][m][iage]); |
printf(" %d%d=%.0f",jk,m,freq[jk][m][iage]); |
} |
} |
|
/* printf(" %d%d=%.0f",jk,m,freq[jk][m][iage]); */ |
fprintf(ficlog," %d%d=%.0f",jk,m,freq[jk][m][iage]); |
fprintf(ficlog," %d%d=%.0f",jk,m,freq[jk][m][iage]); |
} |
} |
if(jk!=0 && m!=0) |
if(jk!=0 && m!=0) |
Line 4560 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4660 Title=%s <br>Datafile=%s Firstpass=%d La
|
for(i=1,jk=1; i <=nlstate; i++){ |
for(i=1,jk=1; i <=nlstate; i++){ |
for(k=1; k <=(nlstate+ndeath); k++){ |
for(k=1; k <=(nlstate+ndeath); k++){ |
if (k != i) { |
if (k != i) { |
printf("%d%d ",i,k); |
|
fprintf(ficlog,"%d%d ",i,k); |
|
for(jj=1; jj <=ncovmodel; jj++){ /* For counting jk */ |
for(jj=1; jj <=ncovmodel; jj++){ /* For counting jk */ |
if(jj==1){ /* Constant case */ |
if(jj==1){ /* Constant case (in fact cste + age) */ |
if(j1==1){ /* All dummy covariates to zero */ |
if(j1==1){ /* All dummy covariates to zero */ |
freq[i][k][iagemax+4]=freq[i][k][iagemax+3]; /* Stores case 0 0 0 */ |
freq[i][k][iagemax+4]=freq[i][k][iagemax+3]; /* Stores case 0 0 0 */ |
freq[i][i][iagemax+4]=freq[i][i][iagemax+3]; /* Stores case 0 0 0 */ |
freq[i][i][iagemax+4]=freq[i][i][iagemax+3]; /* Stores case 0 0 0 */ |
|
printf("%d%d ",i,k); |
|
fprintf(ficlog,"%d%d ",i,k); |
|
printf("%12.7f ln(%.0f/%.0f)= %f, OR=%f sd=%f \n",p[jk],freq[i][k][iagemax+3],freq[i][i][iagemax+3], log(freq[i][k][iagemax+3]/freq[i][i][iagemax+3]),freq[i][k][iagemax+3]/freq[i][i][iagemax+3], sqrt(1/freq[i][k][iagemax+3]+1/freq[i][i][iagemax+3])); |
|
fprintf(ficlog,"%12.7f ln(%.0f/%.0f)= %12.7f \n",p[jk],freq[i][k][iagemax+3],freq[i][i][iagemax+3], log(freq[i][k][iagemax+3]/freq[i][i][iagemax+3])); |
|
pstart[jk]= log(freq[i][k][iagemax+3]/freq[i][i][iagemax+3]); |
|
} |
|
}else if((j1==1) && (jj==2 || nagesqr==1)){ /* age or age*age parameter without covariate V4*age (to be done later) */ |
|
for(iage=iagemin; iage <= iagemax+3; iage++){ |
|
x[iage]= (double)iage; |
|
y[iage]= log(freq[i][k][iage]/freq[i][i][iage]); |
|
/* printf("i=%d, k=%d, jk=%d, j1=%d, jj=%d, y[%d]=%f\n",i,k,jk,j1,jj, iage, y[iage]); */ |
} |
} |
printf("%12.7f ln(%.0f/%.0f)= %f, OR=%f sd=%f \n",p[jk],freq[i][k][iagemax+3],freq[i][i][iagemax+3], log(freq[i][k][iagemax+3]/freq[i][i][iagemax+3]),freq[i][k][iagemax+3]/freq[i][i][iagemax+3], sqrt(1/freq[i][k][iagemax+3]+1/freq[i][i][iagemax+3])); |
linreg(iagemin,iagemax,&no,x,y,&a,&b,&r, &sa, &sb ); /* y= a+b*x with standard errors */ |
fprintf(ficlog,"%12.7f ln(%.0f/%.0f)= %12.7f \n",p[jk],freq[i][k][iagemax+3],freq[i][i][iagemax+3], log(freq[i][k][iagemax+3]/freq[i][i][iagemax+3])); |
pstart[jk]=b; |
pstart[jk]= log(freq[i][k][iagemax+3]/freq[i][i][iagemax+3]); |
pstart[jk-1]=a; |
}else if( (log(j1-1)/log(2)+1 == jj -2 -nagesqr) && Dummy[jj-2-nagesqr]==0){ /* We want only if the position, jj, in model corresponds to unique covariate equal to 1 in j1 combination */ |
}else if( j1!=1 && (j1==2 || (log(j1-1.)/log(2.)-(int)(log(j1-1.)/log(2.))) <0.010) && ( TvarsDind[(int)(log(j1-1.)/log(2.))+1]+2+nagesqr == jj) && Dummy[jj-2-nagesqr]==0){ /* We want only if the position, jj, in model corresponds to unique covariate equal to 1 in j1 combination */ |
|
printf("j1=%d, jj=%d, (int)(log(j1-1.)/log(2.))+1=%d, TvarsDind[(int)(log(j1-1.)/log(2.))+1]=%d\n",j1, jj,(int)(log(j1-1.)/log(2.))+1,TvarsDind[(int)(log(j1-1.)/log(2.))+1]); |
|
printf("j1=%d, jj=%d, (log(j1-1.)/log(2.))+1=%f, TvarsDind[(int)(log(j1-1.)/log(2.))+1]=%d\n",j1, jj,(log(j1-1.)/log(2.))+1,TvarsDind[(int)(log(j1-1.)/log(2.))+1]); |
pstart[jk]= log((freq[i][k][iagemax+3]/freq[i][i][iagemax+3])/(freq[i][k][iagemax+4]/freq[i][i][iagemax+4])); |
pstart[jk]= log((freq[i][k][iagemax+3]/freq[i][i][iagemax+3])/(freq[i][k][iagemax+4]/freq[i][i][iagemax+4])); |
|
printf("%d%d ",i,k); |
|
fprintf(ficlog,"%d%d ",i,k); |
printf("jk=%d,i=%d,k=%d,p[%d]=%12.7f ln((%.0f/%.0f)/(%.0f/%.0f))= %f, OR=%f sd=%f \n",jk,i,k,jk,p[jk],freq[i][k][iagemax+3],freq[i][i][iagemax+3],freq[i][k][iagemax+4],freq[i][i][iagemax+4], log((freq[i][k][iagemax+3]/freq[i][i][iagemax+3])/(freq[i][k][iagemax+4]/freq[i][i][iagemax+4])),(freq[i][k][iagemax+3]/freq[i][i][iagemax+3])/(freq[i][k][iagemax+4]/freq[i][i][iagemax+4]), sqrt(1/freq[i][k][iagemax+3]+1/freq[i][i][iagemax+3]+1/freq[i][k][iagemax+4]+1/freq[i][i][iagemax+4])); |
printf("jk=%d,i=%d,k=%d,p[%d]=%12.7f ln((%.0f/%.0f)/(%.0f/%.0f))= %f, OR=%f sd=%f \n",jk,i,k,jk,p[jk],freq[i][k][iagemax+3],freq[i][i][iagemax+3],freq[i][k][iagemax+4],freq[i][i][iagemax+4], log((freq[i][k][iagemax+3]/freq[i][i][iagemax+3])/(freq[i][k][iagemax+4]/freq[i][i][iagemax+4])),(freq[i][k][iagemax+3]/freq[i][i][iagemax+3])/(freq[i][k][iagemax+4]/freq[i][i][iagemax+4]), sqrt(1/freq[i][k][iagemax+3]+1/freq[i][i][iagemax+3]+1/freq[i][k][iagemax+4]+1/freq[i][i][iagemax+4])); |
}else if(jj==2 || nagesqr==1){ /* age or age*age parameter */ |
|
; |
|
}else{ /* Other cases, like quantitative fixed or varying covariates */ |
}else{ /* Other cases, like quantitative fixed or varying covariates */ |
; |
; |
} |
} |
Line 4583 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4694 Title=%s <br>Datafile=%s Firstpass=%d La
|
/* fprintf(ficlog,"%12.7f )", param[i][jj][k]); */ |
/* fprintf(ficlog,"%12.7f )", param[i][jj][k]); */ |
jk++; |
jk++; |
} /* end jj */ |
} /* end jj */ |
printf("\n"); |
|
fprintf(ficlog,"\n"); |
|
} /* end k!= i */ |
} /* end k!= i */ |
} /* end k */ |
} /* end k */ |
} /* end i, jk */ |
} /* end i, jk */ |
Line 4599 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4708 Title=%s <br>Datafile=%s Firstpass=%d La
|
printf("%d%d ",i,k); |
printf("%d%d ",i,k); |
fprintf(ficlog,"%d%d ",i,k); |
fprintf(ficlog,"%d%d ",i,k); |
for(jj=1; jj <=ncovmodel; jj++){ |
for(jj=1; jj <=ncovmodel; jj++){ |
if(jj==1){ |
pstart[jk]=p[jk]; /* Setting pstart to p values by default */ |
|
if(jj==1){ /* Age has to be done */ |
|
pstart[jk]= log(freq[i][k][iagemax+3]/freq[i][i][iagemax+3]); |
printf("%12.7f ln(%.0f/%.0f)= %12.7f ",p[jk],freq[i][k][iagemax+3],freq[i][i][iagemax+3], log(freq[i][k][iagemax+3]/freq[i][i][iagemax+3])); |
printf("%12.7f ln(%.0f/%.0f)= %12.7f ",p[jk],freq[i][k][iagemax+3],freq[i][i][iagemax+3], log(freq[i][k][iagemax+3]/freq[i][i][iagemax+3])); |
fprintf(ficlog,"%12.7f ln(%.0f/%.0f)= %12.7f ",p[jk],freq[i][k][iagemax+3],freq[i][i][iagemax+3], log(freq[i][k][iagemax+3]/freq[i][i][iagemax+3])); |
fprintf(ficlog,"%12.7f ln(%.0f/%.0f)= %12.7f ",p[jk],freq[i][k][iagemax+3],freq[i][i][iagemax+3], log(freq[i][k][iagemax+3]/freq[i][i][iagemax+3])); |
} |
} |
Line 4630 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4741 Title=%s <br>Datafile=%s Firstpass=%d La
|
fprintf(ficlog,"\n"); |
fprintf(ficlog,"\n"); |
} /* end j=0 */ |
} /* end j=0 */ |
} /* end j */ |
} /* end j */ |
|
|
|
if(mle == -2){ /* We want to use these values as starting values */ |
|
for(i=1, jk=1; i <=nlstate; i++){ |
|
for(j=1; j <=nlstate+ndeath; j++){ |
|
if(j!=i){ |
|
/*ca[0]= k+'a'-1;ca[1]='\0';*/ |
|
printf("%1d%1d",i,j); |
|
fprintf(ficparo,"%1d%1d",i,j); |
|
for(k=1; k<=ncovmodel;k++){ |
|
/* printf(" %lf",param[i][j][k]); */ |
|
/* fprintf(ficparo," %lf",param[i][j][k]); */ |
|
p[jk]=pstart[jk]; |
|
printf(" %f ",pstart[jk]); |
|
fprintf(ficparo," %f ",pstart[jk]); |
|
jk++; |
|
} |
|
printf("\n"); |
|
fprintf(ficparo,"\n"); |
|
} |
|
} |
|
} |
|
} /* end mle=-2 */ |
dateintmean=dateintsum/k2cpt; |
dateintmean=dateintsum/k2cpt; |
|
|
fclose(ficresp); |
fclose(ficresp); |
Line 4637 Title=%s <br>Datafile=%s Firstpass=%d La
|
Line 4770 Title=%s <br>Datafile=%s Firstpass=%d La
|
fclose(ficresphtmfr); |
fclose(ficresphtmfr); |
free_vector(meanq,1,nqfveff); |
free_vector(meanq,1,nqfveff); |
free_matrix(meanqt,1,lastpass,1,nqtveff); |
free_matrix(meanqt,1,lastpass,1,nqtveff); |
|
free_vector(x, iagemin-AGEMARGE, iagemax+4+AGEMARGE); |
|
free_vector(y, iagemin-AGEMARGE, iagemax+4+AGEMARGE); |
free_ma3x(freq,-5,nlstate+ndeath,-5,nlstate+ndeath, iagemin-AGEMARGE, iagemax+4+AGEMARGE); |
free_ma3x(freq,-5,nlstate+ndeath,-5,nlstate+ndeath, iagemin-AGEMARGE, iagemax+4+AGEMARGE); |
free_vector(pospropt,1,nlstate); |
free_vector(pospropt,1,nlstate); |
free_vector(posprop,1,nlstate); |
free_vector(posprop,1,nlstate); |
Line 6288 void printinghtml(char fileresu[], char
|
Line 6423 void printinghtml(char fileresu[], char
|
|
|
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(k1=1; k1<=m;k1++){ /* For each combination of covariate */ |
for(k1=1; k1<=m;k1++){ /* For each combination of covariate */ |
if(TKresult[nres]!= k1) |
if(m != 1 && TKresult[nres]!= k1) |
continue; |
continue; |
|
|
/* for(i1=1; i1<=ncodemax[k1];i1++){ */ |
/* for(i1=1; i1<=ncodemax[k1];i1++){ */ |
Line 6339 divided by h: <sub>h</sub>P<sub>ij</sub>
|
Line 6474 divided by h: <sub>h</sub>P<sub>ij</sub>
|
} |
} |
/* Period (stable) prevalence in each health state */ |
/* Period (stable) prevalence in each health state */ |
for(cpt=1; cpt<=nlstate;cpt++){ |
for(cpt=1; cpt<=nlstate;cpt++){ |
fprintf(fichtm,"<br>\n- Convergence to period (stable) prevalence in state %d. Or probability to be in state %d being in state (1 to %d) at different ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> \ |
fprintf(fichtm,"<br>\n- Convergence to period (stable) prevalence in state %d. Or probability to be in state %d some years earlier, knowing that we will be in state (1 to %d) at different ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> \ |
<img src=\"%s_%d-%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres); |
<img src=\"%s_%d-%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres,subdirf2(optionfilefiname,"P_"),cpt,k1,nres); |
} |
} |
if(backcast==1){ |
if(backcast==1){ |
/* Period (stable) back prevalence in each health state */ |
/* Period (stable) back prevalence in each health state */ |
for(cpt=1; cpt<=nlstate;cpt++){ |
for(cpt=1; cpt<=nlstate;cpt++){ |
fprintf(fichtm,"<br>\n- Convergence to period (stable) back prevalence in state %d. Or probability to be in state %d being in state (1 to %d) at different ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> \ |
fprintf(fichtm,"<br>\n- Convergence to mixed (stable) back prevalence in state %d. Or probability to be in state %d at a younger age, knowing that we will be in state (1 to %d) at different older ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> \ |
<img src=\"%s_%d-%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres); |
<img src=\"%s_%d-%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres,subdirf2(optionfilefiname,"PB_"),cpt,k1,nres); |
} |
} |
} |
} |
Line 6420 See page 'Matrix of variance-covariance
|
Line 6555 See page 'Matrix of variance-covariance
|
|
|
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(k1=1; k1<=m;k1++){ |
for(k1=1; k1<=m;k1++){ |
if(TKresult[nres]!= k1) |
if(m != 1 && TKresult[nres]!= k1) |
continue; |
continue; |
/* for(i1=1; i1<=ncodemax[k1];i1++){ */ |
/* for(i1=1; i1<=ncodemax[k1];i1++){ */ |
jj1++; |
jj1++; |
Line 6516 void printinggnuplot(char fileresu[], ch
|
Line 6651 void printinggnuplot(char fileresu[], ch
|
for (k1=1; k1<= m ; k1 ++){ /* For each valid combination of covariate */ |
for (k1=1; k1<= m ; k1 ++){ /* For each valid combination of covariate */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
/* plot [100000000000000000000:-100000000000000000000] "mysbiaspar/vplrmysbiaspar.txt to check */ |
/* plot [100000000000000000000:-100000000000000000000] "mysbiaspar/vplrmysbiaspar.txt to check */ |
if(TKresult[nres]!= k1) |
if(m != 1 && 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); */ |
Line 6598 void printinggnuplot(char fileresu[], ch
|
Line 6733 void printinggnuplot(char fileresu[], ch
|
/*2 eme*/ |
/*2 eme*/ |
for (k1=1; k1<= m ; k1 ++){ |
for (k1=1; k1<= m ; k1 ++){ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
if(TKresult[nres]!= k1) |
if(m != 1 && TKresult[nres]!= k1) |
continue; |
continue; |
fprintf(ficgp,"\n# 2nd: Total life expectancy with CI: 't' files "); |
fprintf(ficgp,"\n# 2nd: Total life expectancy with CI: 't' files "); |
for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */ |
for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */ |
Line 6658 void printinggnuplot(char fileresu[], ch
|
Line 6793 void printinggnuplot(char fileresu[], ch
|
/*3eme*/ |
/*3eme*/ |
for (k1=1; k1<= m ; k1 ++){ |
for (k1=1; k1<= m ; k1 ++){ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
if(TKresult[nres]!= k1) |
if(m != 1 && TKresult[nres]!= k1) |
continue; |
continue; |
|
|
for (cpt=1; cpt<= nlstate ; cpt ++) { |
for (cpt=1; cpt<= nlstate ; cpt ++) { |
Line 6707 plot [%.f:%.f] \"%s\" every :::%d::%d u
|
Line 6842 plot [%.f:%.f] \"%s\" every :::%d::%d u
|
/* Survival functions (period) from state i in state j by initial state i */ |
/* Survival functions (period) from state i in state j by initial state i */ |
for (k1=1; k1<=m; k1++){ /* For each covariate and each value */ |
for (k1=1; k1<=m; k1++){ /* For each covariate and each value */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
if(TKresult[nres]!= k1) |
if(m != 1 && TKresult[nres]!= k1) |
continue; |
continue; |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state cpt*/ |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state cpt*/ |
fprintf(ficgp,"\n#\n#\n# Survival functions in state j : 'LIJ_' files, cov=%d state=%d",k1, cpt); |
fprintf(ficgp,"\n#\n#\n# Survival functions in state j : 'LIJ_' files, cov=%d state=%d",k1, cpt); |
Line 6753 set ter svg size 640, 480\nunset log y\n
|
Line 6888 set ter svg size 640, 480\nunset log y\n
|
/* Survival functions (period) from state i in state j by final state j */ |
/* Survival functions (period) from state i in state j by final state j */ |
for (k1=1; k1<= m ; k1++){ /* For each covariate combination if any */ |
for (k1=1; k1<= m ; k1++){ /* For each covariate combination if any */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
if(TKresult[nres]!= k1) |
if(m != 1 && TKresult[nres]!= k1) |
continue; |
continue; |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each inital state */ |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each inital state */ |
fprintf(ficgp,"\n#\n#\n# Survival functions in state j and all livestates from state i by final state j: 'lij' files, cov=%d state=%d",k1, cpt); |
fprintf(ficgp,"\n#\n#\n# Survival functions in state j and all livestates from state i by final state j: 'lij' files, cov=%d state=%d",k1, cpt); |
Line 6807 set ter svg size 640, 480\nunset log y\n
|
Line 6942 set ter svg size 640, 480\nunset log y\n
|
/* CV preval stable (period) for each covariate */ |
/* CV preval stable (period) for each covariate */ |
for (k1=1; k1<= m ; k1 ++) /* For each covariate combination if any */ |
for (k1=1; k1<= m ; k1 ++) /* For each covariate combination if any */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
if(TKresult[nres]!= k1) |
if(m != 1 && TKresult[nres]!= k1) |
continue; |
continue; |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */ |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state of arrival */ |
|
|
fprintf(ficgp,"\n#\n#\n#CV preval stable (period): 'pij' files, covariatecombination#=%d state=%d",k1, cpt); |
fprintf(ficgp,"\n#\n#\n#CV preval stable (period): 'pij' files, covariatecombination#=%d state=%d",k1, cpt); |
for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */ |
for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */ |
Line 6833 set ter svg size 640, 480\nunset log y\n
|
Line 6968 set ter svg size 640, 480\nunset log y\n
|
fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\ |
fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\ |
set ter svg size 640, 480\nunset log y\nplot [%.f:%.f] ", ageminpar, agemaxpar); |
set ter svg size 640, 480\nunset log y\nplot [%.f:%.f] ", ageminpar, agemaxpar); |
k=3; /* Offset */ |
k=3; /* Offset */ |
for (i=1; i<= nlstate ; i ++){ |
for (i=1; i<= nlstate ; i ++){ /* State of origin */ |
if(i==1) |
if(i==1) |
fprintf(ficgp,"\"%s\"",subdirf2(fileresu,"PIJ_")); |
fprintf(ficgp,"\"%s\"",subdirf2(fileresu,"PIJ_")); |
else |
else |
fprintf(ficgp,", '' "); |
fprintf(ficgp,", '' "); |
l=(nlstate+ndeath)*(i-1)+1; |
l=(nlstate+ndeath)*(i-1)+1; /* 1, 1+ nlstate+ndeath, 1+2*(nlstate+ndeath) */ |
fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l); |
fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l); |
for (j=2; j<= nlstate ; j ++) |
for (j=2; j<= nlstate ; j ++) |
fprintf(ficgp,"+$%d",k+l+j-1); |
fprintf(ficgp,"+$%d",k+l+j-1); |
Line 6854 set ter svg size 640, 480\nunset log y\n
|
Line 6989 set ter svg size 640, 480\nunset log y\n
|
/* CV back preval stable (period) for each covariate */ |
/* CV back preval stable (period) for each covariate */ |
for (k1=1; k1<= m ; k1 ++) /* For each covariate combination if any */ |
for (k1=1; k1<= m ; k1 ++) /* For each covariate combination if any */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
if(TKresult[nres]!= k1) |
if(m != 1 && TKresult[nres]!= k1) |
continue; |
continue; |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */ |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life ending state */ |
fprintf(ficgp,"\n#\n#\n#CV Back preval stable (period): 'pij' files, covariatecombination#=%d state=%d",k1, cpt); |
fprintf(ficgp,"\n#\n#\n#CV Back preval stable (period): 'pijb' files, covariatecombination#=%d state=%d",k1, cpt); |
for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */ |
for (k=1; k<=cptcoveff; k++){ /* For each covariate and each value */ |
lv= decodtabm(k1,k,cptcoveff); /* Should be the covariate number corresponding to k1 combination */ |
lv= decodtabm(k1,k,cptcoveff); /* Should be the covariate number corresponding to k1 combination */ |
/* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */ |
/* decodtabm(1,1,4) = 1 because h=1 k= (1) 1 1 1 */ |
Line 6879 set ter svg size 640, 480\nunset log y\n
|
Line 7014 set ter svg size 640, 480\nunset log y\n
|
fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\ |
fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\ |
set ter svg size 640, 480\nunset log y\nplot [%.f:%.f] ", ageminpar, agemaxpar); |
set ter svg size 640, 480\nunset log y\nplot [%.f:%.f] ", ageminpar, agemaxpar); |
k=3; /* Offset */ |
k=3; /* Offset */ |
for (i=1; i<= nlstate ; i ++){ |
for (i=1; i<= nlstate ; i ++){ /* State of origin */ |
if(i==1) |
if(i==1) |
fprintf(ficgp,"\"%s\"",subdirf2(fileresu,"PIJB_")); |
fprintf(ficgp,"\"%s\"",subdirf2(fileresu,"PIJB_")); |
else |
else |
fprintf(ficgp,", '' "); |
fprintf(ficgp,", '' "); |
/* l=(nlstate+ndeath)*(i-1)+1; */ |
/* l=(nlstate+ndeath)*(i-1)+1; */ |
l=(nlstate+ndeath)*(cpt-1)+1; |
l=(nlstate+ndeath)*(cpt-1)+1; /* fixed for i; cpt=1 1, cpt=2 1+ nlstate+ndeath, 1+2*(nlstate+ndeath) */ |
/* fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l); /\* a vérifier *\/ */ |
/* fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l); /\* a vérifier *\/ */ |
/* fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l+(cpt-1)+i-1); /\* a vérifier *\/ */ |
/* fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l+(cpt-1)+i-1); /\* a vérifier *\/ */ |
fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d",k1,k+l+(cpt-1)+i-1); /* a vérifier */ |
fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d",k1,k+l+i-1); /* To be verified */ |
/* for (j=2; j<= nlstate ; j ++) */ |
/* for (j=2; j<= nlstate ; j ++) */ |
/* fprintf(ficgp,"+$%d",k+l+j-1); */ |
/* fprintf(ficgp,"+$%d",k+l+j-1); */ |
/* /\* fprintf(ficgp,"+$%d",k+l+j-1); *\/ */ |
/* /\* fprintf(ficgp,"+$%d",k+l+j-1); *\/ */ |
Line 6905 set ter svg size 640, 480\nunset log y\n
|
Line 7040 set ter svg size 640, 480\nunset log y\n
|
|
|
for (k1=1; k1<= m ; k1 ++) /* For each covariate combination if any */ |
for (k1=1; k1<= m ; k1 ++) /* For each covariate combination if any */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
if(TKresult[nres]!= k1) |
if(m != 1 && TKresult[nres]!= k1) |
continue; |
continue; |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */ |
for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */ |
fprintf(ficgp,"\n#\n#\n#Projection of prevalence to stable (period): 'PROJ_' files, covariatecombination#=%d state=%d",k1, cpt); |
fprintf(ficgp,"\n#\n#\n#Projection of prevalence to stable (period): 'PROJ_' files, covariatecombination#=%d state=%d",k1, cpt); |
Line 7036 set ter svg size 640, 480\nunset log y\n
|
Line 7171 set ter svg size 640, 480\nunset log y\n
|
fprintf(ficgp,"# jk=1 to 2^%d=%d\n",cptcoveff,m);/* to be checked */ |
fprintf(ficgp,"# jk=1 to 2^%d=%d\n",cptcoveff,m);/* to be checked */ |
for(jk=1; jk <=m; jk++) /* For each combination of covariate */ |
for(jk=1; jk <=m; jk++) /* For each combination of covariate */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
if(TKresult[nres]!= jk) |
if(m != 1 && TKresult[nres]!= jk) |
continue; |
continue; |
fprintf(ficgp,"# Combination of dummy jk=%d and ",jk); |
fprintf(ficgp,"# Combination of dummy jk=%d and ",jk); |
for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */ |
for (k4=1; k4<= nsq; k4++){ /* For each selected (single) quantitative value */ |
Line 7398 set ter svg size 640, 480\nunset log y\n
|
Line 7533 set ter svg size 640, 480\nunset log y\n
|
/* if (h==(int)(YEARM*yearp)){ */ |
/* if (h==(int)(YEARM*yearp)){ */ |
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(k=1; k<=i1;k++){ |
for(k=1; k<=i1;k++){ |
if(TKresult[nres]!= k) |
if(i1 != 1 && TKresult[nres]!= k) |
continue; |
continue; |
if(invalidvarcomb[k]){ |
if(invalidvarcomb[k]){ |
printf("\nCombination (%d) projection ignored because no cases \n",k); |
printf("\nCombination (%d) projection ignored because no cases \n",k); |
Line 8349 int decoderesult ( char resultline[], in
|
Line 8484 int decoderesult ( char resultline[], in
|
if (strlen(resultsav) >1){ |
if (strlen(resultsav) >1){ |
j=nbocc(resultsav,'='); /**< j=Number of covariate values'=' */ |
j=nbocc(resultsav,'='); /**< j=Number of covariate values'=' */ |
} |
} |
|
if(j == 0){ /* Resultline but no = */ |
|
TKresult[nres]=0; /* Combination for the nresult and the model */ |
|
return (0); |
|
} |
|
|
if( j != cptcovs ){ /* Be careful if a variable is in a product but not single */ |
if( j != cptcovs ){ /* Be careful if a variable is in a product but not single */ |
printf("ERROR: the number of variable in the resultline, %d, differs from the number of variable used in the model line, %d.\n",j, cptcovs); |
printf("ERROR: the number of variable in the resultline, %d, differs from the number of variable used in the model line, %d.\n",j, cptcovs); |
fprintf(ficlog,"ERROR: the number of variable in the resultline, %d, differs from the number of variable used in the model line, %d.\n",j, cptcovs); |
fprintf(ficlog,"ERROR: the number of variable in the resultline, %d, differs from the number of variable used in the model line, %d.\n",j, cptcovs); |
Line 9285 int prevalence_limit(double *p, double *
|
Line 9425 int prevalence_limit(double *p, double *
|
|
|
for(k=1; k<=i1;k++){ /* For each combination k of dummy covariates in the model */ |
for(k=1; k<=i1;k++){ /* For each combination k of dummy covariates in the model */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
if(TKresult[nres]!= k) |
if(i1 != 1 && TKresult[nres]!= k) |
continue; |
continue; |
|
|
/* for(cptcov=1,k=0;cptcov<=i1;cptcov++){ */ |
/* for(cptcov=1,k=0;cptcov<=i1;cptcov++){ */ |
Line 9382 int back_prevalence_limit(double *p, dou
|
Line 9522 int back_prevalence_limit(double *p, dou
|
|
|
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(k=1; k<=i1;k++){ /* For any combination of dummy covariates, fixed and varying */ |
for(k=1; k<=i1;k++){ /* For any combination of dummy covariates, fixed and varying */ |
if(TKresult[nres]!= k) |
if(i1 != 1 && TKresult[nres]!= k) |
continue; |
continue; |
//printf("cptcov=%d cptcod=%d codtab=%d\n",cptcov, cptcod,codtabm(cptcod,cptcov)); |
//printf("cptcov=%d cptcod=%d codtab=%d\n",cptcov, cptcod,codtabm(cptcod,cptcov)); |
fprintf(ficresplb,"#******"); |
fprintf(ficresplb,"#******"); |
Line 9441 int back_prevalence_limit(double *p, dou
|
Line 9581 int back_prevalence_limit(double *p, dou
|
fprintf(ficresplb," %.3f %d\n", tot, *ncvyearp); |
fprintf(ficresplb," %.3f %d\n", tot, *ncvyearp); |
} /* Age */ |
} /* Age */ |
/* was end of cptcod */ |
/* was end of cptcod */ |
|
/*fprintf(ficresplb,"\n");*/ /* Seems to be necessary for gnuplot only if two result lines and no covariate. */ |
} /* end of any combination */ |
} /* end of any combination */ |
} /* end of nres */ |
} /* end of nres */ |
/* hBijx(p, bage, fage); */ |
/* hBijx(p, bage, fage); */ |
Line 9485 int hPijx(double *p, int bage, int fage)
|
Line 9626 int hPijx(double *p, int bage, int fage)
|
/* k=k+1; */ |
/* k=k+1; */ |
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(k=1; k<=i1;k++){ |
for(k=1; k<=i1;k++){ |
if(TKresult[nres]!= k) |
if(i1 != 1 && TKresult[nres]!= k) |
continue; |
continue; |
fprintf(ficrespij,"\n#****** "); |
fprintf(ficrespij,"\n#****** "); |
for(j=1;j<=cptcoveff;j++) |
for(j=1;j<=cptcoveff;j++) |
Line 9557 int hPijx(double *p, int bage, int fage)
|
Line 9698 int hPijx(double *p, int bage, int fage)
|
|
|
/* hstepm=1; aff par mois*/ |
/* hstepm=1; aff par mois*/ |
pstamp(ficrespijb); |
pstamp(ficrespijb); |
fprintf(ficrespijb,"#****** h Pij x Back Probability to be in state i at age x-h being in j at x "); |
fprintf(ficrespijb,"#****** h Bij x Back probability to be in state i at age x-h being in j at x: B1j+B2j+...=1 "); |
i1= pow(2,cptcoveff); |
i1= pow(2,cptcoveff); |
/* for(cptcov=1,k=0;cptcov<=i1;cptcov++){ */ |
/* for(cptcov=1,k=0;cptcov<=i1;cptcov++){ */ |
/* /\*for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){*\/ */ |
/* /\*for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){*\/ */ |
/* k=k+1; */ |
/* k=k+1; */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(nres=1; nres <= nresult; nres++){ /* For each resultline */ |
for(k=1; k<=i1;k++){ /* For any combination of dummy covariates, fixed and varying */ |
for(k=1; k<=i1;k++){ /* For any combination of dummy covariates, fixed and varying */ |
if(TKresult[nres]!= k) |
if(i1 != 1 && TKresult[nres]!= k) |
continue; |
continue; |
fprintf(ficrespijb,"\n#****** "); |
fprintf(ficrespijb,"\n#****** "); |
for(j=1;j<=cptcoveff;j++) |
for(j=1;j<=cptcoveff;j++) |
Line 9591 int hPijx(double *p, int bage, int fage)
|
Line 9732 int hPijx(double *p, int bage, int fage)
|
/* hbxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k); */ |
/* hbxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k); */ |
hbxij(p3mat,nhstepm,agedeb,hstepm,p,prevacurrent,nlstate,stepm, k); |
hbxij(p3mat,nhstepm,agedeb,hstepm,p,prevacurrent,nlstate,stepm, k); |
/* hbxij(p3mat,nhstepm,agedeb,hstepm,p,prevacurrent,nlstate,stepm,oldm,savm, dnewm, doldm, dsavm, k); */ |
/* hbxij(p3mat,nhstepm,agedeb,hstepm,p,prevacurrent,nlstate,stepm,oldm,savm, dnewm, doldm, dsavm, k); */ |
fprintf(ficrespijb,"# Cov Agex agex-h hpijx with i,j="); |
fprintf(ficrespijb,"# Cov Agex agex-h hbijx with i,j="); |
for(i=1; i<=nlstate;i++) |
for(i=1; i<=nlstate;i++) |
for(j=1; j<=nlstate+ndeath;j++) |
for(j=1; j<=nlstate+ndeath;j++) |
fprintf(ficrespijb," %1d-%1d",i,j); |
fprintf(ficrespijb," %1d-%1d",i,j); |
Line 10007 int main(int argc, char *argv[])
|
Line 10148 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 10997 Please run with mle=-1 to get a correct
|
Line 11133 Please run with mle=-1 to get a correct
|
fprintf(ficparo,"agemin=%.0f agemax=%.0f bage=%.0f fage=%.0f estepm=%d, ftolpl=%e\n",ageminpar,agemaxpar,bage,fage, estepm, ftolpl); |
fprintf(ficparo,"agemin=%.0f agemax=%.0f bage=%.0f fage=%.0f estepm=%d, ftolpl=%e\n",ageminpar,agemaxpar,bage,fage, estepm, ftolpl); |
|
|
/* Other stuffs, more or less useful */ |
/* Other stuffs, more or less useful */ |
while((c=getc(ficpar))=='#' && c!= EOF){ |
while(fgets(line, MAXLINE, ficpar)) { |
ungetc(c,ficpar); |
/* If line starts with a # it is a comment */ |
fgets(line, MAXLINE, ficpar); |
if (line[0] == '#') { |
fputs(line,stdout); |
numlinepar++; |
fputs(line,ficparo); |
fputs(line,stdout); |
|
fputs(line,ficparo); |
|
fputs(line,ficlog); |
|
continue; |
|
}else |
|
break; |
} |
} |
ungetc(c,ficpar); |
|
|
if((num_filled=sscanf(line,"begin-prev-date=%lf/%lf/%lf end-prev-date=%lf/%lf/%lf mov_average=%d\n",&jprev1, &mprev1,&anprev1,&jprev2, &mprev2,&anprev2,&mobilav)) !=EOF){ |
fscanf(ficpar,"begin-prev-date=%lf/%lf/%lf end-prev-date=%lf/%lf/%lf mov_average=%d\n",&jprev1, &mprev1,&anprev1,&jprev2, &mprev2,&anprev2,&mobilav); |
|
fprintf(ficparo,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav); |
if (num_filled != 7) { |
fprintf(ficres,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav); |
printf("Error: Not 7 (data)parameters in line but %d, for example:begin-prev-date=1/1/1990 end-prev-date=1/6/2004 mov_average=0\n, your line=%s . Probably you are running an older format.\n",num_filled,line); |
printf("begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav); |
fprintf(ficlog,"Error: Not 7 (data)parameters in line but %d, for example:begin-prev-date=1/1/1990 end-prev-date=1/6/2004 mov_average=0\n, your line=%s . Probably you are running an older format.\n",num_filled,line); |
fprintf(ficlog,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav); |
goto end; |
|
} |
while((c=getc(ficpar))=='#' && c!= EOF){ |
/* fscanf(ficpar,"begin-prev-date=%lf/%lf/%lf end-prev-date=%lf/%lf/%lf mov_average=%d\n",&jprev1, &mprev1,&anprev1,&jprev2, &mprev2,&anprev2,&mobilav); */ |
ungetc(c,ficpar); |
printf("begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav); |
fgets(line, MAXLINE, ficpar); |
fprintf(ficparo,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav); |
fputs(line,stdout); |
fprintf(ficres,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav); |
fputs(line,ficparo); |
printf("begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav); |
|
fprintf(ficlog,"begin-prev-date=%.lf/%.lf/%.lf end-prev-date=%.lf/%.lf/%.lf mov_average=%d\n",jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,mobilav); |
|
} |
|
|
|
while(fgets(line, MAXLINE, ficpar)) { |
|
/* If line starts with a # it is a comment */ |
|
if (line[0] == '#') { |
|
numlinepar++; |
|
fputs(line,stdout); |
|
fputs(line,ficparo); |
|
fputs(line,ficlog); |
|
continue; |
|
}else |
|
break; |
} |
} |
ungetc(c,ficpar); |
|
|
|
|
|
dateprev1=anprev1+(mprev1-1)/12.+(jprev1-1)/365.; |
dateprev1=anprev1+(mprev1-1)/12.+(jprev1-1)/365.; |
dateprev2=anprev2+(mprev2-1)/12.+(jprev2-1)/365.; |
dateprev2=anprev2+(mprev2-1)/12.+(jprev2-1)/365.; |
|
|
fscanf(ficpar,"pop_based=%d\n",&popbased); |
if((num_filled=sscanf(line,"pop_based=%d\n",&popbased)) !=EOF){ |
fprintf(ficlog,"pop_based=%d\n",popbased); |
if (num_filled != 1) { |
fprintf(ficparo,"pop_based=%d\n",popbased); |
printf("Error: Not 1 (data)parameters in line but %d, for example:pop_based=0\n, your line=%s . Probably you are running an older format.\n",num_filled,line); |
fprintf(ficres,"pop_based=%d\n",popbased); |
fprintf(ficlog,"Error: Not 1 (data)parameters in line but %d, for example: pop_based=1\n, your line=%s . Probably you are running an older format.\n",num_filled,line); |
|
goto end; |
while((c=getc(ficpar))=='#' && c!= EOF){ |
} |
ungetc(c,ficpar); |
printf("pop_based=%d\n",popbased); |
fgets(line, MAXLINE, ficpar); |
fprintf(ficlog,"pop_based=%d\n",popbased); |
fputs(line,stdout); |
fprintf(ficparo,"pop_based=%d\n",popbased); |
fputs(line,ficres); |
fprintf(ficres,"pop_based=%d\n",popbased); |
fputs(line,ficparo); |
|
} |
} |
ungetc(c,ficpar); |
|
|
while(fgets(line, MAXLINE, ficpar)) { |
fscanf(ficpar,"prevforecast=%d starting-proj-date=%lf/%lf/%lf final-proj-date=%lf/%lf/%lf mobil_average=%d\n",&prevfcast,&jproj1,&mproj1,&anproj1,&jproj2,&mproj2,&anproj2,&mobilavproj); |
/* If line starts with a # it is a comment */ |
fprintf(ficparo,"prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobil_average=%d\n",prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj); |
if (line[0] == '#') { |
printf("prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobil_average=%d\n",prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj); |
numlinepar++; |
fprintf(ficlog,"prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobil_average=%d\n",prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj); |
fputs(line,stdout); |
fprintf(ficres,"prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobil_average=%d\n",prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj); |
fputs(line,ficparo); |
|
fputs(line,ficlog); |
|
continue; |
|
}else |
|
break; |
|
} |
|
/* while((c=getc(ficpar))=='#' && c!= EOF){ */ |
|
/* ungetc(c,ficpar); */ |
|
/* fgets(line, MAXLINE, ficpar); */ |
|
/* fputs(line,stdout); */ |
|
/* fputs(line,ficres); */ |
|
/* fputs(line,ficparo); */ |
|
/* } */ |
|
/* ungetc(c,ficpar); */ |
|
|
|
/* fscanf(ficpar,"prevforecast=%d starting-proj-date=%lf/%lf/%lf final-proj-date=%lf/%lf/%lf mobil_average=%d\n",&prevfcast,&jproj1,&mproj1,&anproj1,&jproj2,&mproj2,&anproj2,&mobilavproj); */ |
|
if((num_filled=sscanf(line,"prevforecast=%d starting-proj-date=%lf/%lf/%lf final-proj-date=%lf/%lf/%lf mobil_average=%d\n",&prevfcast,&jproj1,&mproj1,&anproj1,&jproj2,&mproj2,&anproj2,&mobilavproj)) !=EOF){ |
|
if (num_filled != 8) { |
|
printf("Error: Not 8 (data)parameters in line but %d, for example:prevforecast=1 starting-proj-date=1/1/1990 final-proj-date=1/1/2000 mobil_average=0\n, your line=%s . Probably you are running an older format.\n",num_filled,line); |
|
fprintf(ficlog,"Error: Not 8 (data)parameters in line but %d, for example:prevforecast=1 starting-proj-date=1/1/1990 final-proj-date=1/1/2000 mov_average=0\n, your line=%s . Probably you are running an older format.\n",num_filled,line); |
|
goto end; |
|
} |
|
fprintf(ficparo,"prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobil_average=%d\n",prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj); |
|
printf("prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobil_average=%d\n",prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj); |
|
fprintf(ficlog,"prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobil_average=%d\n",prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj); |
|
fprintf(ficres,"prevforecast=%d starting-proj-date=%.lf/%.lf/%.lf final-proj-date=%.lf/%.lf/%.lf mobil_average=%d\n",prevfcast,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2,mobilavproj); |
/* day and month of proj2 are not used but only year anproj2.*/ |
/* day and month of proj2 are not used but only year anproj2.*/ |
|
|
while((c=getc(ficpar))=='#' && c!= EOF){ |
|
ungetc(c,ficpar); |
|
fgets(line, MAXLINE, ficpar); |
|
fputs(line,stdout); |
|
fputs(line,ficparo); |
|
fputs(line,ficres); |
|
} |
} |
ungetc(c,ficpar); |
while(fgets(line, MAXLINE, ficpar)) { |
|
/* If line starts with a # it is a comment */ |
|
if (line[0] == '#') { |
|
numlinepar++; |
|
fputs(line,stdout); |
|
fputs(line,ficparo); |
|
fputs(line,ficlog); |
|
continue; |
|
}else |
|
break; |
|
} |
|
/* while((c=getc(ficpar))=='#' && c!= EOF){ */ |
|
/* ungetc(c,ficpar); */ |
|
/* fgets(line, MAXLINE, ficpar); */ |
|
/* fputs(line,stdout); */ |
|
/* fputs(line,ficparo); */ |
|
/* fputs(line,ficres); */ |
|
/* } */ |
|
/* ungetc(c,ficpar); */ |
|
|
fscanf(ficpar,"backcast=%d starting-back-date=%lf/%lf/%lf final-back-date=%lf/%lf/%lf mobil_average=%d\n",&backcast,&jback1,&mback1,&anback1,&jback2,&mback2,&anback2,&mobilavproj); |
fscanf(ficpar,"backcast=%d starting-back-date=%lf/%lf/%lf final-back-date=%lf/%lf/%lf mobil_average=%d\n",&backcast,&jback1,&mback1,&anback1,&jback2,&mback2,&anback2,&mobilavproj); |
fprintf(ficparo,"backcast=%d starting-back-date=%.lf/%.lf/%.lf final-back-date=%.lf/%.lf/%.lf mobil_average=%d\n",backcast,jback1,mback1,anback1,jback2,mback2,anback2,mobilavproj); |
if((num_filled=sscanf(line,"backcast=%d starting-back-date=%lf/%lf/%lf final-back-date=%lf/%lf/%lf mobil_average=%d\n",&backcast,&jback1,&mback1,&anback1,&jback2,&mback2,&anback2,&mobilavproj)) !=EOF){ |
fprintf(ficlog,"backcast=%d starting-back-date=%.lf/%.lf/%.lf final-back-date=%.lf/%.lf/%.lf mobil_average=%d\n",backcast,jback1,mback1,anback1,jback2,mback2,anback2,mobilavproj); |
if (num_filled != 8) { |
fprintf(ficres,"backcast=%d starting-back-date=%.lf/%.lf/%.lf final-back-date=%.lf/%.lf/%.lf mobil_average=%d\n",backcast,jback1,mback1,anback1,jback2,mback2,anback2,mobilavproj); |
printf("Error: Not 8 (data)parameters in line but %d, for example:backcast=1 starting-back-date=1/1/1990 finloal-back-date=1/1/1970 mobil_average=1\n, your line=%s . Probably you are running an older format.\n",num_filled,line); |
|
fprintf(ficlog,"Error: Not 8 (data)parameters in line but %d, for example:backcast=1 starting-back-date=1/1/1990 finloal-back-date=1/1/1970 mobil_average=1\n, your line=%s . Probably you are running an older format.\n",num_filled,line); |
|
goto end; |
|
} |
|
printf("backcast=%d starting-back-date=%.lf/%.lf/%.lf final-back-date=%.lf/%.lf/%.lf mobil_average=%d\n",backcast,jback1,mback1,anback1,jback2,mback2,anback2,mobilavproj); |
|
fprintf(ficparo,"backcast=%d starting-back-date=%.lf/%.lf/%.lf final-back-date=%.lf/%.lf/%.lf mobil_average=%d\n",backcast,jback1,mback1,anback1,jback2,mback2,anback2,mobilavproj); |
|
fprintf(ficlog,"backcast=%d starting-back-date=%.lf/%.lf/%.lf final-back-date=%.lf/%.lf/%.lf mobil_average=%d\n",backcast,jback1,mback1,anback1,jback2,mback2,anback2,mobilavproj); |
|
fprintf(ficres,"backcast=%d starting-back-date=%.lf/%.lf/%.lf final-back-date=%.lf/%.lf/%.lf mobil_average=%d\n",backcast,jback1,mback1,anback1,jback2,mback2,anback2,mobilavproj); |
/* day and month of proj2 are not used but only year anproj2.*/ |
/* day and month of proj2 are not used but only year anproj2.*/ |
|
} |
/* Results */ |
/* Results */ |
nresult=0; |
nresult=0; |
while(fgets(line, MAXLINE, ficpar)) { |
while(fgets(line, MAXLINE, ficpar)) { |
Line 11077 Please run with mle=-1 to get a correct
|
Line 11272 Please run with mle=-1 to get a correct
|
while((num_filled=sscanf(line,"result:%[^\n]\n",resultline)) !=EOF){ |
while((num_filled=sscanf(line,"result:%[^\n]\n",resultline)) !=EOF){ |
if (num_filled == 0){ |
if (num_filled == 0){ |
resultline[0]='\0'; |
resultline[0]='\0'; |
|
printf("Warning %d: no result line should be at minimum 'result: V2=0 V1=1 or result:.\n%s\n", num_filled, line); |
break; |
break; |
} else if (num_filled != 1){ |
} else if (num_filled != 1){ |
printf("ERROR %d: result line should be at minimum 'result=' %s\n",num_filled, line); |
printf("ERROR %d: result line should be at minimum 'result: V2=0 V1=1 or result:.' %s\n",num_filled, line); |
} |
} |
nresult++; /* Sum of resultlines */ |
nresult++; /* Sum of resultlines */ |
printf("Result %d: result=%s\n",nresult, resultline); |
printf("Result %d: result=%s\n",nresult, resultline); |
Line 11251 Please run with mle=-1 to get a correct
|
Line 11447 Please run with mle=-1 to get a correct
|
|
|
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(k=1; k<=i1;k++){ /* For any combination of dummy covariates, fixed and varying */ |
for(k=1; k<=i1;k++){ /* For any combination of dummy covariates, fixed and varying */ |
if(TKresult[nres]!= k) |
if(i1 != 1 && TKresult[nres]!= k) |
continue; |
continue; |
fprintf(ficreseij,"\n#****** "); |
fprintf(ficreseij,"\n#****** "); |
printf("\n#****** "); |
printf("\n#****** "); |
Line 11324 Please run with mle=-1 to get a correct
|
Line 11520 Please run with mle=-1 to get a correct
|
|
|
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(k=1; k<=i1;k++){ /* For any combination of dummy covariates, fixed and varying */ |
for(k=1; k<=i1;k++){ /* For any combination of dummy covariates, fixed and varying */ |
if(TKresult[nres]!= k) |
if(i1 != 1 && TKresult[nres]!= k) |
continue; |
continue; |
printf("\n#****** Result for:"); |
printf("\n#****** Result for:"); |
fprintf(ficrest,"\n#****** Result for:"); |
fprintf(ficrest,"\n#****** Result for:"); |
Line 11465 Please run with mle=-1 to get a correct
|
Line 11661 Please run with mle=-1 to get a correct
|
|
|
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(nres=1; nres <= nresult; nres++) /* For each resultline */ |
for(k=1; k<=i1;k++){ |
for(k=1; k<=i1;k++){ |
if(TKresult[nres]!= k) |
if(i1 != 1 && TKresult[nres]!= k) |
continue; |
continue; |
fprintf(ficresvpl,"\n#****** "); |
fprintf(ficresvpl,"\n#****** "); |
printf("\n#****** "); |
printf("\n#****** "); |