This creates a closure that simulates the model, similar to simulator.c
simfi.RdThis is a shorter alternative to simulator.c (C backend). It also returns the log-likelihood, Fisher Information, and the gradient of the log-likelihood, under the assumption that the measurement error is Gaussian. No attempt is made to parallelize this call, all simulations will be done in sequence.
Arguments
- experiments
a list of experiments to simulate: inital values, inputs, time vectors, initial times
- odeModel
Either the ode object created by as_ode (with a shared library field inserted), or a string (with a comment indicating an .so file) which points out the model to simulate
- parMap
the model will be called with parMap(parABC); so any parameter transformation can happen there.
- method
the integration method as an integer (higher numbers are simpler methods, lower numbers are more advanced methods, 0 maps to 'msbdf')
- omit
integer, omit optional return values, in this order: Fisher Information, gradient of the log-likelihood, the log-likelihood, output functions. Omission includes all previous entries.
omit = 1omits only the Fisher Information,omit=3, omits FI, grad-ll, and log-likelihood calculations.- time.out
(in seconds); simulations are aborted at a time greater than this.
- parABC
the parameters for the model, subject to change by parMap.
Value
a closure that returns the model's output for a given parameter vector, and approximate sensitivity matrices, for each state variable, function, time-point, and parameter vector.
Details
It returns a closure around: - experiments, - the model, and - parameter mapping
The returned function depends only on parABC (the sampling parameters). The simulation will be done suing the rgsl backend.
This version of the function does not use the parallel package at all and cannot add noise to the simulations (unlike simulator.c).
Examples
# \donttest{
f <- uqsa_example("AKAR4")
m <- model_from_tsv(f)
o <- as_ode(m)
ex <- experiments(m,o)
C <- generateCode(o)
#> Error in generateCode(o): could not find function "generateCode"
## as an alternative to the uqsa functions, we can use R builtins as well:
c.file <- tempfile("AKAR4_",fileext=".c")
cat(C,sep='\n',file=c.file)
#> Error in cat(C, sep = "\n", file = c.file): argument 1 (type 'closure') cannot be handled by 'cat'
so.file <- shlib(c.file)
s <- simfi(ex,c("AKAR4",so.file))
y <- s(values(m$Parameter)) # simulates
#> experiments(3) should be the same length as simulations(0), but isn't.
#> Error in class(yf) <- "simulation": attempt to set an attribute on NULL
# }