A compound likelihood


I am working on a model that has a likelihood which can be decomposed as follows:

Likelihood = \Pi f(a). \Pi g(b)

where a and b are vectors of data.

Can you implement in greta using two distribution statements as follows:

distribution (a) = some function
distribution (b) = some other function



Hi Howard,

Just some thoughts I had reading your question:

  1. You can definitely have multiple distribution(.)<- calls in one model, but I’m not 100% sure if that would give you your desired multiplicative effect in the overall likelihood.

  2. To the best of my knowledge you can’t assign distributions from arbitrary functions; they have to be one of the standard distributions Greta exports as a special distribution node/object.

All the best!


Thanks! Yes - I would be using a standard Greta distribution function on the right hand side.


Hi Howard,

I think I have found a better solutions! We can make use of the joint function which allows users to combine two or more different distributions into a single likelihood.

For example: if we assume that vector a is length 10 and each element is distributed \sim N(\mu_1, 1) and vector b is length 10 and each element is distributed \sim N(\mu_2, 1) we could have a model like:

mu_1 <- normal(0, 100)
mu_2 <- normal(0, 100)
x <- cbind(rnorm(10, 10, 1), rnorm(10, 2, 1))
distribution(x) <- joint(normal(mu_1, 1, dim = 10), normal(mu_2, 1, dim = 10))


  1. The use of cbind ensures that the data has the same dimensions as the collections of variables produced by joint.
  2. When we extend the distributions with dim all the variables are independent

After reading the documentation for joint I am confident that this will definitely give you the likelihood you want.

All the best!


Yup, and just for clarity, that joint() code is doing the same thing as:

distribution(x[, 1]) <- normal(mu_1, 1, dim = 10)
distribution(x[, 2]) <-  normal(mu_2, 1, dim = 10)

But it’s included for convenience when working with things like mixture models, and HMMs (which I’m planning to implement in an extension package soon).