StanLogDensityProblems
StanLogDensityProblems implements the LogDensityProblems API for Stan models using BridgeStan. For easily benchmarking inference algorithms, StanLogDensityProblems also integrates with PosteriorDB.
StanLogDensityProblems.StanProblem
— TypeStanProblem(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 NaN
s will be returned.
StanLogDensityProblems.StanProblem
— MethodStanProblem(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
.
By default, Stan does not compile the model with multithreading support. If this is needed, pass make_args=["STAN_THREADS=true"]
to kwargs
.
StanLogDensityProblems.StanProblem
— MethodStanProblem(
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.