4 #define lambda (__p[__parindex[0]])
5 #define mu (__p[__parindex[1]])
6 #define psi (__p[__parindex[2]])
7 #define n0 (__p[__parindex[3]])
8 #define n (__x[__stateindex[0]])
9 #define ll (__x[__stateindex[1]])
10 #define ell (__x[__stateindex[2]])
11 #define node (__x[__stateindex[3]])
14 event_rates(__x,__p,t, \
15 __stateindex,__parindex,rate,&penalty) \
22 const int *__stateindex,
23 const int *__parindex,
27 double event_rate = 0;
35 event_rate += (*rate = alpha*(1-disc)); rate++;
36 *penalty += alpha*disc;
40 event_rate += (*rate = alpha); rate++;
47 assert(R_FINITE(event_rate));
57 const int *__stateindex,
58 const int *__parindex,
59 const int *__covindex,
60 const double *__covars
75 const int *__stateindex,
76 const int *__parindex,
77 const int *__covindex,
78 const double *__covars,
82 double tstep = 0.0, tmax = t + dt;
85 int parent = (int) nearbyint(
node);
90 assert(parent<=nnode);
94 switch (nodetype[parent]) {
105 if (sat[parent] == 1) {
107 }
else if (sat[parent] == 0) {
119 assert(sat[parent]==2);
133 tstep = exp_rand()/event_rate;
135 while (t + tstep < tmax) {
136 event =
rcateg(event_rate,rate,2);
151 tstep = exp_rand()/event_rate;
159 # define lik (__lik[0])
169 const int *__obsindex,
170 const int *__stateindex,
171 const int *__parindex,
172 const int *__covindex,
173 const double *__covars,
177 lik = (give_log) ?
ll : exp(
ll);
get_userdata_int_t * get_userdata_int
static int rcateg(double erate, double *rate, int nrate)
void lbdp_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 lbdp_gill(double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, const double *__covars, double t, double dt)
static double event_rates(double *__x, const double *__p, double t, const int *__stateindex, const int *__parindex, double *rate, double *penalty)
void lbdp_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).