Description Usage Arguments Details Value Important Note See Also Examples
Estimation of parameters for deterministic POMP models
1 2 3 4 5 6 7 8 9 10 11 12 | ## S4 method for signature 'data.frame'
traj_objfun(data, est = character(0),
fail.value = NA, ode_control = list(), params, rinit, skeleton,
dmeasure, partrans, ..., verbose = getOption("verbose", FALSE))
## S4 method for signature 'pomp'
traj_objfun(data, est = character(0), fail.value = NA,
ode_control = list(), ..., verbose = getOption("verbose", FALSE))
## S4 method for signature 'traj_match_objfun'
traj_objfun(data, est, fail.value,
ode_control, ..., verbose = getOption("verbose", FALSE))
|
data |
either a data frame holding the time series data, or an object of class ‘pomp’, i.e., the output of another pomp calculation. |
est |
character vector; the names of parameters to be estimated. |
fail.value |
optional numeric scalar;
if non- |
ode_control |
optional list;
the elements of this list will be passed to |
params |
optional; named numeric vector of parameters.
This will be coerced internally to storage mode |
rinit |
simulator of the initial-state distribution.
This can be furnished either as a C snippet, an R function, or the name of a pre-compiled native routine available in a dynamically loaded library.
Setting |
skeleton |
optional; the deterministic skeleton of the unobserved state process.
Depending on whether the model operates in continuous or discrete time, this is either a vectorfield or a map.
Accordingly, this is supplied using either the |
dmeasure |
evaluator of the measurement model density, specified either as a C snippet, an R function, or the name of a pre-compiled native routine available in a dynamically loaded library.
Setting |
partrans |
optional parameter transformations, constructed using Many algorithms for parameter estimation search an unconstrained space of parameters.
When working with such an algorithm and a model for which the parameters are constrained, it can be useful to transform parameters.
One should supply the |
... |
additional arguments will modify the model structure |
verbose |
logical; if |
In trajectory matching, one attempts to minimize the discrepancy between a POMP model's predictions and data under the assumption that the latent state process is deterministic and all discrepancies between model and data are due to measurement error.
The measurement model likelihood (dmeasure
), or rather its negative, is the natural measure of the discrepancy.
Trajectory matching is a generalization of the traditional nonlinear least squares approach. In particular, if, on some scale, measurement errors are normal with constant variance, then trajectory matching is equivalent to least squares on that particular scale.
traj_objfun
constructs an objective function that evaluates the likelihood function.
It can be passed to any one of a variety of numerical optimization routines, which will adjust model parameters to minimize the discrepancies between the power spectrum of model simulations and that of the data.
traj_objfun
constructs a stateful objective function for spectrum matching.
Specifically, traj_objfun
returns an object of class ‘traj_match_objfun’, which is a function suitable for use in an optim
-like optimizer.
In particular, this function takes a single numeric-vector argument that is assumed to contain the parameters named in est
, in that order.
When called, it will return the negative log likelihood.
It is a stateful function:
Each time it is called, it will remember the values of the parameters and its estimate of the log likelihood.
Since pomp cannot guarantee that the final call an optimizer makes to the function is a call at the optimum, it cannot guarantee that the parameters stored in the function are the optimal ones. Therefore, it is a good idea to evaluate the function on the parameters returned by the optimization routine, which will ensure that these parameters are stored.
trajectory
, optim
,
subplex
, nloptr
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | library(magrittr)
ricker() %>%
traj_objfun(
est=c("r","sigma","N_0"),
partrans=parameter_trans(log=c("r","sigma","N_0")),
paramnames=c("r","sigma","N_0"),
) -> f
f(log(c(20,0.3,10)))
library(subplex)
subplex(fn=f,par=log(c(20,0.3,10)),control=list(reltol=1e-5)) -> out
f(out$par)
library(ggplot2)
f %>%
trajectory(format="data.frame") %>%
ggplot(aes(x=time,y=N))+geom_line()+theme_bw()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.