#include "pomplink.h"
#include "internal.h"
Go to the source code of this file.
|
| #define | STRAIN1 0 |
| |
| #define | STRAIN2 1 |
| |
| #define | STRAIN3 2 |
| |
| #define | Beta1 (__p[__parindex[0]]) |
| |
| #define | Beta2 (__p[__parindex[1]]) |
| |
| #define | Beta3 (__p[__parindex[2]]) |
| |
| #define | gamma (__p[__parindex[3]]) |
| |
| #define | psi1 (__p[__parindex[4]]) |
| |
| #define | psi2 (__p[__parindex[5]]) |
| |
| #define | psi3 (__p[__parindex[6]]) |
| |
| #define | S_0 (__p[__parindex[7]]) |
| |
| #define | I1_0 (__p[__parindex[8]]) |
| |
| #define | I2_0 (__p[__parindex[9]]) |
| |
| #define | I3_0 (__p[__parindex[10]]) |
| |
| #define | R_0 (__p[__parindex[11]]) |
| |
| #define | N (__p[__parindex[12]]) |
| |
| #define | S (__x[__stateindex[0]]) |
| |
| #define | I1 (__x[__stateindex[1]]) |
| |
| #define | I2 (__x[__stateindex[2]]) |
| |
| #define | I3 (__x[__stateindex[3]]) |
| |
| #define | R (__x[__stateindex[4]]) |
| |
| #define | ll (__x[__stateindex[5]]) |
| |
| #define | ellI1 (__x[__stateindex[6]]) |
| |
| #define | ellI2 (__x[__stateindex[7]]) |
| |
| #define | ellI3 (__x[__stateindex[8]]) |
| |
| #define | node (__x[__stateindex[9]]) |
| |
| #define | EVENT_RATES |
| |
| #define | lik (__lik[0]) |
| |
|
| 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 | strains_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 | strains_gill (double *__x, const double *__p, const int *__stateindex, const int *__parindex, const int *__covindex, const double *__covars, double t, double dt) |
| |
| void | strains_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 const int | nrate = 6 |
| |
◆ Beta1
| #define Beta1 (__p[__parindex[0]]) |
◆ Beta2
| #define Beta2 (__p[__parindex[1]]) |
◆ Beta3
| #define Beta3 (__p[__parindex[2]]) |
◆ ellI1
| #define ellI1 (__x[__stateindex[6]]) |
◆ ellI2
| #define ellI2 (__x[__stateindex[7]]) |
◆ ellI3
| #define ellI3 (__x[__stateindex[8]]) |
◆ EVENT_RATES
Value:
__stateindex,__parindex,__covindex, \
__covars,rate,&penalty) \
static double event_rates(double *__x, const double *__p, double t, const int *__stateindex, const int *__parindex, double *rate, double *penalty)
Definition at line 34 of file strains_pomp.c.
34#define EVENT_RATES \
35 event_rates(__x,__p,t, \
36 __stateindex,__parindex,__covindex, \
37 __covars,rate,&penalty) \
38
◆ gamma
| #define gamma (__p[__parindex[3]]) |
◆ I1
| #define I1 (__x[__stateindex[1]]) |
◆ I1_0
| #define I1_0 (__p[__parindex[8]]) |
◆ I2
| #define I2 (__x[__stateindex[2]]) |
◆ I2_0
| #define I2_0 (__p[__parindex[9]]) |
◆ I3
| #define I3 (__x[__stateindex[3]]) |
◆ I3_0
| #define I3_0 (__p[__parindex[10]]) |
◆ lik
◆ ll
| #define ll (__x[__stateindex[5]]) |
| #define N (__p[__parindex[12]]) |
◆ node
| #define node (__x[__stateindex[9]]) |
◆ psi1
| #define psi1 (__p[__parindex[4]]) |
◆ psi2
| #define psi2 (__p[__parindex[5]]) |
◆ psi3
| #define psi3 (__p[__parindex[6]]) |
| #define R (__x[__stateindex[4]]) |
◆ R_0
| #define R_0 (__p[__parindex[11]]) |
| #define S (__x[__stateindex[0]]) |
◆ S_0
| #define S_0 (__p[__parindex[7]]) |
◆ STRAIN1
◆ STRAIN2
◆ STRAIN3
◆ event_rates()
| 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 ) |
|
static |
Definition at line 39 of file strains_pomp.c.
50 {
51 double event_rate = 0;
52 double alpha, disc;
53 *penalty = 0;
61
64 event_rate += (*rate = alpha*(1-disc)); rate++;
65 *penalty += alpha*disc;
66
69 event_rate += (*rate = alpha); rate++;
70 } else {
71 *rate = 0; rate++;
72 *penalty += alpha;
73 }
74
76 *penalty += alpha;
77
80 event_rate += (*rate = alpha*(1-disc)); rate++;
81 *penalty += alpha*disc;
82
85 event_rate += (*rate = alpha); rate++;
86 } else {
87 *rate = 0; rate++;
88 *penalty += alpha;
89 }
90
92 *penalty += alpha;
93
96 event_rate += (*rate = alpha*(1-disc)); rate++;
97 *penalty += alpha*disc;
98
101 event_rate += (*rate = alpha); rate++;
102 } else {
103 *rate = 0; rate++;
104 *penalty += alpha;
105 }
106
108 *penalty += alpha;
109 assert(R_FINITE(event_rate));
110 return event_rate;
111}
◆ strains_dmeas()
| void strains_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).
Definition at line 290 of file strains_pomp.c.
303 {
305 lik = (give_log) ?
ll : exp(
ll);
306}
◆ strains_gill()
| void strains_gill |
( |
double * | __x, |
|
|
const double * | __p, |
|
|
const int * | __stateindex, |
|
|
const int * | __parindex, |
|
|
const int * | __covindex, |
|
|
const double * | __covars, |
|
|
double | t, |
|
|
double | dt ) |
Latent-state process simulator (rprocess).
This integrates the filter equation.
Definition at line 140 of file strains_pomp.c.
150 {
151 double tstep = 0.0, tmax = t + dt;
155
156 int parent = (int) nearbyint(
node);
157
158#ifndef NDEBUG
160 assert(parent>=0);
161 assert(parent<=nnode);
162#endif
163
165
166
167 switch (nodetype[parent]) {
168 default:
169 break;
170 case 0:
171 switch (
deme[parent]) {
178 default:
179 assert(0); break;
180 }
181 break;
182 case 1:
183 assert(sat[parent]==0);
184 switch (
deme[parent]) {
190 break;
196 break;
202 break;
203 default:
204 assert(0); break;
205 }
206 break;
207 case 2:
209 if (sat[parent]!=2) break;
210 switch (
deme[parent]) {
217 break;
224 break;
231 break;
232 default:
233 assert(0);
234 break;
235 }
237 break;
238 }
239
240 if (tmax > t) {
241
242
243 int event;
244 double penalty = 0;
246
248 tstep = exp_rand()/event_rate;
249
250 while (t + tstep < tmax) {
252 assert(event>=0 && event<
nrate);
254 switch (event) {
255 case 0:
257 break;
258 case 1:
260 break;
261 case 2:
263 break;
264 case 3:
266 break;
267 case 4:
269 break;
270 case 5:
272 break;
273 default:
274 assert(0);
275 break;
276 }
277 t += tstep;
279 tstep = exp_rand()/event_rate;
280 }
281 tstep = tmax - t;
283 }
285}
get_userdata_int_t * get_userdata_int
static int rcateg(double erate, double *rate, int nrate)
◆ strains_rinit()
| void strains_rinit |
( |
double * | __x, |
|
|
const double * | __p, |
|
|
double | t, |
|
|
const int * | __stateindex, |
|
|
const int * | __parindex, |
|
|
const int * | __covindex, |
|
|
const double * | __covars ) |
Latent-state initializer (rinit).
Definition at line 114 of file strains_pomp.c.
123 {
125 S = nearbyint(
S_0*m);
129 R = nearbyint(
R_0*m);
135}
◆ nrate