Incorporating time-varying covariates using lookup tables.
## S4 method for signature 'numeric'covariate_table(..., order = c("linear","constant"), times)## S4 method for signature 'character'covariate_table(..., order = c("linear","constant"), times)repair_lookup_table(table, t, order)
Arguments
...: numeric vectors or data frames containing time-varying covariates. It must be possible to bind these into a data frame.
order: the order of interpolation to be used. Options are linear (the default) and constant . Setting order="linear" treats the covariates as piecewise linear functions of time; order="constant" treats them as right-continuous piecewise constant functions.
times: the times corresponding to the covariates. This may be given as a vector of (non-decreasing, finite) numerical values. Alternatively, one can specify by name which of the given variables is the time variable.
table: a covartable object created by a call to covariate_table
t: numeric vector; times at which interpolated values of the covariates in table are required.
Returns
covariate_table returns a lookup table suitable for inclusion of covariates in a pomp object. Specifically, this is an object of class covartable .
repair_lookup_table returns a lookup table with entries at the provided values of t.
Details
If the pomp object contains covariates (specified via the covar argument), then interpolated values of the covariates will be available to each of the model components whenever it is called. In particular, variables with names as they appear in the covar covariate table will be available to any C snippet. When a basic component is defined using an function, that function will be called with an extra argument, covars, which will be a named numeric vector containing the interpolated values from the covariate table.
An exception to this rule is the prior (rprior and dprior): covariate-dependent priors are not allowed. Nor are parameter transformations permitted to depend upon covariates.
repair_lookup_table applies lookup at the provided values of t and returns the resulting lookup table. If order is unsupplied, the interpolation-order from table is preserved. ‘repair_lookup_table’ should be considered experimental: its interfacemay change without notice .
Extrapolation
If t is outside the range of the lookup table, the values will be extrapolated, and a warning will be issued. The type of extrapolation performed will be constant or linear according to the order flag used when creating the table.