Learn R Programming

pomp (version 3.3)

rinit_spec: The initial-state distribution

Description

Specification of rinit

Arguments

Default behavior

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.

Note for Windows users

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 (described here) to cause the C snippets to be written to a file of your choice, thus avoiding the use of temporary files altogether.

Details

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:

  1. 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\).

  2. 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.

  3. 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.

See Also

More on implementing POMP models: Csnippet, accumulators, basic_components, covariate_table(), distributions, dmeasure_spec, dprocess_spec, parameter_trans(), pomp-package, prior_spec, rmeasure_spec, rprocess_spec, skeleton_spec, transformations, userdata

Examples

Run this code
# NOT RUN {
## We set up a trivial process model:

trivial <- function (X, Y, ...) {
  c(X = X+1, Y = Y-1)
}

## We specify \code{rinit} with a function that
## sets state variables X and Y to the values in
## parameters X0, Y0:

f <- function (X0, Y0, ...) {
  c(X = X0, Y = Y0)
}

plot(simulate(times=1:5,t0=0,params=c(X0=3,Y0=-7),
  rinit=f,rprocess=onestep(trivial)))

## A function that depends on covariate P and
## time t0, as well as parameter X0:

g <- function (t0, X0, P, ...) {
  c(X = X0, Y = P + sin(2*pi*t0))
}

plot(simulate(times=1:5,t0=0,params=c(X0=3,Y0=-7),
  covar=covariate_table(t=0:10,P=3:13,times="t"),
  rinit=g,rprocess=onestep(trivial)))
# }

Run the code above in your browser using DataLab