dmeasure_spec: The measurement model density In pomp: Statistical Inference for Partially Observed Markov Processes

Description

Specification of dmeasure.

Details

The measurement model is the link between the data and the unobserved state process. It can be specified either by using one or both of the rmeasure and dmeasure arguments.

Suppose you have a procedure to compute the probability density of an observation given the value of the latent state variables. Then you can furnish

 1 dmeasure = f

to pomp algorithms, where f is a C snippet or R function that implements your procedure.

Using a C snippet is much preferred, due to its much greater computational efficiency. See Csnippet for general rules on writing C snippets. The goal of a dmeasure C snippet is to fill the variable lik with the either the probability density or the log probability density, depending on the value of the variable give_log.

In writing a dmeasure C snippet, observe that:

1. In addition to the states, parameters, covariates (if any), and observables, the variable t, containing the time of the observation will be defined in the context in which the snippet is executed.

2. Moreover, the Boolean variable give_log will be defined.

3. The goal of a dmeasure C snippet is to set the value of the lik variable to the likelihood of the data given the state, if give_log == 0. If give_log == 1, lik should be set to the log likelihood.

If dmeasure is to be provided instead as an R function, this is accomplished by supplying

 1 dmeasure = f

to pomp, where f is a function. The arguments of f should be chosen from among the observables, state variables, parameters, covariates, and time. It must also have the arguments ..., and log. It can take additional arguments via the userdata facility. f must return a single numeric value, the probability density (or log probability density if log = TRUE) of y given x at time t.

Important note

It is a common error to fail to account for both log = TRUE and log = FALSE when writing the dmeasure C snippet or function.

Default behavior

If dmeasure is left unspecified, calls to dmeasure will return missing values (NA).

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.