boot_jaatha: Parametric Bootstrapping of Jaatha Estimates

View source: R/boot_jaatha.R

boot_jaathaR Documentation

Parametric Bootstrapping of Jaatha Estimates

Description

This function is a helper function for using the boot function to bootstrap Jaatha estimates. Each bootstap replication requires a complete jaatha estimation on data simulated with the original parameter estimates. Therefore, bootstrapping is normally computationally demanding and should be executed on a computing cluster.

Usage

boot_jaatha(results, R, cores_per_run = 1, verbose = TRUE, ...)

Arguments

results

The results of an jaatha analysis.

R

The number of bootstrapping replicates that are performed.

cores_per_run

The number of cores that are used for each replicate. This corresponds to the cores option of jaatha. Different replicates can be executed in parallel using the parallel, ncpus and cl options of boot. The total number of CPU cores used is ncpus * cores_per_run.

verbose

If TRUE (default), each bootstrap estimation is written as a message.

...

Additional arguments that are passed on boot. It is highly recommended to use its parallel and ncpus options to parallelize the bootstrap replicates.

Value

The result of boot. This object can be used to estimate standard errors or confidence intervals of the estimates using the functions available in package boot. Note that the returned object contains a vector of parameter values t0 that is the result of an additional jaatha run for the original data, whereas the parametric bootstrap simulations used parameter values that are in the vector mle in the returned boot object. By default, the function boot.ci of the boot package uses the parameter values t0 as a reference point. To use the values in mle instead, overwrite t0 with mle before applying the function boot.ci.

See Also

boot, jaatha

Examples


# The original Jaatha anaylsis:
model <- create_jaatha_model(function(x) rpois(10, x),
                    par_ranges = matrix(c(0.1, 0.1, 10, 10), 2, 2),
                    sum_stats = list(create_jaatha_stat("sum", sum)))
data <- create_jaatha_data(rpois(10, 9), model)
jaatha_result <- jaatha(model, data, cores = 2)

# Bootstrapping the results using 2 CPU cores on localhost:
library(boot)
library(snow)
cl <- makeSOCKcluster(c("localhost", "localhost"))

jaatha_boot_results <- boot_jaatha(jaatha_result, 50, 
                                   cores_per_run = 2,
                                   parallel = "snow",
                                   cl = cl)

stopCluster(cl)
boot.ci(jaatha_boot_results, type = "norm")
jaatha_boot_results$t0 <- jaatha_boot_results$mle
boot.ci(jaatha_boot_results, type = "norm")



jaatha documentation built on March 31, 2023, 11:37 p.m.