Please also provide the following information in addition to your question:
- Operating System: linux
- brms Version: 2.8.0
I’m doing some simulations using the ddirichlet function.
I was expecting the result would be a probability, but I sometimes get values that are greater than 1?
What have I misunderstood?
ddirichlet(c(1/3, 1/3, 1/3), c(1,1,1)) == 2
Do I need to transform the result to get a probability?
I think you are misunderstanding how ddirichlet works. The dirichlet prior is a continuous distribution on a vector of values. Each specific (vector) value, in your case (1/3, 1/3, 1/3) has probability zero (because it is a continuous distribution), but the density at this value may be any positive value. It just integrates to one over the whole (multidimensional) parameter space.
I’m still not sure I understand, perhaps it is the naming. I thought it was the ‘probability density’ function of the dirichlet distribution, just as dnorm, would be the probability density function for the normal distribution, and that the ‘area’ beneath the ‘curve’ would integrate to one, as you explained.
Maybe it is me not fully understanding the concept of a PDF in the multivariate case, but if densities are always positive, how can you get one when integration over the whole when certain densities are larger than one?
More importantly in my case, how would you interprete the density value that ddnorm produces? Would it be wrong to state that compositions with high density are more probable than compositions with lower density?
This basically comes down to understanding how probability works in the continuous case. That is as an integral over the parameter space (or a subset of it). I would expect that some online tutorials on that give you a better explanation than I can give you ad-hoc.
OK I will need to look it up :-)
However, would it be wrong to state that compositions with high density are more probable than compositions with lower density?
Spaces with high density are more probable than areas with low density (given the same volume of these spaces), but each single value has probablity zero under a continuous distribution.
Paul has already been very clear. But just to show that this is a feature of probability densities in general and not specific to the Dirichlet, here is the density of a narrow normal distribution:
curve(dnorm(x, 0, 0.2), from=-1, to=1)
If you integrate over
x, the area sums to one:
curve(pnorm(x, 0, 0.2), from=-1, to=1)