# SEMinR Lecture Series - Mediation Analysis

### SEMinR Lecture Series

This session is focused on how to perform mediation analysis using SEMinR in Cran R.

## Mediation Analysis

- Mediation occurs when a construct, referred to as
**mediator construct**, intervenes between two other related constructs. - More precisely, a change in the exogenous construct causes a change in the mediator construct, which, in turn, results in a change in the endogenous construct in the PLS path model. When such an effect is present,
**mediation**can be a useful statistical analysis, if supported by theory and carried out properly. - Consider Fig. for an illustration of a
**mediating effect**in terms of direct and indirect effects. A**direct effect**describes the relationships linking two constructs with a single arrow. Indirect effects are those structural model paths that involve a sequence of relationships with at least one intervening construct involved. - Thus, an
**indirect effect**is a sequence of two or more direct effects and is represented visually by multiple arrows. Figure shows both a direct effect*p*3 between*Y*1 and*Y*3 and an indirect effect of*Y*1 on*Y*3 in the form of a*Y*1*→ Y*2*→ Y*3 sequence. - The indirect effect, computed as the product
*p*1*∙ p*2, represents the mediating effect of the construct*Y*2 on the relationship between*Y*1 and*Y*3*.* - Finally, the sum of the direct and indirect effect is referred to as the
**total****effect**(i.e.,*p*1*∙ p*2 +*p*3 in Fig).

## Evaluation of Mediation Model

- Evaluating a
**mediation model**requires all quality criteria of the measurement and structural models to be met, as discussed in previous sessions. The analysis begins with the assessment of the reflective/formative measurement models. - For example, a lack of reliability for one or more reflective mediator constructs will have a meaningful impact on the estimated relationships in the PLS path model (i.e., the indirect paths can become considerably smaller than expected).
- For this reason, it is important to ensure that the reflectively measured mediator constructs exhibit a high level of reliability.
- After establishing the reliability and validity of measurement models for the mediator as well as the other exogenous and the endogenous constructs, it is important to consider all structural model evaluation criteria.
High collinearity must not be present since it is likely to produce biased path coefficients. For example, as a result of collinearity, the direct effect may become nonsignificant, suggesting the absence of mediation even though, for example, complementary mediation may be present.

Likewise, high collinearity levels may result in unexpected sign changes, rendering any differentiation between different mediation types problematic.

Moreover, a lack of the mediator construct’s discriminant validity with the exogenous or endogenous construct might result in a strong and significant but substantially biased indirect effect, consequently leading to incorrect implications regarding the existence or type of mediation.

After meeting the relevant assessment criteria for reflective and formative measurement models, as well as the structural model, the actual mediation analysis follows.

## Mediation Analysis Procedure

- Evaluating a
**mediation model.**

## Mediation Analysis Illustration

- We expect Collaborative Culture mediates the relationship between Vision and Organizational Performance. To test these hypothesized effects, we will apply the procedure shown in last figure.
- To begin the mediation analysis, we need to ensure that all construct measures are reliable and valid and that the structural model meets all quality criteria.
- As we have conducted these evaluations in previous session, we can now move directly to the mediation analysis. If your model has not yet been thoroughly assessed, please do so before conducting the mediation analysis.
- The first step is to test for significance of the relevant indirect effects. The indirect effect from Vision via
*Collaborative Culture*to*Organizational Performance*is the product of the path coefficients from Vision to*Collaborative Culture*and from*Collaborative Culture*to*Organizational Performance*. - To test for significance of these path coefficients’ products, we first need to estimate and bootstrap the model and summarize the results.

- The results for total indirect effects can be found by inspecting the
**total_indirect_effects**element within the**summary_model**object,**summary_model$total_indirect_effects**. - Specific indirect paths can be evaluated for significance, by using the
**specific_effect_significance****()**function. This function takes a bootstrapped model object, an antecedent construct name, and an outcome construct name as arguments and returns the bootstrap confidence interval for the total indirect paths from the antecedents to the outcome construct. - We use the
**specific_effect_significance****()**function on the**summary_boot**object and specify the indirect path using theand*from*arguments.*to* - A separate path must be specified for each mediation analysis.

```
# Inspect total indirect effects
summary_simple$total_indirect_effects
# Inspect indirect effects
specific_effect_significance(boot_model, from = "Vision", through = "Collaborative Culture", to = "Organizational Performance", alpha = 0.05)
```

## Output

Following the mediation analysis procedure (Fig), we can now ascertain if the direct effect is significant for the mediation effect (i.e., Vision to Organizational Performance). These paths can be accessed by inspecting the **paths **element of the **summary_simple** object. The confidence intervals for the direct effects can be evaluated by inspecting the **bootstrapped_paths** element of the **summary_boot** object.

```
# Inspect the direct effects
summary_simple$paths
# Inspect the confidence intervals for direct effects
summary_boot$bootstrapped_paths
```

### Output

The results in Fig. show that the direct effect from *Vision* to *Organizaitonal** Performance *is **0.479 **with a 95% confidence interval [**0.574**; **0.723**]. As this interval does not include zero, this direct effect is significant. The specific indirect effect was also found significant. Therefore, it can be concluded that the relationship between *Vision *and *Organizaitonal** Performance *is fully mediated by *Collaborative Culture*.

### Competitive or Complementary Mediation

