void _sir_par_trans (double *pt, double *p, int *parindex) { int nbasis = *(get_pomp_userdata_int("nbasis")); int k; pt[parindex[0]] = exp(GAMMA); pt[parindex[1]] = exp(MU); pt[parindex[2]] = exp(IOTA); for (k = 0; k < nbasis; k++) pt[parindex[3]+k] = exp(BETA[k]); pt[parindex[4]] = exp(BETA_SD); pt[parindex[6]] = expit(RHO); from_log_barycentric(pt+parindex[7],&S0,3); }
/////////////////////////////////////////////////////////////////// // DEFINE THE MEASUREMENT MODEL /////////////////////////////////////////////////////////////////// void null_chickenpox_meas_sim (double *y, double *x, double *p, int *obsindex, int *stateindex, int *parindex, int *covindex, int ncovar, double *covar, double t) { double report_rate, tau; // PUT PARS ON NATURAL SCALE tau = exp(LOGTAU); report_rate = expit(LOGITRHO); CHICKENPOX = rnorm(report_rate*I,tau*I); if (CHICKENPOX >= 0) { CHICKENPOX = nearbyint(CHICKENPOX); } else {CHICKENPOX = 0;} }
/////////////////////////////////////////////////////////////////// // DEFINE THE MEASUREMENT DENSITY FOR CALCULATING THE LIKELIHOOD /////////////////////////////////////////////////////////////////// void null_chickenpox_meas_dens (double *lik, double *y, double *x, double *p, int give_log, int *obsindex, int *stateindex, int *parindex, int *covindex, int ncovar, double *covar, double t) { double report_rate, tau; double tol = 1.0e-18; // PUT PARS ON NATURAL SCALE tau = exp(LOGTAU); report_rate = expit(LOGITRHO); if(CHICKENPOX > 0.0){ *lik = pnorm(CHICKENPOX+0.5,report_rate*I,tau*I,1,0) - pnorm(CHICKENPOX-0.5,report_rate*I,tau*I,1,0)+ tol; } else{ *lik = pnorm(CHICKENPOX+0.5,report_rate*I,tau*I,1,0)+ tol; } if (give_log) *lik = log(*lik); if (!isfinite(*lik)) Rprintf("chickenpox_meas_dens %lg %lg %lg %lg %lg\n",CHICKENPOX,report_rate,tau,I,*lik); }