I am working with a mediated-moderated model like that in Fig. 1. All variables in the model are continuous. The relations depicted by the dashed and solid lines were found to be statistically significant in separate regressions (i.e. reg Y M c.M#c.M X / reg M X c.X#c.E)

I am interested in the mediated relation X -> M -> Y. I tested this relation using SEM. Following the literature on mediation analysis (Preacher and Hayes, 2008; Zhao et al., 2010 see the references below), and given the relatively small sample I have, I used bootstrap to test it. The code I used is very similar to the one below:
Figure 1 - Model


Code:
capture program drop test
program test, rclass

sem (Y <- M Msq X) (M <- X XE)

* Mediated effect with moderator
return scalar ME_M = _b[M:X]*_b[Y:M] + _b[M:X]*_b[Y:Msq] + _b[M:XE]*_b[Y:M] + _b[M:XE]*_b[Y:Msq]

* Mediated effects without moderator
return scalar ME_NM = _b[M:X]*_b[Y:M] + _b[M:X]*_b[Y:Msq]

end

bootstrap r(ME_M) r(ME_NM) reps(5000) seed(1) nodots: test
At this point, after testing the existence of the mediated relation, I would like to plot it using marginsplot. And that’s where I have troubles. The reason I would like to plot this relation is to show that also the mediated relation (X -> M -> Y) is curvilinear, as is the relation between M -> Y. Since the latter relation (M -> Y) is a component of the mediated relation, I suspect (but I am not fully sure), that the whole mediated relation (X -> M -> Y) is itself curvilinear. Not only would I like to draw this relation, but I would also like to draw it at two different levels of the moderator E (i.e. E’ and E’’), as shown in Fig. 2. However, I would like to do so without imposing levels of the mediator (M) – that is, I would like the mediator to take values it really takes in the sample (I hope it’s clear what I mean with this last statement). To complicate things further, if I want to plot CIs I may need to obtain them using some kind of boostrap procedure to be coherent with the rest of the analysis. And that’s where I get lost.
Figure 2 - Plot mediated relation


I would be really grateful if anyone could help me accomplish this. …and perhaps suggest other tests that might be relevant to explore the shape of the mediated relation and how the mediated relation changes as a function of the moderator.

Many thanks,
Riccardo


References

Preacher, K. J., & Hayes, A. F. (2004). SPSS and SAS procedures for estimating indirect effects in simple mediation models. Behavior research methods, instruments, & computers, 36(4), 717-731.

Zhao, X., Lynch Jr, J. G., & Chen, Q. (2010). Reconsidering Baron and Kenny: Myths and truths about mediation analysis. Journal of consumer research, 37(2), 197-206.