StanLogDensityProblems

StanLogDensityProblems implements the LogDensityProblems API for Stan models using BridgeStan. For easily benchmarking inference algorithms, StanLogDensityProblems also integrates with PosteriorDB.

StanLogDensityProblems.StanProblemType
StanProblem(model::BridgeStan.StanModel; nan_on_error::Bool=false)

A wrapper for an unconstrained Stan model with data, implementing the LogDensityProblems interface.

If nan_on_error=true, then any errors from Stan will be suppressed, and NaNs will be returned.

source
StanLogDensityProblems.StanProblemMethod
StanProblem(stan_file::String, data::String; nan_on_error::Bool=false, kwargs...)

Construct a BridgeStan.StanModel from a .stan file and wrap it as a StanProblem.

data should either be a string containing a JSON string literal or a path to a data file ending in .json. If necessary, the model is compiled.

Remaining kwargs are forwarded to BridgeStan.StanModel.

Note

By default, Stan does not compile the model with multithreading support. If this is needed, pass make_args=["STAN_THREADS=true"] to kwargs.

source
StanLogDensityProblems.StanProblemMethod
StanProblem(
    posterior::PosteriorDB.Posterior,
    path::AbstractString;
    nan_on_error::Bool=false,
    force::Bool=false,
    kwargs...,
)

Construct a StanProblem from the Stan model implementation and dataset corresponding to posterior.

The model file will be copied to path before compilation. force=true will first remove an existing file. However, if the original file has already been compiled in this directory, the new model will not be compiled.

source