6 #define Beta (__p[__parindex[0]])
7 #define gamma (__p[__parindex[1]])
8 #define psi (__p[__parindex[2]])
9 #define omega (__p[__parindex[3]])
10 #define S0 (__p[__parindex[4]])
11 #define I0 (__p[__parindex[5]])
12 #define R0 (__p[__parindex[6]])
13 #define N (__p[__parindex[7]])
14 #define S (__x[__stateindex[0]])
15 #define I (__x[__stateindex[1]])
16 #define R (__x[__stateindex[2]])
17 #define ll (__x[__stateindex[3]])
18 #define ellI (__x[__stateindex[4]])
19 #define node (__x[__stateindex[5]])
22 event_rates(__x,__p,t, \
23 __stateindex,__parindex,__covindex, \
24 __covars,rate,&penalty) \
31 const int *__stateindex,
32 const int *__parindex,
33 const int *__covindex,
34 const double *__covars,
38 double event_rate = 0;
47 event_rate += (*rate = alpha*(1-disc)); rate++;
48 *penalty += alpha*disc;
52 event_rate += (*rate = alpha); rate++;
59 event_rate += (*rate = alpha); rate++;
63 assert(R_FINITE(event_rate));
73 const int *__stateindex,
74 const int *__parindex,
75 const int *__covindex,
76 const double *__covars
94 const int *__stateindex,
95 const int *__parindex,
96 const int *__covindex,
97 const double *__covars,
101 double tstep = 0.0, tmax = t + dt;
105 int parent = (int) nearbyint(
node);
110 assert(parent<=nnode);
114 switch (nodetype[parent]) {
125 if (sat[parent] == 1) {
127 }
else if (sat[parent] == 0) {
140 assert(sat[parent]==2);
144 ll -= log(
I*(
I-1)/2);
157 tstep = exp_rand()/event_rate;
159 while (t + tstep < tmax) {
178 tstep = exp_rand()/event_rate;
186 # define lik (__lik[0])
196 const int *__obsindex,
197 const int *__stateindex,
198 const int *__parindex,
199 const int *__covindex,
200 const double *__covars,
204 lik = (give_log) ?
ll : exp(
ll);
get_userdata_int_t * get_userdata_int
static int rcateg(double erate, double *rate, int nrate)
void sirs_dmeas(double *__lik, const double *__y, const double *__x, const double *__p, int give_log, const int *__obsindex, const int *__stateindex, const int *__parindex, const int *__covindex, const double *__covars, double t)
Measurement model likelihood (dmeasure).
static double event_rates(double *__x, const double *__p, double t, const int *__stateindex, const int *__parindex, const int *__covindex, const double *__covars, double *rate, double *penalty)
void sirs_rinit(double *__x, const double *__p, double t, const int *__stateindex, const int *__parindex, const int *__covindex, const double *__covars)
Latent-state initializer (rinit).
void sirs_gill(double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, const double *__covars, double t, double dt)