rinit_spec | R Documentation |
Specification of the initial-state distribution simulator, rinit.
To fully specify the unobserved Markov state process, one must give its distribution at the zero-time (t0
).
One does this by furnishing a value for the rinit
argument.
As usual, this can be provided either as a C snippet or as an R function.
In the former case, bear in mind that:
The goal of a this snippet is the construction of a state vector, i.e., the setting of the dynamical states at time t_0
.
In addition to the parameters and covariates (if any), the variable t
, containing the zero-time, will be defined in the context in which the snippet is executed.
NB: The statenames
argument plays a particularly important role when the rinit is specified using a C snippet.
In particular, every state variable must be named in statenames
.
Failure to follow this rule will result in undefined behavior.
General rules for writing C snippets can be found here.
If an R function is to be used, pass
rinit = f
to pomp
, where f
is a function with arguments that can include the initial time t0
, any of the model parameters, and any covariates.
As usual, f
may take additional arguments, provided these are passed along with it in the call to pomp
.
f
must return a named numeric vector of initial states.
It is of course important that the names of the states match the expectations of the other basic components.
Note that the state-process rinit
can be either deterministic (as in the default) or stochastic.
In the latter case, it samples from the distribution of the state process at the zero-time, t0
.
By default, pomp
assumes that the initial distribution is concentrated on a single point.
In particular, any parameters in params
, the names of which end in “_0
” or “.0
”, are assumed to be initial values of states.
When the state process is initialized, these are simply copied over as initial conditions.
The names of the resulting state variables are obtained by dropping the suffix.
Some Windows users report problems when using C snippets in parallel computations.
These appear to arise when the temporary files created during the C snippet compilation process are not handled properly by the operating system.
To circumvent this problem, use the cdir
and cfile
options to cause the C snippets to be written to a file of your choice, thus avoiding the use of temporary files altogether.
rinit
More on implementing POMP models:
Csnippet
,
accumvars
,
basic_components
,
betabinomial
,
covariates
,
dinit_spec
,
dmeasure_spec
,
dprocess_spec
,
emeasure_spec
,
eulermultinom
,
parameter_trans()
,
pomp-package
,
pomp_constructor
,
prior_spec
,
rmeasure_spec
,
rprocess_spec
,
skeleton_spec
,
transformations
,
userdata
,
vmeasure_spec
## Starting with an existing pomp object
verhulst() -> po
## we add or change the initial-state simulator,
## rinit, using the 'rinit' argument in any 'pomp'
## elementary or estimation function (or in the
## 'pomp' constructor itself).
## Here, we pass the rinit specification to 'simulate'
## as an R function.
po |>
simulate(
rinit=function (n_0, ...) {
c(n=rpois(n=1,lambda=n_0))
}
) -> sim
## We can also pass it as a C snippet:
po |>
simulate(
rinit=Csnippet("n = rpois(n_0);"),
paramnames="n_0",
statenames="n"
) -> sim
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.