Hypothesis testing via separate inference for each group and then combining Suppose there are two groups, A and B, and we are interested in inferring a certain parameter for each one and also the difference between the two parameters. Here we can take a Bayesian perspective and strive for a posterior distribution in each case. I am wondering if the following is a sound way of doing this:

*

*estimate the posterior for group A,

*estimate the posterior for group B, and

*estimate the posterior of the difference by sampling extensively the first two posteriors and taking the difference.

I am specifically unsure about this kind of divide-and-conquer approach where each group is treated separately, and then the results are combined. Usually, it is done in one take where, perhaps, a linear model is fitted with an indicator for the group membership.
Let me give a simple example. Say, the outcome is binary. One can then use a Bernoulli–beta model to infer the posterior of the success probability, which will be a beta distribution for each group. As the last step, one can sample the two betas and get a posterior for the difference.

Let $Y_A$ and $Y_B$ denote the datasets for groups $A$ and $B$. Similarly let $\theta_A$ and $\theta_B$ denote the corresponding parameters.
If the joint distribution factors,
\begin{equation}
p(Y_A,Y_B,\theta_A,\theta_B) = p(Y_A,\theta_A)\,p(Y_B,\theta_B) ,
\end{equation}
then the joint posterior factors,
\begin{equation}
p(\theta_A,\theta_B|Y_A,Y_B) = p(\theta_A|Y_A)\,p(\theta_B|Y_B) ,
\end{equation}
where
\begin{equation}
p(\theta_i|Y_i) = \frac{p(Y_i|\theta_i)\,p(\theta_i)}{p(Y_i)} 
\end{equation}
for $i \in \{A,B\}$.
The joint distribution will factor if the likelihood factors,
\begin{equation}
p(Y_A,Y_B|\theta_A,\theta_B) = p(Y_A|\theta_A)\,p(Y_B|\theta_B) ,
\end{equation}
and the prior factors,
\begin{equation}
p(\theta_A,\theta_B) = p(\theta_A)\,p(\theta_B) . 
\end{equation}
If these assumptions are reasonable, then the proposed procedure is fine.
