sampleposterior {NeuralEstimators} | R Documentation |
sampleposterior
Description
Given data Z
, a neural likelihood-to-evidence-ratio estimator
, and a prior
, draws samples from the implied approximate posterior distribution
Currently, the sampling algorithm is based on a fine-gridding theta_grid
of the parameter space. The approximate posterior density is evaluated over this grid, which is then used to draw samples. This is very effective when making inference with a small number of parameters. For models with a large number of parameters, other sampling algorithms may be needed (please feel free to contact the package maintainer for discussion).
Usage
sampleposterior(
estimator,
Z,
theta_grid,
N = 1000,
prior = NULL,
use_gpu = TRUE
)
Arguments
estimator |
a neural likelihood-to-evidence-ratio estimator |
Z |
data; it's format should be amenable to the architecture of |
theta_grid |
a (fine) gridding of the parameter space, given as a matrix with p rows, where p is the number of parameters in the model |
N |
number of samples to draw (default 1000) |
prior |
the prior (default uniform), specified as a Julia or R function |
use_gpu |
a boolean indicating whether to use the GPU if it is available (default true) |
Value
a p × N
matrix of posterior samples, where p is the number of parameters in the model. If multiple data sets are given in Z
, a list of posterior samples will be returned