#define NLSTATEMAX 8 /* Maximum number of live states (for func) */\r
#define NDEATHMAX 8 /* Maximum number of dead states (for func) */\r
#define NCOVMAX 8 /* Maximum number of covariates */\r
-#define MAXN 80000\r
+#define MAXN 20000\r
#define YEARM 12. /* Number of months per year */\r
#define AGESUP 130\r
#define AGEBASE 40\r
{\r
int i,lg,j,p;\r
i=0;\r
- if (t[0]== occ) p=0;\r
for(j=0; j<=strlen(t)-1; j++) {\r
- if((t[j]!= occ) && (t[j+1]==occ)) p=j+1;\r
+ if((t[j]!= occ) && (t[j+1]== occ)) p=j+1;\r
}\r
\r
lg=strlen(t);\r
}\r
}\r
\r
-\r
/********************** nrerror ********************/\r
\r
void nrerror(char error_text[])\r
cov[1]=1.;\r
cov[2]=agev[mw[mi][i]][i]+d*stepm/YEARM;\r
if (cptcovn>0){\r
- for (k=1; k<=cptcovn;k++) {\r
- cov[2+k]=covar[Tvar[k]][i];\r
- /* printf("k=%d cptcovn=%d %lf\n",k,cptcovn,covar[Tvar[k]][i]);*/\r
- }\r
+ for (k=1; k<=cptcovn;k++) cov[2+k]=covar[1+k-1][i];\r
}\r
out=matprod2(newm,oldm,1,nlstate+ndeath,1,nlstate+ndeath,\r
1,nlstate+ndeath,pmij(pmmij,cov,ncovmodel,x,nlstate));\r
savm=oldm;\r
oldm=newm;\r
+\r
+\r
} /* end mult */\r
\r
lli=log(out[s[mw[mi][i]][i]][s[mw[mi+1][i]][i]]);\r
for(k=1,l=0.; k<=nlstate; k++) l += ll[k];\r
/* printf("l1=%f l2=%f ",ll[1],ll[2]); */\r
l= l*ipmx/sw; /* To get the same order of magnitude as if weight=1 for every body */\r
-\r
return -l;\r
}\r
\r
}\r
}\r
delti[theta]=delts;\r
- return res; \r
+ return res;\r
+ \r
}\r
\r
double hessij( double x[], double delti[], int thetai,int thetaj)\r
}\r
else{\r
j= rint( (agev[mw[mi+1][i]][i]*12 - agev[mw[mi][i]][i]*12));\r
- /*printf("i=%d agevi+1=%lf agevi=%lf j=%d\n", i,agev[mw[mi+1][i]][i],agev[mw[mi][i]][i],j);*/\r
-\r
k=k+1;\r
if (j >= jmax) jmax=j;\r
else if (j <= jmin)jmin=j;\r
s=imatrix(1,maxwav+1,1,n);\r
adl=imatrix(1,maxwav+1,1,n); \r
tab=ivector(1,NCOVMAX);\r
- ncodemax=ivector(1,NCOVMAX);\r
+ ncodemax=ivector(1,8);\r
\r
i=1; \r
while (fgets(line, MAXLINE, fic) != NULL) {\r
} \r
num[i]=atol(stra);\r
\r
- /* printf("%d %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]), (mint[3][i]), (anint[3][i]), (s[3][i]), (mint[4][i]), (anint[4][i]), (s[4][i]));*/\r
-\r
- /*printf("%d %.lf %.lf %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]),(covar[3][i]), (covar[4][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]));*/\r
+ /*printf("%d %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]), (mint[3][i]), (anint[3][i]), (s[3][i]), (mint[4][i]), (anint[4][i]), (s[4][i]), (mint[5][i]), (anint[5][i]), (s[5][i]), (mint[6][i]), (anint[6][i]), (s[6][i]));*/\r
\r
i=i+1;\r
}\r
} \r
- /*scanf("%d",i);*/\r
\r
+ /*scanf("%d",i);*/\r
imx=i-1; /* Number of individuals */\r
- \r
+\r
/* Calculation of the number of parameter from char model*/\r
Tvar=ivector(1,8); \r
\r
j=0;\r
j=nbocc(model,'+');\r
cptcovn=j+1;\r
- \r
+ \r
strcpy(modelsav,model); \r
if (j==0) {\r
cutv(stra,strb,modelsav,'V'); Tvar[1]=atoi(strb);\r
for (k=1; k<=lastobs;k++) \r
covar[ncov+1][k]=covar[atoi(stre)][k]*covar[atoi(strc)][k];\r
}\r
- else {\r
- cutv(strd,strc,strb,'V');\r
- Tvar[i+1]=atoi(strc);\r
+ else {cutv(strd,strc,strb,'V');\r
+ Tvar[i+1]=atoi(strc);\r
}\r
- strcpy(modelsav,stra); \r
+ strcpy(modelsav,stra); \r
}\r
- /*cutv(strd,strc,stra,'V');*/\r
+ cutv(strd,strc,stra,'V');\r
Tvar[1]=atoi(strc);\r
}\r
}\r
- /*printf("tvar=%d ",Tvar[1]);*/\r
- /*scanf("%d ",i);*/\r
+ /*printf("tvar=%d ",Tvar[1]);\r
+ scanf("%d ",i);*/ \r
fclose(fic);\r
\r
if (weightopt != 1) { /* Maximisation without weights*/\r
for (i=1; i<=imx; i++) {\r
agedc[i]=(moisdc[i]/12.+andc[i])-(moisnais[i]/12.+annais[i]);\r
for(m=1; (m<= maxwav); m++){\r
- if (mint[m][i]==99 || anint[m][i]==9999) s[m][i]=-1; \r
if(s[m][i] >0){\r
if (s[m][i] == nlstate+1) {\r
if(agedc[i]>0)\r
}\r
else if(s[m][i] !=9){ /* Should no more exist */\r
agev[m][i]=(mint[m][i]/12.+1./24.+anint[m][i])-(moisnais[i]/12.+1./24.+annais[i]);\r
- if(mint[m][i]==99 || anint[m][i]==9999){\r
+ if(mint[m][i]==99 || anint[m][i]==9999)\r
agev[m][i]=1;\r
- /* printf("i=%d m=%d agev=%lf \n",i,m, agev[m][i]); */ \r
- }\r
else if(agev[m][i] <agemin){ \r
agemin=agev[m][i];\r
/*printf(" Min anint[%d][%d]=%.2f annais[%d]=%.2f, agemin=%.2f\n",m,i,anint[m][i], i,annais[i], agemin);*/\r
printf("i=%d k=%d %d ",i,k,codtab[i][k]);\r
}\r
printf("\n");\r
- }\r
- scanf("%d",i);*/\r
+ }*/\r
+ /*scanf("%d",i);*/\r
\r
/* Calculates basic frequencies. Computes observed prevalence at single age\r
and prints on file fileres'p'. */\r
freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax);\r
\r
+\r
+ /*scanf("%d ",i);*/\r
+\r
+\r
pmmij= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */\r
oldms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */\r
newms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */\r
/* For Powell, parameters are in a vector p[] starting at p[1]\r
so we point p on param[1][1] so that p[1] maps on param[1][1][1] */\r
p=param[1][1]; /* *(*(*(param +1)+1)+0) */\r
- /*scanf("%d",i);*/\r
+ \r
mlikeli(ficres,p, npar, ncovmodel, nlstate, ftol, func);\r
\r
\r
\r
/*3eme*/\r
\r
- for (k1=1; k1<= m ; k1 ++) { \r
+ for (k1=1; k1<= m ; k1 ++) { \r
for (cpt=1; cpt<= nlstate ; cpt ++) {\r
k=2+nlstate*(cpt-1);\r
fprintf(ficgp,"set ter gif small size 400,300\nplot [%.f:%.f] \"e%s\" every :::%d::%d u 1:%d t \"e%d1\" w l",agemin,fage,fileres,k1-1,k1-1,k,cpt);\r
} \r
fprintf(ficgp,"\nset out \"exp%s%d%d.gif\" \nreplot\n\n",strtok(optionfile, "."),cpt,k1);\r
}\r
- }\r
+ }\r
\r
/* CV preval stat */\r
- for (k1=1; k1<= m ; k1 ++) { \r
+ for (k1=1; k1<= m ; k1 ++) { \r
for (cpt=1; cpt<nlstate ; cpt ++) {\r
k=3;\r
fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \nset ter gif small size 400,300\nplot [%.f:%.f] \"pij%s\" u ($1==%d ? ($3):1/0):($%d/($%d",agemin,agemax,fileres,k1,k+cpt+1,k+1);\r
fprintf(ficgp,"set out \"p%s%d%d.gif\" \nreplot\n\n",strtok(optionfile, "."),cpt,k1);\r
} \r
}\r
-\r
+ \r
/* proba elementaires */\r
for(i=1,jk=1; i <=nlstate; i++){\r
for(k=1; k <=(nlstate+ndeath); k++){\r
}\r
fprintf(ficgp,"\nset out \"pe%s%d.gif\" \nreplot\n\n",strtok(optionfile, "."),jk); \r
}\r
- fclose(ficgp);\r
- \r
-chdir(path);\r
+ \r
+ fclose(ficgp);\r
+\r
+ chdir(path);\r
free_matrix(agev,1,maxwav,1,imx);\r
free_ivector(wav,1,imx);\r
free_imatrix(dh,1,lastpass-firstpass+1,1,imx);\r
}\r
ungetc(c,ficpar);\r
\r
+\r
fscanf(ficpar,"agemin=%lf agemax=%lf bage=%lf fage=%lf\n",&agemin,&agemax, &bage, &fage);\r
printf("agemin=%.0f agemax=%.0f bage=%.0f fage=%.0f\n",agemin,agemax, bage, fage);\r
fprintf(ficparo,"agemin=%.0f agemax=%.0f bage=%.0f fage=%.0f\n",agemin,agemax,bage,fage);\r
}\r
for(cpt=1; cpt<=nlstate;cpt++) {\r
fprintf(fichtm,"\n<br>- Health life expectancies by age and initial health state (%d): exp%s%d%d.gif <br>\r
-<img src=\"exp%s%d%d.gif\">",cpt,strtok(optionfile, "."),cpt,j1,strtok(optionfile, "."),cpt,j1);\r
+<img src=\"ex%s%d%d.gif\">",cpt,strtok(optionfile, "."),cpt,j1,strtok(optionfile, "."),cpt,j1);\r
}\r
fprintf(fichtm,"\n<br>- Total life expectancy by age and\r
health expectancies in states (1) and (2): e%s%d.gif<br>\r
fclose(ficrest);\r
fclose(ficpar);\r
free_vector(epj,1,nlstate+1);\r
- /* scanf("%d ",i); */\r
+ /*scanf("%d ",i); */\r
\r
/*------- Variance limit prevalence------*/ \r
\r
#ifdef windows\r
chdir(pathcd);\r
#endif \r
- system("wgnuplot ../gp37mgw/graph.plt");\r
+ system("wgnuplot graph.plt");\r
\r
#ifdef windows\r
while (z[0] != 'q') {\r