Description Usage Arguments Details See Also Examples
View source: R/simcases-simulate.R
Simulate data from various models. Results are saved to disk.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | smc_simulate(
models = models,
code = "",
constants = nlist::nlist(),
parameters = nlist::nlist(),
monitor = ".*",
stochastic = NA,
latent = NA,
nsims = 1,
path = ".",
exists = FALSE,
rdists = sims_rdists(),
ask = getOption("sims.ask", TRUE),
silent = FALSE,
environment = parent.frame(),
fun = function(x) read.table(text = gsub(";|,| |:|\t|\\||&|~", "\t",
readLines(textConnection(x))), header = TRUE),
...
)
|
models |
A data frame or an object that becomes a data frame when |
code |
A string of the JAGS or R code to generate the data. The JAGS code must not be in a data or model block. |
constants |
An nlist object (or list that can be coerced to nlist) specifying the values of nodes in code. The values are included in the output dataset. |
parameters |
An nlist object (or list that can be coerced to nlist) specifying the values of nodes in code. The values are not included in the output dataset. |
monitor |
A character vector (or regular expression if a string) specifying the names of the nodes in code to include in the dataset. By default all nodes are included. |
stochastic |
A logical scalar specifying whether to monitor deterministic and stochastic (NA), only deterministic (FALSE) or only stochastic nodes (TRUE). |
latent |
A logical scalar specifying whether to monitor observed and latent (NA), only latent (TRUE) or only observed nodes (FALSE). |
nsims |
A whole number between 1 and 1,000,000 specifying the number of data sets to simulate. By default 100 data sets are simulated. |
path |
A string specifying the path to the directory to save the data sets in. |
exists |
A flag specifying whether the 'path' directory should already exist (if ‘exists = NA' it doesn’t matter). |
rdists |
A character vector specifying the R functions to recognize as stochastic. The seed should be specified using [base::set.seed()]. |
ask |
A flag specifying whether to ask before deleting sims compatible files. |
silent |
A flag specifying whether to suppress warnings. |
environment |
The environment in which the objects described in |
fun |
A function to convert |
... |
Unused. |
The arguments code
, constants
, parameters
, monitor
, stochastic
, latent
and nsims
will only be used if not specified within models
.
[sims::simulate()]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | normal <- "a ~ dnorm(0, 1/sigma^2)"
sigma1 <- list(sigma=1)
sigma2 <- list(sigma=2)
smc_simulate("code parameters,
normal sigma1
normal sigma2",
path = tempdir(),
exists = NA,
ask = FALSE)
smc_simulate(tibble::tribble(
~code, ~parameters,
"normal", "sigma1",
"normal", "sigma2"),
fun = identity,
path = tempdir(),
exists = NA,
ask = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.