version 1.196, 2015/08/18 23:17:52
|
version 1.197, 2015/09/01 18:24:39
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.197 2015/09/01 18:24:39 brouard |
|
*** empty log message *** |
|
|
Revision 1.196 2015/08/18 23:17:52 brouard |
Revision 1.196 2015/08/18 23:17:52 brouard |
Summary: 0.98q5 |
Summary: 0.98q5 |
|
|
Line 694 typedef struct {
|
Line 697 typedef struct {
|
#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 20 /**< Maximum number of covariates, including generated covariates V1*V2 */ |
#define NCOVMAX 20 /**< Maximum number of covariates, including generated covariates V1*V2 */ |
#define codtabm(h,k) 1 & (h-1) >> (k-1) ; |
#define codtabm(h,k) (1 & (h-1) >> (k-1))+1 |
#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 715 typedef struct {
|
Line 718 typedef struct {
|
/* $State$ */ |
/* $State$ */ |
#include "version.h" |
#include "version.h" |
char version[]=__IMACH_VERSION__; |
char version[]=__IMACH_VERSION__; |
char copyright[]="August 2015,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015"; |
char copyright[]="September 2015,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015"; |
char fullversion[]="$Revision$ $Date$"; |
char fullversion[]="$Revision$ $Date$"; |
char strstart[80]; |
char strstart[80]; |
char optionfilext[10], optionfilefiname[FILENAMELENGTH]; |
char optionfilext[10], optionfilefiname[FILENAMELENGTH]; |
Line 850 int estepm;
|
Line 853 int estepm;
|
|
|
int m,nb; |
int m,nb; |
long *num; |
long *num; |
int firstpass=0, lastpass=4,*cod, *Tage,*cens; |
int firstpass=0, lastpass=4,*cod, *cens; |
int *ncodemax; /* ncodemax[j]= Number of modalities of the j th |
int *ncodemax; /* ncodemax[j]= Number of modalities of the j th |
covariate for which somebody answered excluding |
covariate for which somebody answered excluding |
undefined. Usually 2: 0 and 1. */ |
undefined. Usually 2: 0 and 1. */ |
Line 870 double **covar; /**< covar[j,i], value
|
Line 873 double **covar; /**< covar[j,i], value
|
* cov[Tage[kk]+2]=covar[Tvar[Tage[kk]]][i]*age; */ |
* cov[Tage[kk]+2]=covar[Tvar[Tage[kk]]][i]*age; */ |
double idx; |
double idx; |
int **nbcode, *Tvar; /**< model=V2 => Tvar[1]= 2 */ |
int **nbcode, *Tvar; /**< model=V2 => Tvar[1]= 2 */ |
|
int *Tage; |
int *Ndum; /** Freq of modality (tricode */ |
int *Ndum; /** Freq of modality (tricode */ |
int **codtab; /**< codtab=imatrix(1,100,1,10); */ |
int **codtab; /**< codtab=imatrix(1,100,1,10); */ |
int **Tvard, *Tprod, cptcovprod, *Tvaraff; |
int **Tvard, *Tprod, cptcovprod, *Tvaraff; |
Line 1908 double **prevalim(double **prlim, int nl
|
Line 1912 double **prevalim(double **prlim, int nl
|
cov[3]= agefin*agefin;; |
cov[3]= agefin*agefin;; |
for (k=1; k<=cptcovn;k++) { |
for (k=1; k<=cptcovn;k++) { |
cov[2+nagesqr+k]=nbcode[Tvar[k]][codtab[ij][Tvar[k]]]; |
cov[2+nagesqr+k]=nbcode[Tvar[k]][codtab[ij][Tvar[k]]]; |
/*printf("prevalim ij=%d k=%d Tvar[%d]=%d nbcode=%d cov=%lf codtab[%d][Tvar[%d]]=%d \n",ij,k, k, Tvar[k],nbcode[Tvar[k]][codtab[ij][Tvar[k]]],cov[2+k], ij, k, codtab[ij][Tvar[k]]);*/ |
/* printf("prevalim ij=%d k=%d Tvar[%d]=%d nbcode=%d cov=%lf codtab[%d][Tvar[%d]]=%d \n",ij,k, k, Tvar[k],nbcode[Tvar[k]][codtab[ij][Tvar[k]]],cov[2+k], ij, k, codtab[ij][Tvar[k]]);*/ |
} |
} |
/*wrong? for (k=1; k<=cptcovage;k++) cov[2+Tage[k]]=cov[2+Tage[k]]*cov[2]; */ |
/*wrong? for (k=1; k<=cptcovage;k++) cov[2+Tage[k]]=cov[2+Tage[k]]*cov[2]; */ |
for (k=1; k<=cptcovage;k++) cov[2+nagesqr+Tage[k]]=nbcode[Tvar[k]][codtab[ij][Tvar[k]]]*cov[2]; |
for (k=1; k<=cptcovage;k++) cov[2+nagesqr+Tage[k]]=nbcode[Tvar[k]][codtab[ij][Tvar[k]]]*cov[2]; |
Line 3394 void tricode(int *Tvar, int **nbcode, in
|
Line 3398 void tricode(int *Tvar, int **nbcode, in
|
nbcode[Tvar[j]][1]=0; |
nbcode[Tvar[j]][1]=0; |
nbcode[Tvar[j]][2]=1; |
nbcode[Tvar[j]][2]=1; |
nbcode[Tvar[j]][3]=2; |
nbcode[Tvar[j]][3]=2; |
|
To be continued (not working yet). |
*/ |
*/ |
ij=0; /* ij is similar to i but can jumps over null modalities */ |
ij=0; /* ij is similar to i but can jump over null modalities */ |
for (i=modmincovj; i<=modmaxcovj; i++) { /* i= 1 to 2 for dichotomous, or from 1 to 3 or from -1 to 1*/ |
for (i=modmincovj; i<=modmaxcovj; i++) { /* i= 1 to 2 for dichotomous, or from 1 to 3 or from -1 or 0 to 1 currently*/ |
if (Ndum[i] == 0) { /* If at least one individual responded to this modality k */ |
if (Ndum[i] == 0) { /* If nobody responded to this modality k */ |
break; |
break; |
} |
} |
ij++; |
ij++; |
nbcode[Tvar[j]][ij]=i; /* stores the original modality i in an array nbcode, ij modality from 1 to last non-nul modality.*/ |
nbcode[Tvar[j]][ij]=i; /* stores the original value of modality i in an array nbcode, ij modality from 1 to last non-nul modality.*/ |
cptcode = ij; /* New max modality for covar j */ |
cptcode = ij; /* New max modality for covar j */ |
} /* end of loop on modality i=-1 to 1 or more */ |
} /* end of loop on modality i=-1 to 1 or more */ |
|
|
Line 4230 void varprob(char optionfilefiname[], do
|
Line 4235 void varprob(char optionfilefiname[], do
|
fprintf(fichtm,"\n<li><h4> Computing and drawing one step probabilities with their confidence intervals</h4></li>\n"); |
fprintf(fichtm,"\n<li><h4> Computing and drawing one step probabilities with their confidence intervals</h4></li>\n"); |
fprintf(fichtm,"\n"); |
fprintf(fichtm,"\n"); |
|
|
fprintf(fichtm,"\n<li><h4> <a href=\"%s\">Matrix of variance-covariance of pairs of step probabilities (drawings)</a></h4></li>\n",optionfilehtmcov); |
fprintf(fichtm,"\n<li><h4> <a href=\"%s\">Matrix of variance-covariance of one-step probabilities (drawings)</a></h4></br>this page is important in order to visualize confidence intervals and especially correlation between disability and recovery</li>\n",optionfilehtmcov); |
fprintf(fichtmcov,"\n<h4>Matrix of variance-covariance of pairs of step probabilities</h4>\n\ |
fprintf(fichtmcov,"Current page is file <a href=\"%s\">%s</a><br>\n\n<h4>Matrix of variance-covariance of pairs of step probabilities</h4>\n",optionfilehtmcov, optionfilehtmcov); |
file %s<br>\n",optionfilehtmcov); |
fprintf(fichtmcov,"\nEllipsoids of confidence centered on point (p<inf>ij</inf>, p<inf>kl</inf>) are estimated \ |
fprintf(fichtmcov,"\nEllipsoids of confidence centered on point (p<inf>ij</inf>, p<inf>kl</inf>) are estimated\ |
|
and drawn. It helps understanding how is the covariance between two incidences.\ |
and drawn. It helps understanding how is the covariance between two incidences.\ |
They are expressed in year<sup>-1</sup> in order to be less dependent of stepm.<br>\n"); |
They are expressed in year<sup>-1</sup> in order to be less dependent of stepm.<br>\n"); |
fprintf(fichtmcov,"\n<br> Contour plot corresponding to x'cov<sup>-1</sup>x = 4 (where x is the column vector (pij,pkl)) are drawn. \ |
fprintf(fichtmcov,"\n<br> Contour plot corresponding to x'cov<sup>-1</sup>x = 4 (where x is the column vector (pij,pkl)) are drawn. \ |
Line 4558 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
Line 4562 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
\n<br><li><h4> <a name='secondorder'>Result files (second order: variances)</a></h4>\n\ |
\n<br><li><h4> <a name='secondorder'>Result files (second order: variances)</a></h4>\n\ |
- Parameter file with estimated parameters and covariance matrix: <a href=\"%s\">%s</a> <br> \ |
- Parameter file with estimated parameters and covariance matrix: <a href=\"%s\">%s</a> <br> \ |
- 95%% confidence intervals and T statistics are in the log file.<br>\n", rfileres,rfileres); |
- 95%% confidence intervals and Wald tests of the estimated parameters are in the log file.<br> \ |
|
But because parameters are usually highly correlated (a higher incidence of disability \ |
|
and a higher incidence of recovery can give very close observed transition) it might \ |
|
be very useful to look not only at linear confidence intervals estimated from the \ |
|
variances but at the covariance matrix. And instead of looking at the estimated coefficients \ |
|
(parameters) of the logistic regression, it might be more meaningful to visualize the \ |
|
covariance matrix of the one-step probabilities. \ |
|
See page 'Matrix of variance-covariance of one-step probabilities' below. \n", rfileres,rfileres); |
|
|
fprintf(fichtm," - Standard deviation of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
fprintf(fichtm," - Standard deviation of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
subdirf2(fileres,"prob"),subdirf2(fileres,"prob")); |
subdirf2(fileres,"prob"),subdirf2(fileres,"prob")); |
Line 4814 plot [%.f:%.f] ", ageminpar, agemaxpar)
|
Line 4825 plot [%.f:%.f] ", ageminpar, agemaxpar)
|
fprintf(ficgp," exp(p%d+p%d*x+p%d*x*x",i,i+1,i+1+nagesqr); |
fprintf(ficgp," exp(p%d+p%d*x+p%d*x*x",i,i+1,i+1+nagesqr); |
ij=1;/* To be checked else nbcode[0][0] wrong */ |
ij=1;/* To be checked else nbcode[0][0] wrong */ |
for(j=3; j <=ncovmodel-nagesqr; j++) { |
for(j=3; j <=ncovmodel-nagesqr; j++) { |
if(((j-2)==Tage[ij]) &&(ij <=cptcovage)) { /* Bug valgrind */ |
/* printf("Tage[%d]=%d, j=%d\n", ij, Tage[ij], j); */ |
fprintf(ficgp,"+p%d*%d*x",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]); |
if(ij <=cptcovage) { /* Bug valgrind */ |
ij++; |
if((j-2)==Tage[ij]) { /* Bug valgrind */ |
|
fprintf(ficgp,"+p%d*%d*x",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]); |
|
ij++; |
|
} |
} |
} |
else |
else |
fprintf(ficgp,"+p%d*%d",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtab[jk][j-2]]); |
fprintf(ficgp,"+p%d*%d",i+j+nagesqr-1,nbcode[Tvar[j-2]][codtab[jk][j-2]]); |
Line 4831 plot [%.f:%.f] ", ageminpar, agemaxpar)
|
Line 4845 plot [%.f:%.f] ", ageminpar, agemaxpar)
|
|
|
ij=1; |
ij=1; |
for(j=3; j <=ncovmodel-nagesqr; j++){ |
for(j=3; j <=ncovmodel-nagesqr; j++){ |
if(((j-2)==Tage[ij]) &&(ij <=cptcovage)) { |
if(ij <=cptcovage) { /* Bug valgrind */ |
fprintf(ficgp,"+p%d*%d*x",k3+(k1-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]); |
if((j-2)==Tage[ij]) { /* Bug valgrind */ |
ij++; |
fprintf(ficgp,"+p%d*%d*x",k3+(k1-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtab[jk][Tvar[j-2]]]); |
|
ij++; |
|
} |
} |
} |
else |
else |
fprintf(ficgp,"+p%d*%d",k3+(k1-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtab[jk][j-2]]); |
fprintf(ficgp,"+p%d*%d",k3+(k1-1)*ncovmodel+1+j-2+nagesqr,nbcode[Tvar[j-2]][codtab[jk][j-2]]); |
Line 6279 int main(int argc, char *argv[])
|
Line 6295 int main(int argc, char *argv[])
|
|
|
int jj, ll, li, lj, lk; |
int jj, ll, li, lj, lk; |
int numlinepar=0; /* Current linenumber of parameter file */ |
int numlinepar=0; /* Current linenumber of parameter file */ |
|
int num_filled; |
int itimes; |
int itimes; |
int NDIM=2; |
int NDIM=2; |
int vpopbased=0; |
int vpopbased=0; |
Line 6297 int main(int argc, char *argv[])
|
Line 6314 int main(int argc, char *argv[])
|
double ***mobaverage; |
double ***mobaverage; |
|
|
char line[MAXLINE]; |
char line[MAXLINE]; |
char path[MAXLINE],pathc[MAXLINE],pathcd[MAXLINE],pathtot[MAXLINE],model[MAXLINE]; |
char path[MAXLINE],pathc[MAXLINE],pathcd[MAXLINE],pathtot[MAXLINE]; |
|
|
|
char model[MAXLINE], modeltemp[MAXLINE]; |
char pathr[MAXLINE], pathimach[MAXLINE]; |
char pathr[MAXLINE], pathimach[MAXLINE]; |
char *tok, *val; /* pathtot */ |
char *tok, *val; /* pathtot */ |
int firstobs=1, lastobs=10; |
int firstobs=1, lastobs=10; |
Line 6441 int main(int argc, char *argv[])
|
Line 6460 int main(int argc, char *argv[])
|
goto end; |
goto end; |
} |
} |
fprintf(ficlog,"Log filename:%s\n",filelog); |
fprintf(ficlog,"Log filename:%s\n",filelog); |
fprintf(ficlog,"\n%s\n%s",version,fullversion); |
fprintf(ficlog,"Version %s %s",version,fullversion); |
fprintf(ficlog,"\nEnter the parameter file name: \n"); |
fprintf(ficlog,"\nEnter the parameter file name: \n"); |
fprintf(ficlog,"pathimach=%s\npathtot=%s\n\ |
fprintf(ficlog,"pathimach=%s\npathtot=%s\n\ |
path=%s \n\ |
path=%s \n\ |
Line 6449 int main(int argc, char *argv[])
|
Line 6468 int main(int argc, char *argv[])
|
optionfilext=%s\n\ |
optionfilext=%s\n\ |
optionfilefiname='%s'\n",pathimach,pathtot,path,optionfile,optionfilext,optionfilefiname); |
optionfilefiname='%s'\n",pathimach,pathtot,path,optionfile,optionfilext,optionfilefiname); |
|
|
syscompilerinfo(0); |
syscompilerinfo(1); |
|
|
printf("Local time (at start):%s",strstart); |
printf("Local time (at start):%s",strstart); |
fprintf(ficlog,"Local time (at start): %s",strstart); |
fprintf(ficlog,"Local time (at start): %s",strstart); |
Line 6485 int main(int argc, char *argv[])
|
Line 6504 int main(int argc, char *argv[])
|
|
|
/* Reads comments: lines beginning with '#' */ |
/* Reads comments: lines beginning with '#' */ |
numlinepar=0; |
numlinepar=0; |
while((c=getc(ficpar))=='#' && c!= EOF){ |
|
ungetc(c,ficpar); |
/* First parameter line */ |
fgets(line, MAXLINE, 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; |
|
} |
|
if((num_filled=sscanf(line,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\n", \ |
|
title, datafile, &lastobs, &firstpass,&lastpass)) !=EOF){ |
|
if (num_filled != 5) { |
|
printf("Should be 5 parameters\n"); |
|
} |
numlinepar++; |
numlinepar++; |
fputs(line,stdout); |
printf("title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\n", title, datafile, lastobs, firstpass,lastpass); |
fputs(line,ficparo); |
} |
fputs(line,ficlog); |
/* Second parameter line */ |
|
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; |
|
} |
|
if((num_filled=sscanf(line,"ftol=%lf stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n", \ |
|
&ftol, &stepm, &ncovcol, &nlstate, &ndeath, &maxwav, &mle, &weightopt)) !=EOF){ |
|
if (num_filled != 8) { |
|
printf("Not 8\n"); |
|
} |
|
printf("ftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\n",ftol, stepm, ncovcol, nlstate,ndeath, maxwav, mle, weightopt); |
} |
} |
ungetc(c,ficpar); |
|
|
|
fscanf(ficpar,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%lf stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d model=1+age+%s\n",title, datafile, &lastobs, &firstpass,&lastpass,&ftol, &stepm, &ncovcol, &nlstate,&ndeath, &maxwav, &mle, &weightopt,model); |
/* Third parameter line */ |
numlinepar=numlinepar+3; /* In general */ |
while(fgets(line, MAXLINE, ficpar)) { |
printf("title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nlstate,ndeath, maxwav, mle, weightopt,model); |
/* 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; |
|
} |
|
if((num_filled=sscanf(line,"model=1+age%[^.\n]\n", model)) !=EOF){ |
|
if (num_filled != 1) { |
|
printf("ERROR %d: Model should be at minimum 'model=1+age.' %s\n",num_filled, line); |
|
fprintf(ficlog,"ERROR %d: Model should be at minimum 'model=1+age.' %s\n",num_filled, line); |
|
model[0]='\0'; |
|
goto end; |
|
} |
|
else{ |
|
if (model[0]=='+'){ |
|
for(i=1; i<=strlen(model);i++) |
|
modeltemp[i-1]=model[i]; |
|
} |
|
strcpy(model,modeltemp); |
|
} |
|
printf(" model=1+age%s modeltemp= %s, model=%s\n",model, modeltemp, model);fflush(stdout); |
|
} |
|
/* fscanf(ficpar,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%lf stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d model=1+age+%s\n",title, datafile, &lastobs, &firstpass,&lastpass,&ftol, &stepm, &ncovcol, &nlstate,&ndeath, &maxwav, &mle, &weightopt,model); */ |
|
/* numlinepar=numlinepar+3; /\* In general *\/ */ |
|
/* printf("title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncovcol, nlstate,ndeath, maxwav, mle, weightopt,model); */ |
if(model[strlen(model)-1]=='.') /* Suppressing leading dot in the model */ |
if(model[strlen(model)-1]=='.') /* Suppressing leading dot in the model */ |
model[strlen(model)-1]='\0'; |
model[strlen(model)-1]='\0'; |
fprintf(ficparo,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol,nlstate,ndeath,maxwav, mle, weightopt,model); |
fprintf(ficparo,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol,nlstate,ndeath,maxwav, mle, weightopt,model); |
fprintf(ficlog,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age+%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol,nlstate,ndeath,maxwav, mle, weightopt,model); |
fprintf(ficlog,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncovcol=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=1+age%s.\n", title, datafile, lastobs, firstpass,lastpass,ftol,stepm,ncovcol,nlstate,ndeath,maxwav, mle, weightopt,model); |
fflush(ficlog); |
fflush(ficlog); |
/* if(model[0]=='#'|| model[0]== '\0'){ */ |
/* if(model[0]=='#'|| model[0]== '\0'){ */ |
if(model[0]=='#'){ |
if(model[0]=='#'){ |
Line 6847 Please run with mle=-1 to get a correct
|
Line 6925 Please run with mle=-1 to get a correct
|
|
|
m=pow(2,cptcoveff); |
m=pow(2,cptcoveff); |
|
|
for(k=1;k<=cptcoveff; k++){ /* scans any effective covariate */ |
|
for(i=1; i <=pow(2,cptcoveff-k);i++){ /* i=1 to 8/1=8; i=1 to 8/2=4; i=1 to 8/8=1 */ |
|
for(j=1; j <= ncodemax[k]; j++){ /* For each modality of this covariate ncodemax=2*/ |
|
for(cpt=1; cpt <=pow(2,k-1); cpt++){ /* cpt=1 to 8/2**(3+1-1 or 3+1-3) =1 or 4 */ |
|
h++; |
|
if (h>m) |
|
h=1; |
|
/**< codtab(h,k) k = codtab[h,k]=( (h-1) - mod(k-1,2**(k-1) )/2**(k-1) + 1 |
/**< codtab(h,k) k = codtab[h,k]=( (h-1) - mod(k-1,2**(k-1) )/2**(k-1) + 1 |
* For k=4 covariates, h goes from 1 to 2**k |
* For k=4 covariates, h goes from 1 to 2**k |
* codtabm(h,k)= 1 & (h-1) >> (k-1) ; |
* codtabm(h,k)= 1 & (h-1) >> (k-1) ; |
Line 6867 Please run with mle=-1 to get a correct
|
Line 6938 Please run with mle=-1 to get a correct
|
* 6 2 1 2 1 |
* 6 2 1 2 1 |
* 7 i=4 1 2 2 1 |
* 7 i=4 1 2 2 1 |
* 8 2 2 2 1 |
* 8 2 2 2 1 |
* 9 i=5 1 i=3 1 i=2 1 1 |
* 9 i=5 1 i=3 1 i=2 1 2 |
* 10 2 1 1 1 |
* 10 2 1 1 2 |
* 11 i=6 1 2 1 1 |
* 11 i=6 1 2 1 2 |
* 12 2 2 1 1 |
* 12 2 2 1 2 |
* 13 i=7 1 i=4 1 2 1 |
* 13 i=7 1 i=4 1 2 2 |
* 14 2 1 2 1 |
* 14 2 1 2 2 |
* 15 i=8 1 2 2 1 |
* 15 i=8 1 2 2 2 |
* 16 2 2 2 1 |
* 16 2 2 2 2 |
*/ |
*/ |
codtab[h][k]=j; |
for(h=1; h <=100 ;h++){ |
/* codtab[12][3]=1; */ |
/* printf("h=%2d ", h); */ |
/*codtab[h][Tvar[k]]=j;*/ |
for(k=1; k <=10; 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]]); |
/* printf("k=%d %d ",k,codtabm(h,k)); */ |
} |
codtab[h][k]=codtabm(h,k); |
} |
} |
} |
/* printf("\n"); */ |
} |
} |
|
/* for(k=1;k<=cptcoveff; k++){ /\* scans any effective covariate *\/ */ |
|
/* for(i=1; i <=pow(2,cptcoveff-k);i++){ /\* i=1 to 8/1=8; i=1 to 8/2=4; i=1 to 8/8=1 *\/ */ |
|
/* for(j=1; j <= ncodemax[k]; j++){ /\* For each modality of this covariate ncodemax=2*\/ */ |
|
/* for(cpt=1; cpt <=pow(2,k-1); cpt++){ /\* cpt=1 to 8/2**(3+1-1 or 3+1-3) =1 or 4 *\/ */ |
|
/* h++; */ |
|
/* if (h>m) */ |
|
/* h=1; */ |
|
/* codtab[h][k]=j; */ |
|
/* /\* codtab[12][3]=1; *\/ */ |
|
/* /\*codtab[h][Tvar[k]]=j;*\/ */ |
|
/* /\* 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]]); *\/ */ |
|
/* } */ |
|
/* } */ |
|
/* } */ |
|
/* } */ |
/* printf("codtab[1][2]=%d codtab[2][2]=%d",codtab[1][2],codtab[2][2]); |
/* printf("codtab[1][2]=%d codtab[2][2]=%d",codtab[1][2],codtab[2][2]); |
codtab[1][2]=1;codtab[2][2]=2; */ |
codtab[1][2]=1;codtab[2][2]=2; */ |
/* for(i=1; i <=m ;i++){ |
/* for(i=1; i <=m ;i++){ */ |
for(k=1; k <=cptcovn; k++){ |
/* for(k=1; k <=cptcovn; k++){ */ |
printf("i=%d k=%d %d %d ",i,k,codtab[i][k], cptcoveff); |
/* printf("i=%d k=%d %d %d ",i,k,codtab[i][k], cptcoveff); */ |
} |
/* } */ |
printf("\n"); |
/* printf("\n"); */ |
} |
/* } */ |
scanf("%d",i);*/ |
/* scanf("%d",i);*/ |
|
|
free_ivector(Ndum,-1,NCOVMAX); |
free_ivector(Ndum,-1,NCOVMAX); |
|
|
Line 7255 Please run with mle=-1 to get a correct
|
Line 7341 Please run with mle=-1 to get a correct
|
ftolhess=ftol; /* Usually correct */ |
ftolhess=ftol; /* Usually correct */ |
hesscov(matcov, p, npar, delti, ftolhess, func); |
hesscov(matcov, p, npar, delti, ftolhess, func); |
} |
} |
printf("Parameters and 95%% confidence intervals\n"); |
printf("Parameters and 95%% confidence intervals\n W is simply the result of the division of the parameter by the square root of covariance of the parameter.\n And Wald-based confidence intervals plus and minus 1.96 * W .\n But be careful that parameters are highly correlated because incidence of disability is highly correlated to incidence of recovery.\n It might be better to visualize the covariance matrix. See the page 'Matrix of variance-covariance of one-step probabilities' and its graphs.\n"); |
fprintf(ficlog, "Parameters, T and confidence intervals\n"); |
fprintf(ficlog, "Parameters, Wald tests and Wald-based confidence intervals\n W is simply the result of the division of the parameter by the square root of covariance of the parameter.\n And Wald-based confidence intervals plus and minus 1.96 * W \n It might be better to visualize the covariance matrix. See the page 'Matrix of variance-covariance of one-step probabilities' and its graphs.\n"); |
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); |
printf("%d%d ",i,k); |
fprintf(ficlog,"%d%d ",i,k); |
fprintf(ficlog,"%d%d ",i,k); |
for(j=1; j <=ncovmodel; j++){ |
for(j=1; j <=ncovmodel; j++){ |
printf("%12.7f T=%8.3f CI=[%12.7f ; %12.7f] ",p[jk], p[jk]/sqrt(matcov[jk][jk]), p[jk]-2*sqrt(matcov[jk][jk]),p[jk]+2*sqrt(matcov[jk][jk])); |
printf("%12.7f W=%8.3f CI=[%12.7f ; %12.7f] ",p[jk], p[jk]/sqrt(matcov[jk][jk]), p[jk]-1.96*sqrt(matcov[jk][jk]),p[jk]+1.96*sqrt(matcov[jk][jk])); |
fprintf(ficlog,"%12.7f T=%8.3f CI=[%12.7f ; %12.7f] ",p[jk], p[jk]/sqrt(matcov[jk][jk]), p[jk]-2*sqrt(matcov[jk][jk]),p[jk]+2*sqrt(matcov[jk][jk])); |
fprintf(ficlog,"%12.7f W=%8.3f CI=[%12.7f ; %12.7f] ",p[jk], p[jk]/sqrt(matcov[jk][jk]), p[jk]-1.96*sqrt(matcov[jk][jk]),p[jk]+1.96*sqrt(matcov[jk][jk])); |
jk++; |
jk++; |
} |
} |
printf("\n"); |
printf("\n"); |