## You need to import this data into your R workspace using ## the following code simulated=read.csv("simulated.csv") #### Next we need to perform Step1 of mediation analysis s1=glm(simulated[,3]~simulated[,1],family=binomial) summary(s1) #### Next we perform Step2 as follows s2=glm(simulated[,2]~simulated[,1],family=binomial) summary(s2) ##### And step 3 s3=glm(simulated[,3]~simulated[,2],family=binomial) summary(s3) ##### Finally, if we find that all the coefficients returned above are statistically ##### significant we need to proceed to step 4 s4=glm(simulated[,3]~simulated[,2] + simulated[,1],family=binomial) summary(s4) #### We now compare "s1" to "s4" to verify mediation summary(s1) summary(s4) ###### As will be clear, the parameter was statistically significant in one ###### model (step1) but not in the other (step4).