The function runs simulations of the user-defined statistical model either for a single parameter or a list of parameters.
simQLdata(sim, ..., nsim, X = NULL, mode = c("list", "matrix", "mean"),
cl = NULL, iseed = NULL, na.rm = getOption("na.rm", TRUE),
verbose = FALSE)
user supplied simulation function
arguments passed to `sim
`
number of simulation replications at each parameter
list or matrix of model parameters
type of return value: "list
", "matrix
", "mean
"
cluster object, NULL
(default), of class MPIcluster
, SOCKcluster
, cluster
integer seed for initializing the cluster workers
whether to remove NA
values from simulation results
if TRUE
, then print intermediate output
List of (aggregated) simulation results of class simQL
and the following attributes:
matrix of sample points (equal to `X
` if supplied) or the result of multiDimLHS
number of simulation runs at each parameter
an integer seed value to initialize cluster workers
only in case of errors detected in simulation function
Basically, the given simulation function `sim
` is called for each parameter value
`nsim
` times and the results are returned depending on the chosen type `mode
`.
If `X
` is NULL
(default), then the design, that is, the matrix of sample points, is first generated
by multiDimLHS
and the result is stored as an attribute named `X
`. In this case, the arguments
`N
`,`bounds
` and `method
` must be given as named input arguments as required by multiDimLHS
.
In case of catched errors, the function tries to omit the corresponding simulation runs from the final results if possible.
Depending on the complexity of the model simulations we strongly encourage the use of a cluster object `cl
`. Make sure
to export all functions to the cluster environment beforehand which are required by the user-defined simulation function.
Also, using the option `qle.cache
` caches results of a function call to be stored in the current working directory.
The filename is generated by a hash code using the digest
package. Setting an integer seed iseed
before
stores each result in a separate file and makes the data reproducible while loading the data again.
# NOT RUN {
# generate design points, simulate and return the sample means
sim <- simQLdata(sim=function(x) rlnorm(1,x[1],x[2]),
nsim=10,N=8, method="maximinLHS",
lb=c(-1.5,0),ub=c(2,1), mode="mean")
# }
Run the code above in your browser using DataLab