Multilevel path model using lavaan: Testing 1-1-1 mediation
Overview
This example is adapted from a study by Xie et al. (2015), “Linking Colleague Support to Employees’ Promotive Voice: A Moderated Mediation Model” published in PLOS One. Although we will not be testing the authors’ model, we will rely on the dataset they published in the Supplementary Materials on the journal site for their article (https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0132123).
I have constructed a smaller dataset from the original data and made some changes in naming, etc. You can download a copy of the .csv file containing the data here. The .csv file is named prvoiceV5. Once you have downloaded the data to your computer, you will need to import it into RStudio for use.
For our analysis, we are modeling data based on \(n_1\)=162 employees (level 1 units) nested within \(n_2\)=51 work teams (level 2 units). At the employee level, we are predicting promotive voice as a function of felt obligation, psychological safety, and team identification. Felt obligation is treated as a mediator of the effects of psychological safety and team identification on promotive voice.
At level 2, we are allowing the random intercepts for the two endogenous level 1 variables to covary. This added covariance for the random intercepts at level 2 in our model is due to a requirement that some type of model is specified at level 2 in lavaan. The authors of this site https://lavaan.ugent.be/tutorial/multilevel.html suggest that if you do not have a substantive model to test at level 2, then you ‘you can specify a saturated level by adding all variances and covariances of the endogenous variables’.
Here is a figure of the model we will be specifying and testing using lavaan.
Let’s take a look at the names of the
variables in our dataset.
names(prvoiceV5)
## [1] "X" "teamcode"
## [3] "colleaguesupport" "feltobl"
## [5] "gender" "age"
## [7] "eduation" "tenure"
## [9] "teamsize" "teamID"
## [11] "subgroupformationindividual" "psysafe"
## [13] "prvoice"
The variables we will be using when running our analysis include:
- prvoice (level 1 outcome; promotive voice)
- feltobl (level 1 mediator; felt obligation)
- teamID (level 1 antecedent; team identification)
- psysafe (level 1 antecedent; psychological safety)
All variables are treated as continuous in the analysis. [Keep in mind too that lavaan currently does not allow for categorical endogenous variables]
The main analyses
library(lavaan)
model1a <- '
level: 1 # specification of level 1 model
prvoice ~ feltobl
feltobl ~ psysafe + teamID
level: 2 # specification of level 2 model
# this specification will result in the estimation
# of the variances and covariances of the
# random intercepts for these variables. It will also
# saturate the model at level 2.
prvoice ~~ feltobl
'
The following code will fit the model and generate our output.
Make sure you include the cluster argument (see below) and set it equal
to the name of the clustering variable (enclosed in quotes). [The output
will contain warning messages about lack of variance within clusters for
certain variables. This is simply a warning. But I do not reproduce it
here.]
fit1 <- sem(model1a, data = prvoiceV5, cluster = "teamcode")
summary(fit1, fit.measures=T, rsquare=T)
## lavaan 0.6.13 ended normally after 27 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Number of observations 162
## Number of clusters [teamcode] 51
##
## Model Test User Model:
##
## Test statistic 0.977
## Degrees of freedom 2
## P-value (Chi-square) 0.614
##
## Model Test Baseline Model:
##
## Test statistic 122.772
## Degrees of freedom 6
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.026
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -344.851
## Loglikelihood unrestricted model (H1) -344.363
##
## Akaike (AIC) 709.703
## Bayesian (BIC) 740.579
## Sample-size adjusted Bayesian (SABIC) 708.921
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.126
## P-value H_0: RMSEA <= 0.050 0.718
## P-value H_0: RMSEA >= 0.080 0.172
##
## Standardized Root Mean Square Residual (corr metric):
##
## SRMR (within covariance matrix) 0.022
## SRMR (between covariance matrix) 0.045
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Observed
## Observed information based on Hessian
##
##
## Level 1 [within]:
##
## Regressions:
## Estimate Std.Err z-value P(>|z|)
## prvoice ~
## feltobl 0.385 0.108 3.574 0.000
## feltobl ~
## psysafe 0.355 0.049 7.291 0.000
## teamID 0.265 0.045 5.950 0.000
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .prvoice 0.000
## .feltobl 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .prvoice 0.625 0.084 7.430 0.000
## .feltobl 0.238 0.032 7.409 0.000
##
## R-Square:
## Estimate
## prvoice 0.099
## feltobl 0.484
##
##
## Level 2 [teamcode]:
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## .prvoice ~~
## .feltobl 0.111 0.048 2.328 0.020
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .prvoice 3.509 0.405 8.673 0.000
## .feltobl 0.981 0.281 3.491 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .prvoice 0.759 0.195 3.894 0.000
## .feltobl 0.017 0.021 0.796 0.426
The chi-square goodness of fit test was not statistically significant, \(\chi^2\)(6)=122.772, p=.614 (lead to a failure to reject the exact fit hypothesis). The CFI=1 and TLI = 1.026 were above .95, indicating a very good fitting model. Similarly, the RMSEA of approximately 0 indicates a very good fitting model. The SRMR within and between also suggested a well fitting model.
Team identification (b=.265, p<.001) and psychological safety (b=.355, p<.001) were both significant positive predictors of felt obligation. Felt obligation, in turn, was a positive and significant (b=.385, p<.001) predctor of promotive voice.
If you would like to report on the intraclass correlations for
the endogenous level 1 variables use the lavInspect()
function.
lavInspect(fit1, "icc")
## prvoice feltobl psysafe teamID
## 0.525 0.044 0.000 0.000
We can test for mediation at level 1 as well in lavaan. To do this, you will need to (a) assign labels to the paths used in the construction of the indirect effects and then (b) create estimands for the indirect effects. The figure below shows you the paths involved in the construction of the indirect effect estimands.
Specification of our model…
model1a <- '
level: 1 # specification of level 1 model
prvoice ~ b*feltobl
feltobl ~ a1*psysafe + a2*teamID
# Adding estimands to capture indirect effects
IE1 := a1*b #psysafe->feltobl->prvoice
IE2 := a2*b #teamID->feltobl->prvoice
level: 2 # specification of level 2 model
prvoice ~~ feltobl '
fit1 <- sem(model1a, data = prvoiceV5, cluster = "teamcode")
summary(fit1, fit.measures=T, rsquare=T)
## lavaan 0.6.13 ended normally after 27 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Number of observations 162
## Number of clusters [teamcode] 51
##
## Model Test User Model:
##
## Test statistic 0.977
## Degrees of freedom 2
## P-value (Chi-square) 0.614
##
## Model Test Baseline Model:
##
## Test statistic 122.772
## Degrees of freedom 6
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.026
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -344.851
## Loglikelihood unrestricted model (H1) -344.363
##
## Akaike (AIC) 709.703
## Bayesian (BIC) 740.579
## Sample-size adjusted Bayesian (SABIC) 708.921
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.126
## P-value H_0: RMSEA <= 0.050 0.718
## P-value H_0: RMSEA >= 0.080 0.172
##
## Standardized Root Mean Square Residual (corr metric):
##
## SRMR (within covariance matrix) 0.022
## SRMR (between covariance matrix) 0.045
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Observed
## Observed information based on Hessian
##
##
## Level 1 [within]:
##
## Regressions:
## Estimate Std.Err z-value P(>|z|)
## prvoice ~
## feltobl (b) 0.385 0.108 3.574 0.000
## feltobl ~
## psysafe (a1) 0.355 0.049 7.291 0.000
## teamID (a2) 0.265 0.045 5.950 0.000
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .prvoice 0.000
## .feltobl 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .prvoice 0.625 0.084 7.430 0.000
## .feltobl 0.238 0.032 7.409 0.000
##
## R-Square:
## Estimate
## prvoice 0.099
## feltobl 0.484
##
##
## Level 2 [teamcode]:
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## .prvoice ~~
## .feltobl 0.111 0.048 2.328 0.020
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .prvoice 3.509 0.405 8.673 0.000
## .feltobl 0.981 0.281 3.491 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .prvoice 0.759 0.195 3.894 0.000
## .feltobl 0.017 0.021 0.796 0.426
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|)
## IE1 0.137 0.043 3.181 0.001
## IE2 0.102 0.034 3.030 0.002
We see that the both indirect effects were positive and statistically significant.
References
Xie, X.-Y., Ling, C.-D., Mo, S.-J., Luan, K. (2015). Linking colleague support to employees’ promotive voice: A moderated mediation model. PLoS ONE 10(7): e0132123. doi:10.1371/journal.pone.0132123. Downloaded April 21, 2024 from: https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0132123
Comments
Post a Comment