This is from my textbook, I was wondering why the last equation hold?
I got $$\begin{aligned} p(y|M_i)& =\int p(y,\theta_i|M_i)d\theta_i\\ & =\int \frac{p(y,\theta_i,M_i)}{p(M_i)}d\theta_i\\ & =\int \frac{p(y,\theta_i,M_i)}{p(\theta_i,M_i)}\frac{p(\theta_i,M_i)}{p(M_i)}d\theta_i\\ &=\int p(y|\theta_i,M_i)p(\theta_i|M_i)d\theta_i \end{aligned}$$
Many thanks~

The correct series of equations can be obtained in a more direct way.
\begin{equation} \begin{aligned} p(y \mid M_i) & = \int p(y, \theta_i \mid M_i) d\theta \text{ by marginalizing} \\ & = \int p(p, \mid M_i, \theta_i) p(\theta_i \mid M_i) d\theta_i \text{ by factoring pdf} \\ \end{aligned} \end{equation}
The last step is justified in general because $ p(x, y \mid z) = p(x \mid y, z)p(y \mid z) $, where $ x, y, z $ are allowed to be vectors (and in particular, $ z $ can be empty).