Skip to main content
Post Closed as "Not suitable for this site" by Xi'an, Adrian Keister, mdewey

Below is a reproductable example that mirrors my real data problem. The code (lightly edited by myself) comes from the supplementary materials of this article https://10.3390/psych3030024https://doi.org/10.3390/psych3030024 by Schoemann & Jorgensen (2021). My edited version features: continuous IV, continous moderator, continous mediator, binary DV. I am fitting a linear probability model. The code gives simple slopes for the moderation and conditional indirect effects, however, all based upon the unstandardized solution (i.e., values in the "Estimate" column not "Std.all").

Below is a reproductable example that mirrors my real data problem. The code (lightly edited by myself) comes from the supplementary materials of this article https://10.3390/psych3030024 by Schoemann & Jorgensen (2021). My edited version features: continuous IV, continous moderator, continous mediator, binary DV. I am fitting a linear probability model. The code gives simple slopes for the moderation and conditional indirect effects, however, all based upon the unstandardized solution (i.e., values in the "Estimate" column not "Std.all").

Below is a reproductable example that mirrors my real data problem. The code (lightly edited by myself) comes from the supplementary materials of this article https://doi.org/10.3390/psych3030024 by Schoemann & Jorgensen (2021). My edited version features: continuous IV, continous moderator, continous mediator, binary DV. I am fitting a linear probability model. The code gives simple slopes for the moderation and conditional indirect effects, however, all based upon the unstandardized solution (i.e., values in the "Estimate" column not "Std.all").

Source Link

How to use probe2WayMC() with fully standardized solution with semTools / Lavaan R packages?

Is it possible to get the probe2WayMC() function from SEMtools package for Lavaan in R to give estimates based upon the fully standardized solution of a SEM model? (i.e., using the estimates from the "Std.all" output column rather than the "Estimate" column).

I tried setting std.lv=TRUE, std.ov=TRUE to make the Estimates column the same as Std.all, but the parameters were still not the same (see "fit model: version 2" in code below).

Below is a reproductable example that mirrors my real data problem. The code (lightly edited by myself) comes from the supplementary materials of this article https://10.3390/psych3030024 by Schoemann & Jorgensen (2021). My edited version features: continuous IV, continous moderator, continous mediator, binary DV. I am fitting a linear probability model. The code gives simple slopes for the moderation and conditional indirect effects, however, all based upon the unstandardized solution (i.e., values in the "Estimate" column not "Std.all").

# load packages
  library(lavaan)
  library(semTools)
  
# generate data
  set.seed(42)
  dat2wayMC <- indProd(dat2way, 1:3, 4:6)
  dat2wayMC$DVbinary <- sample(0:1, 10000, replace = TRUE)
  
# sem model with latent factor interactions from semTools package
  model1 <- "
  # cfa
f1 =~ x1 + x2 + x3
f2 =~ x4 + x5 + x6
f12 =~ x1.x4 + x2.x5 + x3.x6
f3 =~ x7 + x8 + x9
  # path analysis
f3 ~ f1 + f2 + f12
f12 ~~ 0*f1 + 0*f2
x1 + x4 + x1.x4 + x7 ~ 0*1 # identify latent means
f1 + f2 + f12 + f3 ~ NA*1
DVbinary ~ b*f3
"
  
# fit model: version 1
  fitMC2way <- sem(model1, data = dat2wayMC, meanstructure = TRUE)
# fit model: version 2
  fitMC2way <- sem(model1, data = dat2wayMC, meanstructure = TRUE, std.lv=TRUE, std.ov=TRUE)
  summary(fitMC2way, standardized=TRUE)
  
# latent factor moderation
  probe <- probe2WayMC(fitMC2way, nameX = c("f1", "f2", "f12"), 
                       nameY = "f3", modVar = "f2", valProbe = c(-1, 0, 1))
  probe$SimpleSlope
# conditional indirect effects on newDV
  probe$SimpleSlope$est * coef(fitMC2way)[["b"]]
  
# custom function to return simple slopes
  condIndFX <- function(fit) {
    condFX <- probe2WayMC(fit, nameX = c("f1", "f2", "f12"), nameY = "f3",
                          modVar = "f2", valProbe = c(-1, 0, 1))
    indFX <- condFX$SimpleSlope$est * coef(fit)[["b"]]
    names(indFX) <- paste("f2 =", condFX$SimpleSlope$f2)
    indFX
  }
# test once on original data
  condIndFX(fitMC2way)
  
# (too small) bootstrap sample of simple slopes
  bootOut <- bootstrapLavaan(fitMC2way, R = 10, FUN = condIndFX)
# percentile 95% CI
  apply(bootOut, MARGIN = 2, FUN = quantile, probs = c(.025, .975))
```