PyMC observed data for a sum of random variables

I am trying to derive model parameters using PyMC. In particular, the observed data are modeled as the sum of two different random variables: negative binomial and Poisson.

In PyMC, the algebraic composition of random variables is described by a "deterministic" object. Is it possible to assign observable data to this deterministic object?

If this is not possible, we still know that the PDF sum of the sum is a convolution of the PDF components. Is there any trick to efficiently calculate this convolution?

+4
source share
1 answer

deterministic node PyMC2, , . :

def model(values):
    # priors for model parameters
    mu_A = pm.Exponential('mu_A', beta=1, value=1)
    alpha_A = pm.Exponential('alpha_A', beta=1, value=1)
    mu_B_minus_A = pm.Uninformative('mu_B_minus_A', value=1)

    # latent variable for negative binomial
    A = pm.NegativeBinomial('A', mu=mu_A, alpha=alpha_A, value=0)

    # observed variable for conditional poisson
    B = pm.Poisson('B', mu=mu_B_minus_A+A, value=values, observed=True)

    return locals()

, . , . , NB , , .

+5

All Articles