570 likes | 1.14k Views
Using SPSS and R for Mediation Analyses. Matt Baldwin Lucas Keefer. We will cover…. Simple and simultaneous mediation Sequential mediation Moderated mediation Three models using PROCESS for SPSS R-code for those models MAYBE: Monte-Carlo estimator online. Terms. M. b. a. Y. X. c’.
E N D
Using SPSS and R for Mediation Analyses Matt Baldwin Lucas Keefer
We will cover… • Simple and simultaneous mediation • Sequential mediation • Moderated mediation • Three models using PROCESS for SPSS • R-code for those models • MAYBE: Monte-Carlo estimator online
Terms M b a Y X c’ Indirect effect: a * b ≠ 0
Terms • Simple mediation • One predictor • One outcome • One or more mediators in parallel • Sequential mediation • One predictor • One outcome • More than one mediator in sequence
Terms • Moderated mediation: strength of indirect effect depends on one or more moderators • One predictor • One outcome • One or more mediators (not in sequence) • One or more moderators • Bootstrapping: estimating a parameter from repeated resampling of the data • Approximates sampling distribution • Uses standard error to calculate confidence interval for indirect effect (a*b)
PROCESS: SPSS • Andrew Hayes, Ph.D. • http://afhayes.com/introduction-to-mediation-moderation-and-conditional-process-analysis.html
PROCESS: Models • Templates PDF file: templates.pdf
Model 4 • Simple mediation • Multiple mediators in parallel
Model 4 Output • Remember, if the confidence interval does NOT include zero, the indirect effect is significant!
Model 6 • Sequential mediation • Multiple mediators in sequence
Model 7 • Moderated mediation • Multiple mediators in parallel
The boot package • Install the boot package and dependencies • What does it do?
Data • Whatever object contains the data you are analyzing • If there are filters to apply, do so beforehand: • med_data <- subset(data, filters)
Model • The model must be specified manually: • mediation<-function(med_data,i){ • d <- med_data[i,] • model1<- lm(M~X, data=d) • model2<-lm(Y~M+X, data=d) • ab <- coef(model1)[2]*coef(model2)[2] • return(as.numeric(ab)) • }
Model • The model must be specified manually: • mediation<-function(med_data,i){ • d <- med_data[i,] • model1<- lm(M~X, data=d) • model2<-lm(Y~M+X, data=d) • ab <- coef(model1)[2]*coef(model2)[2] • return(as.numeric(ab)) • }
Model • The model must be specified manually: • mediation<-function(med_data,i){ • d <- med_data[i,] • model1<- lm(M~X, data=d) • model2<-lm(Y~M+X, data=d) • ab <- coef(model1)[2]*coef(model2)[2] • return(as.numeric(ab)) • }
Model • The model must be specified manually: • mediation<-function(med_data,i){ • d <- med_data[i,] • model1<- lm(M~X, data=d) • model2<-lm(Y~M+X, data=d) • ab <- coef(model1)[2]*coef(model2)[2] • return(as.numeric(ab)) • }
Model • The model must be specified manually: • mediation<-function(med_data,i){ • d <- med_data[i,] • model1<- lm(M~X, data=d) • model2<-lm(Y~M+X, data=d) • ab <- coef(model1)[2]*coef(model2)[2] • return(as.numeric(ab)) • }
Model • The model must be specified manually: • mediation<-function(med_data,i){ • d <- med_data[i,] • model1<- lm(M~X, data=d) • model2<-lm(Y~M+X, data=d) • ab <- coef(model1)[2]*coef(model2)[2] • return(as.numeric(ab)) • }
Simple Mediation • mediation<-function(med_data,i){ • d <- med_data[i,] • model1<- lm(M~X, data=d) • model2<-lm(Y~M+X, data=d) • ab <- coef(model1)[2]*coef(model2)[2] • return(as.numeric(ab)) • }
Simple Mediation • boot(model, data, R = #) • obj <- boot(mediation, med_data, R = 10000) • boot.ci(obj)
Moderated Mediation • mediation<-function(med_data,i){ • d <- med_data[i,] • model1<- lm(M~X+W+WX, data=d) • model2<-lm(Y~M+X, data=d) • ab <- coef(model1)[2]*coef(model2)[2] • return(as.numeric(ab)) • }
Sequential Mediation • mediation<-function(med_data,i){ • d <- med_data[i,] • model1<- lm(M1~X, data=d) • model2<-lm(M2~M1+X, data=d) • model3<-lm(Y~M2+M1+X, data=d) • ab <- coef(model1)[2]*coef(model2)[2]* coef(model3)[2] • return(as.numeric(ab)) • }
Final Pointers • Want to add model covariates? Just add them into all the model commands (NOT as first predictor)
Final Pointers • Want to add model covariates? Just add them into all the model commands (NOT as first predictor) • Because you are specifying the model manually, triple check your work!
Final Pointers • Want to add model covariates? Just add them into all the model commands (NOT as first predictor) • Because you are specifying the model manually, triple check your work! • It won’t catch misspecification
Final Pointers • Want to add model covariates? Just add them into all the model commands (NOT as first predictor) • Because you are specifying the model manually, triple check your work! • It won’t catch misspecification • Make sure it is storing the right coefficient
Monte-Carlo Estimator • Similar to bootstrapping method • Calculates indirect effect from a, b, and standard error • http://www.quantpsy.org/medmc/medmc.htm
Thank You • Please feel free to ask us questions now or later! • Matt’s email: mwbaldwin@ku.edu • Lucas’ email: lkeefer1@ku.edu • These slides can be found at http://matthewbaldwin.yolasite.com/tools.php