- We now need to further evaluate if
*Collaborative Culture*acts as a complementary or competitive mediator for the effect of Vision on Organizational Performance. - To do so, we need to determine whether the product of the direct and indirect effects (
*p*1*∙ p*2*∙ p*3) has a positive or negative sign. To show these paths, we use the path element of**summary_simple**. - We can subset this path’s matrix to display the path from
*Vision*to*Organizational Performance*,**summary_simple$paths****[“Vision”, “****Orgnaizational****Performance”]**. - We need to repeat this step for each of the three paths in the mediation relationship and then multiply the paths.

```
#Calculate the sign of p1*p2*p3
summary_simple$paths["Vision", "Organizational Performance"] *
summary_simple$paths["Vision", "Collaborative Culture"] *
summary_simple$paths["Collaborative Culture", "Organizational Performance"]
```

## Video Tutorial - Step 1

## Complete Code - Simple Mediation with 1 Mediator

```
library(seminr)
# Load the Data
datas <- read.csv(file = "D:\\YouTube Videos\\SEMinR\\Data.csv", header = TRUE, sep = ",")
head(datas)
# Create measurement model
simple_mm <- constructs(
composite("Vision", multi_items("VIS", 1:4), weights = mode_B),
composite("Collaborative Culture", multi_items("CC", 1:6)),
composite("Organizational Performance", multi_items("OP", 1:5)))
# Create structural model
simple_sm <- relationships(
paths(from = "Vision", to = "Organizational Performance"),
paths(from = "Vision", to = "Collaborative Culture"),
paths(from = "Collaborative Culture", to = "Organizational Performance"))
# Estimate the model
simple_model <- estimate_pls(data = datas,
measurement_model = simple_mm,
structural_model = simple_sm,
missing = mean_replacement,
missing_value = "-99")
# Summarize the model results
summary_simple <- summary(simple_model)
# Iterations to converge
summary_simple$iterations
# Bootstrap the model on the PLS Estimated Model
boot_model <- bootstrap_model(
seminr_model = simple_model,
nboot = 1000,
cores = parallel::detectCores(),
seed = 123)
# Store the summary of the bootstrapped model
# alpha sets the specified level for significance, i.e. 0.05
summary_boot <- summary(boot_model, alpha = 0.05)
# Inspect total indirect effects
summary_simple$total_indirect_effects
# Inspect indirect effects
specific_effect_significance(boot_model,
from = "Vision",
through = "Collaborative Culture",
to = "Organizational Performance",
alpha = 0.05)
# Inspect the direct effects
summary_simple$paths
# Inspect the confidence intervals for direct effects
summary_boot$bootstrapped_paths
#Calculate the sign of p1*p2*p3
summary_simple$paths["Vision", "Organizational Performance"] *
summary_simple$paths["Vision", "Collaborative Culture"] *
summary_simple$paths["Collaborative Culture", "Organizational Performance"]
plot(simple_model)
plot(boot_model)
```

## Complete Code - Mediation with Multiple Mediator

#### Sample Model

## Complete Code - Mediation with 2 Mediators

```
library(seminr)
# Load the Data
datas <- read.csv(file = "D:\\YouTube Videos\\SEMinR\\Data.csv", header = TRUE, sep = ",")
head(datas)
# Create measurement model
simple_mm <- constructs(
composite("Vision", multi_items("VIS", 1:4), weights = mode_B),
composite("Commitment", multi_items("OC", 1:8)),
composite("Collaborative Culture", multi_items("CC", 1:6)),
composite("Organizational Performance", multi_items("OP", 1:5)))
# Create structural model
simple_sm <- relationships(
paths(from = "Vision", to = "Organizational Performance"),
paths(from = "Vision", to = c("Commitment","Collaborative Culture")),
paths(from = c("Commitment","Collaborative Culture"), to = "Organizational Performance"))
# Estimate the model
simple_model <- estimate_pls(data = datas, measurement_model = simple_mm, structural_model = simple_sm, missing = mean_replacement, missing_value = "-99")
# Summarize the model results
summary_simple <- summary(simple_model)
# Iterations to converge
summary_simple$iterations
# Bootstrap the model on the PLS Estimated Model
boot_model <- bootstrap_model(
seminr_model = simple_model,
nboot = 1000,
cores = parallel::detectCores(),
seed = 123)
# Store the summary of the bootstrapped model
# alpha sets the specified level for significance, i.e. 0.05
summary_boot <- summary(boot_model, alpha = 0.05)
# Inspect total indirect effects
summary_simple$total_indirect_effects
# Inspect indirect effects from Vision to Organizational Performance through Collaborative Culture
specific_effect_significance(boot_model,
from = "Vision", through = "Collaborative Culture", to = "Organizational Performance", alpha = 0.05)
# Inspect indirect effects from Vision to Organizational Performance through Commitment
specific_effect_significance(boot_model,
from = "Vision", through = "Commitment", to = "Organizational Performance", alpha = 0.05)
# Inspect the direct effects
summary_simple$paths
# Inspect the confidence intervals for direct effects
summary_boot$bootstrapped_paths
#Calculate the sign of p1*p2*p3
summary_simple$paths["Vision", "Organizational Performance"] *
summary_simple$paths["Vision", "Collaborative Culture"] *
summary_simple$paths["Collaborative Culture", "Organizational Performance"]
#Calculate the sign of p1*p4*p5
summary_simple$paths["Vision", "Organizational Performance"] *
summary_simple$paths["Vision", "Commitment"] *
summary_simple$paths["Commitment", "Organizational Performance"]
```

## Reference

Hair Jr, J. F., Hult, G. T. M., Ringle, C. M., Sarstedt, M., Danks, N. P., & Ray, S. (2021). Partial Least Squares Structural Equation Modeling (PLS-SEM) Using R: A Workbook.