A Sobel test is a method of testing the significance of a mediation effect.
According to Wikipedia:
In mediation, the relationship between the independent variable and the dependent variable is hypothesized to be an indirect effect that exists due to the influence of a third variable (the mediator). As a result when the mediator is included in a regression analysis model with the independent variable, the effect of the independent variable is reduced and the effect of the mediator remains significant.
The Sobel test is basically a specialized t test that provides a method to determine whether the reduction in the effect of the independent variable, after including the mediator in the model, is a significant reduction and therefore whether the mediation effect is statistically significant.
This tutorial explains how to conduct a sobel test in R.
Conducting a Sobel Test in R
To conduct a sobel test in R, we can use the bda library.
#install bda package if not already installed install.packages('bda') #load bda package library(bda)
The basic syntax to conduct a sobel test is the following:
where mv is the mediator variable, iv is the independent variable, and dv is the dependent variable.
The following code conducts a sobel test using a list of 50 normal random variables for the mediator variable, independent variable, and dependent variable:
mv <- rnorm(50) iv <- rnorm(50) dv <- rnorm(50) mediation.test(mv,iv,dv)
This code produces the following output:
In this case, we are interested primarily in the values in the Sobel column. The z value is -1.047 and the corresponding p-value is 0.295.
Since this p-value is greater than the alpha level of 0.05, we would fail to reject the null hypothesis that there is no mediation effect.
Thus, the mediation effect is not statistically significant.
Note: You may use a different alpha level in your own test. Common choices for alpha include 0.01, 0.05, and 0.10.