# Mediation analysis: When does the total effect exactly equal direct effect + indirect effect?

Typically in mediation analyses we see diagrams like the following, in which X is the causal variable, Y is the outcome variable, and M is the mediating variable. Meanwhile path c is called the total effect, path c' is called the direct effect, and path ab is called the indirect effect.

The equation c = c' + ab is often mentioned. When does it exactly hold?

The equation of c = c' + ab exactly holds when a) multiple regression (or structural equation modeling without latent variables) is used, b) the same cases are used in all the analyses, c) and the same covariates are in all the equations. However, the two are only approximately equal for multilevel models, logistic analysis and structural equation modeling with latent variables.
I'll welcome, and will accept, an answer that improves on this explanation, e.g. by discussing why these conditions are necessary for c'+ab to exactly equal c, and why they're only approximately equal for multilevel models, logistic analysis and structural equation modeling with latent variables.