eulermultinom | R Documentation |
pomp provides a number of probability distributions that have proved useful in modeling partially observed Markov processes. These include the Euler-multinomial family of distributions and the the Gamma white-noise processes.
reulermultinom(n = 1, size, rate, dt)
deulermultinom(x, size, rate, dt, log = FALSE)
rgammawn(n = 1, sigma, dt)
n |
integer; number of random variates to generate. |
size |
scalar integer; number of individuals at risk. |
rate |
numeric vector of hazard rates. |
dt |
numeric scalar; duration of Euler step. |
x |
matrix or vector containing number of individuals that have succumbed to each death process. |
log |
logical; if TRUE, return logarithm(s) of probabilities. |
sigma |
numeric scalar; intensity of the Gamma white noise process. |
If N
individuals face constant hazards of death in K
ways
at rates r_1, r_2, \dots, r_K
,
then in an interval of duration \Delta{t}
,
the number of individuals remaining alive and dying in each way is multinomially distributed:
(\Delta{n_0}, \Delta{n_1}, \dots, \Delta{n_K}) \sim \mathrm{Multinomial}(N;p_0,p_1,\dots,p_K),
where \Delta{n_0}=N-\sum_{k=1}^K \Delta{n_k}
is the number of individuals remaining alive and
\Delta{n_k}
is the number of individuals dying in way k
over the interval.
Here, the probability of remaining alive is
p_0=\exp(-\sum_k r_k \Delta{t})
and the probability of dying in way k
is
p_k=\frac{r_k}{\sum_j r_j} (1-p_0).
In this case, we say that
(\Delta{n_1},\dots,\Delta{n_K})\sim\mathrm{Eulermultinom}(N,r,\Delta t),
where r=(r_1,\dots,r_K)
.
Draw m
random samples from this distribution by doing
dn <- reulermultinom(n=m,size=N,rate=r,dt=dt),
where r
is the vector of rates.
Evaluate the probability that x=(x_1,\dots,x_K)
are the numbers of individuals who have died in each of the K
ways over the interval \Delta t=
dt
,
by doing
deulermultinom(x=x,size=N,rate=r,dt=dt).
Bretó & Ionides (2011) discuss how an infinitesimally overdispersed death process can be constructed by compounding a multinomial process with a Gamma white noise process. The Euler approximation of the resulting process can be obtained as follows. Let the increments of the equidispersed process be given by
reulermultinom(size=N,rate=r,dt=dt).
In this expression, replace the rate r
with r\,{\Delta{W}}/{\Delta t}
,
where \Delta{W} \sim \mathrm{Gamma}(\Delta{t}/\sigma^2,\sigma^2)
is the increment of an integrated Gamma white noise process with intensity \sigma
.
That is, \Delta{W}
has mean \Delta{t}
and variance \sigma^2 \Delta{t}
.
The resulting process is overdispersed and converges (as \Delta{t}
goes to zero) to a well-defined process.
The following lines of code accomplish this:
dW <- rgammawn(sigma=sigma,dt=dt)
dn <- reulermultinom(size=N,rate=r,dt=dW)
or
dn <- reulermultinom(size=N,rate=r*dW/dt,dt=dt).
He et al. (2010) use such overdispersed death processes in modeling measles and the "Simulation-based Inference" course discusses the value of allowing for overdispersion more generally.
For all of the functions described here, access to the underlying C routines is available: see below.
reulermultinom |
Returns a |
deulermultinom |
Returns a vector (of length equal to the number of columns of |
rgammawn |
Returns a vector of length |
An interface for C codes using these functions is provided by the package. Visit the package homepage to view the pomp C API document.
Aaron A. King
2011
\He2010
More on implementing POMP models:
Csnippet
,
accumvars
,
basic_components
,
betabinomial
,
covariates
,
dinit_spec
,
dmeasure_spec
,
dprocess_spec
,
emeasure_spec
,
parameter_trans()
,
pomp-package
,
pomp_constructor
,
prior_spec
,
rinit_spec
,
rmeasure_spec
,
rprocess_spec
,
skeleton_spec
,
transformations
,
userdata
,
vmeasure_spec
print(dn <- reulermultinom(5,size=100,rate=c(a=1,b=2,c=3),dt=0.1))
deulermultinom(x=dn,size=100,rate=c(1,2,3),dt=0.1)
## an Euler-multinomial with overdispersed transitions:
dt <- 0.1
dW <- rgammawn(sigma=0.1,dt=dt)
print(dn <- reulermultinom(5,size=100,rate=c(a=1,b=2,c=3),dt=dW))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.