Analysing the mediating role of a network: a Bayesian latent space approach