How do I perform SEM moderation model in R?

Tools

R

R packages: lavaan, semTools

Instructions

  • We will test the moderating effect of mod on the two effects of iv1 and iv2 on dv
  • Conduct the double mean centering procedure for interactions

Load packages

library(lavaan)
library(semTools)

Measurement model

measure.model <- '
# independent variable 1
iv1 =~ x1 + x2  
# independent variable 2
iv2 =~ x3 + x4 
# moderation variable
mod =~ mod1 + mod2 
# dependent variable
dv =~ y1 + y2 + y3 
'

fit <- sem(measure.model, data = data)
summary(fit, standardized = T)
# standardizedSolution(fit)

Double mean centering

# interaction between iv1 and mod
data.dmc1 <- indProd(data,
var1 = c("x1", "x2"),
var2 = c("mod1", "mod2"),
match = F, meanC = T, residualC = T, doubleMC = T)
# generate new columns: x1.mod1, x2.mod1, x1.mod2, x2.mod2

# interaction between iv2 and mod
data.dmc2 <- indProd(data.dmc1,
var1 = c("x3", "x4"),
var2 = c("mod1", "mod2"),
match = F, meanC = T, residualC = T, doubleMC = T)
# generate new columns: x3.mod1, x4.mod1, x3.mod2, x4.mod2

Moderation model

mod.model <- '
# independent variable 1
iv1 =~ x1 + x2  
# independent variable 2
iv2 =~ x3 + x4 
# moderation variable
mod =~ mod1 + mod2 
# dependent variable
dv =~ y1 + y2 + y3 

# interaction between iv1 and mod
int1 = ~ x1.mod1 + x2.mod1 + x1.mod2 + x2.mod2

# interaction between iv2 and mod
int2 = ~ x3.mod1 + x4.mod1 + x3.mod2 + x4.mod2

# sem model
dv ~ iv1 + iv2 + mod + int1 + int2
'

# use the double mean centered data
fit <- sem(mod.model, data = data.dmc2) 
summary(fit, standardized = T)
# standardizedSolution(fit)

How did I apply for PhD programs for 23 fall?

See my personal page on USTCFlyer.com for background and tips: https://www.ustcflyer.com/usermain/1387 (in Chinese).

Applied Programs:

  1. PhD in Communication at UIUC (rejected)
  2. PhD in Network Science at NEU (rejected)
  3. PhD in Communication at U Kentucky (admitted)
  4. PhD in Mass Communication at UW-Madison (rejected)
  5. PhD in Communication Studies at UT Austin (accepted)
  6. PhD in Communication at ASU (rejected)
  7. PhD in Communication, Information and Media at Rutgers (admitted)
  8. PhD in Management at Monash (withdrawn)