brian-j-smith / Mamba.jl

Markov chain Monte Carlo (MCMC) for Bayesian analysis in julia
Other
253 stars 52 forks source link

ABC Model that has an unknown distribution #162

Closed GantZA closed 4 years ago

GantZA commented 4 years ago

I am unsure of how to setup an ABC model where I don't know the quantile or distribution of the node.

I have a model which returns an Array{Float64, 2} data type and takes in 5 parameters. I have prior distributions for the parameters but I don't have any distribution for the output of the model. Below is the basic idea of what I have set as the Model()

model = Model(
  price_path = Stochastic(2 ,(D, σ, nu, α, μ) -> SLOB_MODEL(D, σ, nu, α, μ),
    false),
  D = Stochastic(() -> Uniform(0.125, 3.0)),
  σ = Stochastic(() -> Uniform(0.01, 2.0)),
  nu = Stochastic(() -> Uniform(0.01, 0.95)),
  α = Stochastic(() -> Uniform(5.0, 500.0)),
  μ = Stochastic(() -> Uniform(0.01, 0.1)),
)

I have used the extension = quotes... block to create the SLOB_MODEL struct which "inherits" from the ContinuousMultivariateDistribution. Is this how I should be defining the SLOB_MODEL? I have looked at the documentation, and it says that I need to provide the following methods: length, insupport and _logpdf. But I can't give a _logpdf value as I don't know the distribution. Additionally, in the GK example, there doesn't seem to be a _logpdf method defined

Maybe I'm not meant to be using the Stochastic node type for price_path? It is a non-deterministic function though which can be controlled through a seed variable if this helps?

bdeonovic commented 4 years ago

The ABC sampler needs to be able to simulate values from your distribution. So you need be able to call rand(SLOB_MODEL(D, σ, nu, α, μ)) and get a correct draw from the distribution.

As a fallback the Distributions package will utilize inverse transform sampling which only requires the quantile function of a random variable to be defined in order to sample from it. You do not have to use this, as long as you can sample from your distribution in some other way.

GantZA commented 4 years ago

Sorry for such a late reply, I finally got around to implementing the "rand" fix and it's working now! Thank you for the help