Modeling heterogeneous causal mechanisms in epidemiology with observational data