The S4 class contains the simulation and summary statistics function and other necessary arguments
for a model to run in the main bsl
function.
BSLModel
is the constructor function for a BSLMODEL
object.
initialize.BSLMODEL
initialises a ``BSLMODEL'' object.
validBSLModelObject
check the validity of a ``BSLMODEL'' object.
BSLModel(fnSim, fnSimVec, fnSum, fnLogPrior, simArgs, sumArgs, theta0,
thetaNames, test = TRUE)initialize.BSLMODEL(.Object, fnSim, fnSimVec, simArgs, fnSum, sumArgs,
fnLogPrior, theta0, thetaNames, test = TRUE)
validBSLModelObject(object)
# S4 method for BSLMODEL
fn(.Object)
# S4 method for BSLMODEL
setns(.Object)
A function that simulates data for a given parameter value. The first argument should be the
parameters. Other necessary arguments (optional) can be specified with simArgs
.
A vectorised function that simulates a number of datasets simultaneously for a given parameter
value. The first two arguments should be the number of simulations to run and parameters, respectively. Other necessary
arguments (optional) can be specified with simArgs
. The output must be a list of each simulation result.
A function for computing summary statistics of data. The first argument should be the observed
or simulated dataset. Other necessary arguments (optional) can be specified with sumArgs
.
A function that computes the log of prior density for a parameter. If this is missing, the prior by default is an improper flat prior over the real line for each parameter. The function must have a single input: a vector of parameter values.
A list of additional arguments to pass into the simulation function. Only use when the input
fnSim
requires additional arguments.
A list of additional arguments to pass into the summary statistics function. Only use when the
input fnSum
requires additional arguments.
Initial guess of the parameter value.
A string vector of parameter names, which must have the same length as the parameter vector.
Logical, whether a short simulation test will be ran upon initialisation.
A ``BSLMODEL'' object.
A ``BSLMODEL'' object.
fn
: Generate the generic simulation and summary statistics function for n
simulations and fixed theta
(for internal use).
setns
: Find and set the length of summary statistics with a test run (for internal use).
fnSim
A function that simulates data for a given parameter value. The first argument should be the
parameters. Other necessary arguments (optional) can be specified with simArgs
.
fnSimVec
A vectorised function that simulates a number of datasets simultaneously for a given parameter
value. If this is not NULL
, vectorised simulation function will be used instead of fnSim
. The
first two arguments should be the number of simulations to run and parameters, respectively. Other necessary
arguments (optional) can be specified with simArgs
. The output must be a list of each simulation result.
fnSum
A function for computing summary statistics of data. The first argument should be the observed
or simulated dataset. Other necessary arguments (optional) can be specified with sumArgs
. The users
should code this function carefully so the output have fixed length and never contain any Inf
value.
fnLogPrior
A function that computes the log of prior density for a parameter. The default is NULL
,
which uses an improper flat prior over the real line for each parameter. The function must have a single input: a
vector of parameter values.
simArgs
A list of additional arguments to pass into the simulation function. Only use when the input
fnSim
or fnSimVec
requires additional arguments. The default is NULL
.
sumArgs
A list of additional arguments to pass into the summary statistics function. Only use when the
input fnSum
requires additional arguments. The default is NULL
.
theta0
Initial guess of the parameter value, which is used as the starting value for MCMC.
thetaNames
Expression, parameter names.
ns
The number of summary statistics of a single observation. Note this will be generated automatically, thus is not required for initialisation.
test
Logical indicator of whether a short simulation test will be ran upon initialisation.
# NOT RUN {
data(ma2)
model <- BSLModel(fnSim = ma2_sim, fnSum = ma2_sum, simArgs = ma2$sim_options, theta0 = ma2$start,
fnLogPrior = ma2_logPrior)
validObject(model)
# }
Run the code above in your browser using DataLab