Description Usage Arguments Details Value Important Note See Also Examples
Estimation of parameters by matching power spectra
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## S4 method for signature 'data.frame'
spect_objfun(data, est = character(0),
weights = 1, fail.value = NA, vars, kernel.width, nsim,
seed = NULL, transform.data = identity, detrend = c("none", "mean",
"linear", "quadratic"), params, rinit, rprocess, rmeasure, partrans, ...,
verbose = getOption("verbose", FALSE))
## S4 method for signature 'pomp'
spect_objfun(data, est = character(0), weights = 1,
fail.value = NA, vars, kernel.width, nsim, seed = NULL,
transform.data = identity, detrend = c("none", "mean", "linear",
"quadratic"), ..., verbose = getOption("verbose", FALSE))
## S4 method for signature 'spectd_pomp'
spect_objfun(data, est = character(0),
weights = 1, fail.value = NA, vars, kernel.width, nsim,
seed = NULL, transform.data = identity, detrend, ...,
verbose = getOption("verbose", FALSE))
## S4 method for signature 'spect_match_objfun'
spect_objfun(data, est, weights, fail.value,
seed = NULL, ..., 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. |
weights |
optional numeric or function.
The mismatch between model and data is measured by a weighted average of mismatch at each frequency.
By default, all frequencies are weighted equally.
|
fail.value |
optional numeric scalar;
if non- |
vars |
optional; names of observed variables for which the power spectrum will be computed. By default, the spectrum will be computed for all observables. |
kernel.width |
width parameter for the smoothing kernel used for calculating the estimate of the spectrum. |
nsim |
the number of model simulations to be computed. |
seed |
integer.
When fitting, it is often best to fix the seed of the random-number generator (RNG).
This is accomplished by setting |
transform.data |
function; this transformation will be applied to the observables prior to estimation of the spectrum, and prior to any detrending. |
detrend |
de-trending operation to perform. Options include no detrending, and subtraction of constant, linear, and quadratic trends from the data. Detrending is applied to each data series and to each model simulation independently. |
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 |
rprocess |
simulator of the latent state process, specified using one of the rprocess plugins.
Setting |
rmeasure |
simulator of the measurement model, 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 supply new or modify existing model characteristics or components.
See When named arguments not recognized by |
verbose |
logical; if |
In spectrum matching, one attempts to minimize the discrepancy between a POMP model's predictions and data, as measured in the frequency domain by the power spectrum.
spect_objfun
constructs an objective function that measures the discrepancy.
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.
spect_objfun
constructs a stateful objective function for spectrum matching.
Specifically, spect_objfun
returns an object of class ‘spect_match_objfun’, which is a function suitable for use in an optim
-like optimizer.
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 (optionally weighted) L2 distance between the data spectrum and simulated spectra.
It is a stateful function:
Each time it is called, it will remember the values of the parameters and the discrepancy measure.
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.
Other pomp parameter estimation methods: abc
,
bsmc2
, kalman
,
mif2
, nlf
,
pmcmc
, pomp2-package
,
probe.match
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(magrittr)
ricker() %>%
spect_objfun(
est=c("r","sigma","N_0"),
partrans=parameter_trans(log=c("r","sigma","N_0")),
paramnames=c("r","sigma","N_0"),
kernel.width=3,
nsim=100,
seed=5069977
) -> f
f(log(c(20,0.3,10)))
f %>% spect() %>% plot()
library(subplex)
subplex(fn=f,par=log(c(20,0.3,10)),control=list(reltol=1e-5)) -> out
f(out$par)
f %>% summary()
f %>% spect() %>% plot()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.