Started code for functional mediation in R