Using SPSS and R for Mediation Analyses Matt Baldwin Lucas Keefer.

Post on 22-Dec-2015

213 views 0 download

Tags:

Transcript of Using SPSS and R for Mediation Analyses Matt Baldwin Lucas Keefer.

Using SPSS and R for Mediation Analyses

Matt BaldwinLucas 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

X

M

Y

a b

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

Installing PROCESS

PROCESS: Models

• Templates PDF file: templates.pdf

Model 4

• Simple mediation• Multiple mediators in parallel

Model 4

Model 4 Output

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 6

Model 6 Output

Model 7

• Moderated mediation• Multiple mediators in parallel

Model 7

Model 7

Model 7 Output

Bootstrapping Mediation in R

The boot package

• Install the boot package and dependencies• What does it do?

The boot package

boot(model, data, R = #)

Number of Resamples

Model

Data

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

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

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

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

Thank you

Monte-Carlo Estimator

• Similar to bootstrapping method• Calculates indirect effect from a, b, and

standard error• http://www.quantpsy.org/medmc/medmc.ht

m

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