synlik-class {synlik} | R Documentation |
synlik-class
Description
Basic class for simulation-based approximate inference using Synthetic Likelihood methods.
Usage
synlik(...)
Arguments
... |
See section "Slots". |
Slots
- param
Named vector of parameters used by
object@simulator
(numeric
).- simulator
Function that simulates from the model (
function
). It has to have prototypefun(param, nsim, extraArgs, ...)
. Ifsummaries()
is not specified thesimulator()
has output a matrix withnsim
rows, where each row is a vector of simulated statistics. Otherwise it can output any kind of object, and this output will be passed tosummaries()
.- summaries
Function that transforms simulated data into summary statistics (
function
). It has to have prototypefun(x, extraArgs, ...)
and it has to output a matrix withnsim
rows, where each row is a vector of simulated statistics. Parameterx
contains the data.- data
Object containing the observed data or statistics (
ANY
).- extraArgs
List containing all the extra arguments to be passed to
object@simulator
andobject@summaries
(list
).- plotFun
Function that will be used to plot
object@data
. Prototype should befun(x, ...)
(function
).
Author(s)
Matteo Fasiolo <matteo.fasiolo@gmail.com>
References
Simon N Wood. Statistical inference for noisy nonlinear ecological dynamic systems. Nature, 466(7310):1102–1104, 2010.
Examples
#### Create Object
ricker_sl <- synlik(simulator = rickerSimul,
summaries = rickerStats,
param = c( logR = 3.8, logSigma = log(0.3), logPhi = log(10) ),
extraArgs = list("nObs" = 50, "nBurn" = 50),
plotFun = function(input, ...)
plot(drop(input), type = 'l', ylab = "Pop", xlab = "Time", ...)
)
# Simulate from the object
ricker_sl@data <- simulate(ricker_sl)
ricker_sl@extraArgs$obsData <- ricker_sl@data # Needed by WOOD2010 statistics
plot(ricker_sl)