Compile and run a TreePPL program
Arguments
- dir
The directory that contains the TreePPL code and input file. The executable and the output files will be written here.
- source
Name of file with TreePPL program.
- method
Inference method to be used.
- data
Name of object with input data.
- samples
The number of samples during inference.
Value
A data frame with sampled values, log weights, normalized weights, and the normalizing constant for all samples.
Examples
if (FALSE) {
coinflips <- tibble(coinflips = sample(c(TRUE, FALSE), 20, replace = TRUE))
output <- run_treeppl(dir = system.file("extdata", package = "treepplr"),
source = "coin.tppl", data = coinflips, samples = 10)
if(rlang::is_installed("ggplot2")) {
ggplot2::ggplot(output) +
ggplot2::geom_col(ggplot2::aes(.data$samples, .data$nweights), width = 0.005) +
ggplot2::theme_bw()
}
}