How does the dsum sampler actually work?

  • VelocideX

    VelocideX - 2014-05-01

    Martyn or anyone else - your help greatly appreciated...

    I am trying to understand how the dsum sampler works on a fundamental basis.

    If you have C = A + B, then Bayes theorem gives that P(C|Data) ~ P(Data|C).P(C)

    If you happen to know the functional form then you can calculate some of this via convolutions. Eg if A and B are both normal then C is also normal. P(C) can then be calculated and you can sample C.

    But then you have to apportion C into A and B in a way which is consistent with P(A) and P(B). From Bayes theorem, P(A,B|C) ~ P(C|A,B).P(A).P(B) (I have assumed here for simplicity that A and B are independent). Sampling A and B simultaneously requires you to sample from the joint distribution which is not simple even for the normal-normal case.

    Alternatively, you can do Gibbs sampling, given a value of A given B and C, and then get a value of B given A and C, etc, but this is inefficient and my understanding is that this is precisely what dsum is trying to avoid (otherwise you'd just specify your model in JAGS code as normal and not worry about any of this).

    Is there some simple trick for getting from a sample of C to samples of A and B that are consistent with P(A) and P(B)?

    JAGS seems to be able to deal with real variables without knowledge of the actual functional form. How does it do this?

    Many thanks

  • Martyn Plummer

    Martyn Plummer - 2014-05-05

    With the dsum sampler you are taking a 1-dimensional slice through a 2-dimensional distribution. If you have joint density p(A,B) and apply the constraint A+B=C (via dsum) with C observed, then the density of A is proportional to p(A, C-A). So we sample A from this density (with slice sampling) and set B = C - A.

    If C is not observed, then JAGS defines C as a deterministc node.

  • VelocideX

    VelocideX - 2014-05-05

    Thanks Martyn, that's exactly what I need


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks