# Bayes factor from posterior odds

I tried to answer my own question Comparing two Bayesian models under disjoint prior supports using MCMC. Here is my intent. I am not confident in what I wrote so prefer to post it as a question : Is this a correct way to compute Bayes factor ?

I would like to compute the Bayes factor: $$K = \frac{P(x|H_1)}{P(x|H_2)} =\frac{P(H_1|x)}{P(H_2|x)} \frac{P(H_2)}{P(H_1)}$$

I have a model consisting of three parameters $\theta_1$, $\theta_2$ and $\theta_3$. $H_1$ is $\{(\theta_1,\theta_2,\theta_3) \in [m,M]^3 \mbox{ such that } \theta_1<\theta_2<\theta_3\}$, $H_2$ is it complementary. Then suppose that I have a model to infer $P(\theta_1,\theta_2,\theta_3 | x)$ under the complete parameter space $H_1 \cup H_2$ then $P(H_1|x)$ can simply be computed as: $$P(H_1|x)=\int_m^M P(\theta_1,\theta_2,\theta_3|x) 1_{\theta_1>\theta_2>\theta_3}(\theta_1,\theta_2,\theta_3) d\theta_1 d\theta_2 d\theta_3$$ by simply counting the posterior MCMC samples satisfying the condition and $P(H_2|x)=1-P(H_1|x)$.

So it remains to extract the associated $\frac{P(H_2)}{P(H_1)}$ by simply considering the subpart of $H_1$ over the overall parameter space: $$P(H_1)=\int p(\theta_1,\theta_2,\theta_3) \cdot 1_{\theta_1>\theta_2>\theta_3}(\theta_1,\theta_2,\theta_3) d\theta_1 d\theta_2 d\theta_3$$ which can be computed analytically for the prior $p(\theta_1,\theta_2,\theta_3)$ associated to my posterior and again $P(H_2)=1-p(H_1)$.

Is this a correct way to compute Bayes factor ? If yes, is this method has a name?

This is a correct approach indeed, since you compare two subsets of the parameter space after selected a prior for the entire parameter set. This prior indeed defines single-handedly prior weights on both subsets $H_0$ and $H_1$, which can be computed by integration. (If the three parameters are exchangeable, the prior weight of $H_0$ is $1/3!$.)