spatPomp_Csnippet: C snippets

spatPomp_CsnippetR Documentation

C snippets

Description

spatPomp_Csnippet() is used to provide snippets of C code that specify model components. It functions similarly to Csnippet() from the pomp package; in fact, the output of spatPomp_Csnippet is an object of class Csnippet. It additionally provides some arguments that allow the user to stay focused on model development in the spatiotemporal context where model size grows.

Usage

## S4 method for signature 'character'
spatPomp_Csnippet(
  code,
  method = "",
  unit_statenames,
  unit_obsnames,
  unit_covarnames,
  unit_ivpnames,
  unit_paramnames,
  unit_vfnames
)

Arguments

code

encodes a component of a spatiotemporal POMP model using C code

method

a character string matching the name of the 'spatPomp' argument which the code is designed to specify. This argument is ignored unless needed to correctly specify the Csnippet.

unit_statenames

a subset of the unit_statenames slot of the spatPomp object for which we are writing a model. This argument allows the user to get variables that can be indexed conveniently to update states and measurements in a loop. See examples for more details.

unit_obsnames

a subset of the unit_obsnames slot of the spatPomp object for which we are writing a model. This argument allows the user to get variables that can be indexed conveniently to update states and measurements in a loop. See examples for more details.

unit_covarnames

if the model has covariate information for each unit, the names of the covariates for each unit can be supplied to this argument. This allows the user to get variables that can be indexed conveniently to use incorporate the covariate information in a loop. See examples for more details.

unit_ivpnames

This argument is particularly useful when specifying the rinit model component. The paramnames argument to the spatPomp() constructor often has names for initial value parameters for the latent states (e.g. S1_0, S2_0 for the the quantity of susceptibles at unit 1 and unit 2 at the initial time in an SIR model). By supplying unit_ivpnames, we can get variables that can be easily indexed to reference the initial value parameters (in the previous example, unit_ivpnames=c('S') we can get a variable named S_0 that we can index as S_0[0] and S_0[1] to refer to S1_0 and S2_0). See examples for more details.

unit_paramnames

This argument is particularly useful when there are non-initial value parameters that are unit-specific.

unit_vfnames

This argument is particularly useful when specifying the skeleton model component. For all components of the latent state, the user can assume a variable defining the time-derivative is pre-defined (e.g. DS1 and DS2 for the time-derivative of the quantity of the susceptibles at unit 1 and unit 2 in an SIR model). By supplying unit_vfnames, we can get variables that can be easily indexed to reference these variables (in the previous example, setting unit_vfnames=c('S') gets us a variable named DS that we can index as DS[0] and DS[1] to refer to DS1 and DS2). See examples for more details.

Value

An object of class ‘Csnippet’ which represents a model specification in C code.

Author(s)

Kidus Asfaw

Examples

# Set initial states for Brownian motion
bm_rinit <- spatPomp_Csnippet(
  method = "rinit",
  unit_statenames = c("X"),
  unit_ivpnames = c("X"),
  code = "
    for (int u = 0; u < U; u++) {
      X[u]=X_0[u];
    }
  "
)
# Skeleton for Brownian motion
bm_skel <- spatPomp_Csnippet(
  method = "skeleton",
  unit_statenames = c("X"),
  unit_vfnames = c("X"),
  code = "
      for (int u = 0 ; u < U ; u++) {
        DX[u] = 0;
      }
  "
)

kidusasfaw/spatPomp documentation built on May 2, 2024, 6:12 p.m.