Description Usage Arguments Value Examples
View source: R/simcases-evaluate.R
Calculates measures to evaluate the performance of the model The results are compared with the true parameter values by calculating performance measures such as bias, mean square error and coverage probability. R code can be used to customize the performance measures
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | smc_evaluate(
cases,
setup = NULL,
measures = c("bias", "mse", "cpQuantile"),
estimator = mean,
alpha = 0.05,
parameters = NULL,
monitor = ".*",
custom_funs = list(),
custom_expr_before = "",
custom_expr_after = "",
path = ".",
progress = FALSE,
options = furrr::future_options(),
environment = parent.frame(),
fun = function(x) read.table(text = gsub(";|,| |:|\t|\\||&|~", "\t",
readLines(textConnection(x))), header = TRUE),
...
)
|
cases |
An object that becomes a data frame when |
setup |
An object that becomes a data frame when |
measures |
A vector of strings indicating which performance measures to calculate. Strings may include "bias", "E" (expectation),
"cpQuantile" (coverage probability of quantile-based CrIs of level |
estimator |
A function, typically mean or median, for the Bayes estimator to use to calculate the performance measures. |
alpha |
Scalar representing the alpha level used to construct credible intervals. Default is 0.05. |
parameters |
An nlist object (or list that can be coerced to nlist). True values of parameters to be used to calculate the performance measures. |
monitor |
A character vector (or regular expression if a string) specifying the names of the stochastic nodes in code to include in the summary. By default all stochastic nodes are included. |
custom_funs |
A named list of functions to calculate over the mcmc samples. E.g. list(posteriormedian = median). |
custom_expr_before |
A string of R code to derive custom measures.
This code is used BEFORE averaging over all simulations.
E.g. "mse = (posteriormedian - parameters)^2".
Functions from |
custom_expr_after |
A string of R code to derive additional custom measures.
This code is used AFTER averaging over all simulations. E.g. "rmse = sqrt(mse)".
Measures calculated from |
path |
A string specifying the path to the directory. |
progress |
A flag specifying whether to print a progress bar. |
options |
The future specific options to use with the workers. |
environment |
The environment in which the objects described in |
fun |
A function to convert |
... |
Unused |
A flag.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | normal <- "a ~ dnorm(0, 1/sigma^2)"
sigma1 <- list(sigma=1)
sigma2 <- list(sigma=2)
models_sims <- "code parameters
normal sigma1
normal sigma2"
smc_simulate(models = models_sims,
path = tempdir(),
exists = NA,
ask = FALSE,
nsims = 2)
prior1 = "sigma ~ dunif(0, 4)"
prior2 = "sigma ~ dunif(0, 5)"
models_analysis <- "code code.add
normal prior1
normal prior2"
cases <- "sims analyse
1 1
2 2"
smc_analyse(models = models_analysis,
cases = cases,
path = tempdir())
setup = "parameters
sigma1
sigma2"
smc_evaluate(cases, setup, path = tempdir(), monitor="sigma")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.