sem-in-r / seminr

Natural feeling domain-specific language for building structural equation models in R for estimation by covariance-based methods (like LISREL/Lavaan) or partial least squares (like SmartPLS)
58 stars 19 forks source link

Effect size of indirect and total effects in mediation analyses #233

Open JulianGaviriaL opened 3 years ago

JulianGaviriaL commented 3 years ago

Dear seminr experts,

First, thank you for the seminr package. It makes an important contribution to the PLS-SEM implementation.

On the other hand, I wonder how could I obtain the effect size of indirect and total effects from a mediation analysis? As you know, fSquared does not account for mediator variables. Thanks in advance for any suggestion on this regard. Please find below my sample data and code:

library(seminr)
library(DiagrammeR)
packageVersion('seminr')

[data.xlsx](https://github.com/sem-in-r/seminr/files/6868978/data.xlsx)
myDATA<-as.data.frame(myDATA)

# Measurement model;
measu_m <- constructs(
  composite("X", multi_items("Brain_prev", 1:2), weights = mode_B),
  composite("Y", multi_items("Brain_curr", 1:2), weights = mode_B),
  composite("M", multi_items("behavior", 1:2), weights = mode_B)
)

# Structural model: 
struct_m <- relationships( 
  paths(from = "X", to = "M"),
  paths(from = "M", to ="Y"), 
  paths(from = "X", to = "Y") 
)

# Model estimation
pls_m <- estimate_pls(data = myDATA, measurement_model = measu_m, structural_model = struct_m)
summary_pls_m <- summary(pls_m)

#bootstrap the model
boot_pls<-bootstrap_model(pls_m, nboot = 1000, cores = 4, seed = NULL)
boot_summary<-summary(boot_pls)

#extract effect size from paths
fSquared(boot_pls, "X", "Y")
fSquared(boot_pls, "X", "M")
fSquared(boot_pls, "M", "Y")

#Indirect effect,
indirect_eff <- specific_effect_significance(boot_pls, 
                                             from = "X",  
                                             through ="M", 
                                             to = "Y",
                                             alpha = 0.05)
NicholasDanks commented 3 years ago

Dear Julian,

It is great to see your continued use of our package, I hope that I can assist you with the following: For an example of some code applying mediation analysis, I suggest running the demo file: demo("seminr-primer-chap7") The function specific_effect_significance() can be used to determine the CIs and t-value of an indirect path (even with multiple mediators). The total indirect effects can be accessed via the summary object of a bootstrapped model: summary_object$total_indirect_effects

We have written an open-access textbook that addresses these types of questions and explores multiple aspects of model evaluation, but it is only expected to be published by the end of the year.

I hope this helps.

Kind regards, Nick

JulianGaviriaL commented 3 years ago

Dear @NicholasDanks

Thank you very much for your response.

Indeed, I could use summary_object$total_indirect_effects in the following code:

[data.xlsx](https://github.com/sem-in-r/seminr/files/6876415/data.xlsx)
myDATA<-as.data.frame(myDATA)

# Measurement model;
measu_m <- constructs(
  composite("X", multi_items("Brain_prev", 1:2), weights = mode_B),
  composite("Y", multi_items("Brain_curr", 1:2), weights = mode_B),
  composite("M", multi_items("behavior", 1:2), weights = mode_B)
)

# Structural model: 
struct_m <- relationships( 
  paths(from = "X", to = "M"),
  paths(from = "M", to ="Y"), 
  paths(from = "X", to = "Y") 
)

# Model estimation
pls_m <- estimate_pls(data = myDATA, measurement_model = measu_m, structural_model = struct_m)
summary_pls_m <- summary(pls_m)
summary_pls_m$total_indirect_effects
X     M     Y
X 0.000 0.000 0.000
M 0.000 0.000 0.000
Y 0.000 0.000 0.000
> 

Questions:

  1. Are these results expressed in p-values?, i.e., does the output indictes that all the potential direct effects are significant?

  2. Would it be possible to compute the T Statatistics and the confidence intervals, such as it's nice provided in specific_effect_significance?:

indirect_eff <- specific_effect_significance(boot_pls, 
                                             from = "X",  
                                             through ="M", 
                                             to = "Y",
                                             alpha = 0.05)

> indirect_eff
 Original Est. Bootstrap Mean   Bootstrap SD        T Stat.        2.5% CI       97.5% CI 
    0.52558789     0.51823081     0.23735366     2.21436606     0.03171129     0.99265115 

Many thanks in advance for your comments.

Best regards.

Julian

NicholasDanks commented 3 years ago

Dear Julian,

In this case, there is no such report. We are currently thinking about how to update the reporting to include this type of display. Unfortunately in order to test significance of indirect paths you will need to repeatedly run specific_effect_significance for each indirect path. This will provide you with the Original Est of indirect effect and the inferential information. Please keep this issue open as we go forward we will try to work up an automated report that yields these results.

Kind regards, Nick