#Example with JOBS II Field experiment
data(jobs)
#########################################
#Continuous mediator and continuous outcome
#########################################
#Fit parametric models
model.m <- lm(job_seek ~ treat + depress1, data=jobs)
model.y <- lm(depress2 ~ treat + job_seek + depress1, data=jobs)
#Pass model objects through mediate function
med.cont <- mediate(model.m, model.y, treat="treat", mediator="job_seek", sims=1000)
#Pass mediate output through medsens function
sens.cont <- medsens(med.cont, sims=1000, rho.by=.1)
#Use summary function to display values of rho where 95summary(sens.cont)
#Plot mediation effect and 95plot(sens.cont, main="JOBS", ylim=c(-.2,.2))
#Plot sensitivity analysis using R^2 method. See plot.medsens for additional detail
plot(sens.cont, sens.par="R2", r.type=2, sign.prod=1)
Run the code above in your browser using DataLab