Skip to contents

tp_treeppl executes TreePPL and returns the inference output (string JSON format).

Usage

tp_treeppl(
  model = NULL,
  model_file_name = "tmp_model_file",
  data = NULL,
  data_file_name = "tmp_data_file",
  compile_model = TRUE,
  samples = 1000,
  seed = NULL,
  n_runs = 1,
  method = "smc-bpf",
  align = FALSE,
  cps = "none",
  delay = NULL,
  kernel = NULL,
  mcmc_lw_gprob = NULL,
  pmcmc_particles = NULL,
  prune = FALSE,
  subsample = NULL,
  resample = NULL
)

Arguments

model

a TreePPL model (S3).

model_file_name

a string giving a name to the temporary model file.

data

a json object with all data needed for inference (S3).

data_file_name

a string giving a name to the temporary data file.

compile_model

a base::logical. Compile the model?

samples

a base::integer giving the number of samples (MCMC) / particles (SMC).

seed

a base::numeric to use as a random seed.

n_runs

a base::integer giving the number of runs (MCMC) / sweeps (SMC).

method

a string giving the inference method name.

align

a base::logical. Whether or not to align the model.

cps

a string giving the configuration of CPS transformation.

delay

a string giving the configuration of delayed sampling.

kernel

a base::numeric value giving the driftScale for driftKernel in MCMC.

mcmc_lw_gprob

a base::numeric probability of performing a global MCMC step.

pmcmc_particles

a base::integer number of particles for the SMC proposal computation.

prune

a base::logical. Whether or not to prune the model.

subsample

a base::integer number of draws to subsample from the posterior distribution.

resample

a string giving the selected resample placement method.

Value

TreePPL output in JSON format.

Details

This function takes a TreePPL object (the model) and a json object (the data), compiles the TreePPL model, runs it with the data and returns TreePPL output.

TreePPL has to be installed on your computer (see install manual). The executable and the output files will be written in R's base::tempdir.

model : A TreePPL model (S3), see tp_model for further details. Use 'NULL' if you have previously provided a model. Check already provided models with tp_stored_model.

model_file_name : a string given to tp_treeppl as a model name. Use a tp_stored_data name if you have already written your model with tp_treeppl.

data : A json object (S3), see tp_json for further details. Use 'NULL' if you have previously provided data. Check already provided data with tp_stored_data.

data_file_name : a string given to tp_treeppl as a data name. Use a tp_stored_data name if you have already written your data with tp_treeppl.

compile_model : a base::logical telling if the model needs to be compiled. Can be used to avoid compiling the same model again in R's base::tempdir. Check already compiled models with tp_stored_compiled.

samples : The number of samples (MCMC) / particles (SMC) during inference.

seed : The random seed to use. Using 'NULL' initializes it randomly.

n_runs : The number of runs (MCMC) / sweeps (SMC) used for the inference.

method : Inference method to be used. The supported methods are: is-lw, smc-bpf, smc-apf, mcmc-lightweight, mcmc-trace, mcmc-naive, pmcmc-pimh.

The following options are only applicable to certain methods:

align : Whether or not to align the model.

cps : Configuration of CPS transformation. The supported options are: none, partial, and full.

delay : The model is transformed to an efficient representation if possible. The supported options are: static or dynamic. Use 'NULL' to ignore.

kernel : The value of the driftScale for driftKernel in MCMC. Use 'NULL' to ignore. Use together with method mcmc-lightweight". Use 'NULL' to ignore.

mcmc_lw_gprob : The probability of performing a global MH step (non-global means only modify a single sample in the previous trace). Use together with method mcmc-lightweight". Use 'NULL' to ignore.

pmcmc_particles : The number of particles for the SMC proposal computation. This option is used if one of the following methods are used: pmcmc-*. Use 'NULL' to ignore.

prune : The model is pruned if possible.

subsample : The number of draws to subsample from the posterior distribution. Use together with method smc-apf or smc-bpf. Use 'NULL' to ignore.

resample: The selected resample placement method. The supported methods are: likelihood (resample immediately after all likelihood updates), align (resample after aligned likelihood updates, forces –align), and manual (sample only at manually defined resampling locations). Use 'NULL' to ignore.