rmeasure_spec: The measurement-model simulator

Description Details Default behavior Note for Windows users See Also Examples

Description

Specification of the measurement-model simulator, rmeasure.

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 simulate observations given the value of the latent state variables. Then you can furnish

1
  rmeasure = 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.

In writing an rmeasure C snippet, bear in mind that:

  1. The goal of such a snippet is to fill the observables with random values drawn from the measurement model distribution. Accordingly, each observable should be assigned a new value.

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

The demos and the tutorials on the package website give examples as well.

It is also possible, though far less efficient, to specify rmeasure using an R function. In this case, specify the measurement model simulator by furnishing

1
  rmeasure = f

to pomp, where f is an R function. The arguments of f should be chosen from among the state variables, parameters, covariates, and time. It must also have the argument .... f must return a named numeric vector of length equal to the number of observable variables.

Default behavior

The default rmeasure is undefined. It will yield 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 to cause the C snippets to be written to a file of your choice, thus avoiding the use of temporary files altogether.

See Also

rmeasure

More on implementing POMP models: Csnippet, accumulator variables, basic components, covariates, distributions, dmeasure specification, dprocess specification, parameter transformations, pomp-package, pomp, prior specification, rinit specification, rprocess specification, skeleton specification, transformations, userdata

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  ## We start with the pre-built Ricker example:
  
  ricker() -> po

  ## To change the measurement model simulator, rmeasure,
  ## we use the 'rmeasure' argument in any 'pomp'
  ## elementary or estimation function.
  ## Here, we pass the rmeasure specification to 'simulate'
  ## as an R function.

  po %>%
    simulate(
      rmeasure=function (N, phi, ...) {
        c(y=rpois(n=1,lambda=phi*N))
      }
    ) -> sim

  ## We can also pass it as a C snippet:

  po %>%
    simulate(
      rmeasure=Csnippet("y = rpois(phi*N);"),
      paramnames="phi",
      statenames="N"
    ) -> sim

pomp documentation built on Sept. 5, 2021, 5:27 p.m.