What is mediation?

Mediation is the process by which one variable transmits an effect onto another through one or more mediating variables. In this case, as depression increases, People with Epilespsy (PWE) will have higher sense of severity from thier illness, and then their Quality of Life (QOL) will diminish.This study examones that illness perceptions may be a useful target in screening and intervention approaches in order to improve QOL among PWE.

What is an indirect effect?

The indirect effect quantifies a mediation effect, if such an effect exists. Referring to the study, in statistical terms, the indirect effect quantifies the extent to which depression is associated with QOL indirectly through illness perception. Based on interpreting regression coefficients and the idea of controlling for other variables, then it is intuitive to think of the indirect effect as the decrease in the relationship between depression and QOL after you’ve partialed out the association between depression and illness perception. In other words, how much does the coefficient for depression decrease when you control for illness perception?

Model and Conceptual Assumptions

Testing the Significance of Mediation

There are two primary methods for formally testing the significance of the indirect test: the Sobel test & bootstrapping. For more information, see also http://davidakenny.net/cm/mediate.htm#WIM

Visualize relationships

# Write model to test indirect effect using sem() from lavaan

Fit model

## lavaan 0.6-7 ended normally after 24 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of free parameters                          5
##                                                       
##   Number of observations                           261
##                                                       
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                            Bootstrap
##   Number of requested bootstrap draws            10000
##   Number of successful bootstrap draws           10000
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   severe ~                                                              
##     PHQ        (a)    0.332    0.054    6.104    0.000    0.332    0.371
##   QOLIE10 ~                                                             
##     severe     (b)   -2.089    0.270   -7.725    0.000   -2.089   -0.398
##     PHQ       (cp)   -1.944    0.242   -8.022    0.000   -1.944   -0.413
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .severe            2.064    0.169   12.181    0.000    2.064    0.863
##    .QOLIE10          36.148    3.201   11.294    0.000   36.148    0.549
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     ab               -0.695    0.142   -4.879    0.000   -0.695   -0.148
##     total            -2.639    0.248  -10.639    0.000   -2.639   -0.561
lhs op rhs label est se z pvalue ci.lower ci.upper std.lv std.all std.nox
severe ~ PHQ a 0.3324448 0.0544652 6.103798 0.0e+00 0.2220184 0.4375907 0.3324448 0.3705972 0.2149081
QOLIE10 ~ severe b -2.0894618 0.2704776 -7.725082 0.0e+00 -2.6154877 -1.5536006 -2.0894618 -0.3982640 -0.3982640
QOLIE10 ~ PHQ cp -1.9440904 0.2423547 -8.021675 0.0e+00 -2.4184676 -1.4627137 -1.9440904 -0.4130814 -0.2395447
severe ~~ severe 2.0642950 0.1694687 12.180982 0.0e+00 1.7606527 2.4273279 2.0642950 0.8626578 0.8626578
QOLIE10 ~~ QOLIE10 36.1479108 3.2005433 11.294305 0.0e+00 30.6101873 43.3812796 36.1479108 0.5488116 0.5488116
PHQ ~~ PHQ 2.9737085 0.0000000 NA NA 2.9737085 2.9737085 2.9737085 1.0000000 2.9737085
ab := a*b ab -0.6946306 0.1423773 -4.878801 1.1e-06 -1.0092166 -0.4432444 -0.6946306 -0.1475955 -0.0855902
total := cp+ab total -2.6387210 0.2480230 -10.639018 0.0e+00 -3.1230253 -2.1559284 -2.6387210 -0.5606770 -0.3251348

Every 1-unit increase in PHQ was associated with an a = 0.33 (S.E. = 0.054) increase in severity units. Adjusting for PHQ, every 1-unit increase in seizure severity was associated with lower QOL b = -2.08 (S.E. = 0.27).Every 1-unit increase in PHQ was associated with an a = -1.94 (S.E. = 0.24) increase in QOL units independent of its association with seizure severity. PHQ increase was associated with decrease in QOL indirectly through increases in illness severeity, for every a = 0.32 unit increase in the association between PHQ and illness severity, there was an ab = -0.69 (S.E. = 0.14) decrease in QOL.] Last, PHQ was associated with QOL independent of its association with epilespsy severity, c’ = -1.94 (S.E. = 0.24).

When a mediator is hypothesized, the total effect can be broken into two parts: the direct and indirect effect. The direct effect is the effect of exposure on the outcome absent the mediator. The indirect pathway is the effect of exposure on the outcome that works through the mediator.

Total effect : b = -2.63 (S.E. = 0.24).

Test same model using mediation() from MBESS

## [1] "Bootstrap resampling has begun. This process may take a considerable amount of time if the number of replications is large, which is optimal for the bootstrap procedure."
##                                           Estimate CI.Lower_BCa CI.Upper_BCa
## Indirect.Effect                        -0.69463064  -1.00063575  -0.44264116
## Indirect.Effect.Partially.Standardized -0.08542606  -0.12002861  -0.05526128
## Index.of.Mediation                     -0.14759552  -0.20784871  -0.09516187
## R2_4.5                                  0.16715794   0.10238662   0.24341269
## R2_4.6                                  0.02740866   0.01178226   0.05203861
## R2_4.7                                  0.06074771   0.02897712   0.10336969
## Ratio.of.Indirect.to.Total.Effect       0.26324520   0.17064118   0.37089060
## Ratio.of.Indirect.to.Direct.Effect      0.35730367   0.20581967   0.59005455
## Success.of.Surrogate.Endpoint          -7.93732181 -11.26154038  -6.01608405
## Residual.Based_Gamma                    0.13617558   0.08588986   0.19793141
## Residual.Based.Standardized_gamma       0.11596384   0.06823284   0.17346787
## SOS                                     0.53174278   0.36364427   0.68015418

The plot above depicts the relationship between the proposed mediator (Severity) and outcome variable (QOL) at different levels of the proposed antecedent (PHQ). The plot doesn’t label this, but if check out the right triangle formed in between the vertical lines marking the a coefficient, you’ll see the indirect effect, which is the height of this triangle.

## Loading required package: DiagrammeR
## [1] "Bootstrap resampling has begun. This process may take a considerable amount of time if the number of replications is large, which is optimal for the bootstrap procedure."
##                                           Estimate CI.Lower_BCa CI.Upper_BCa
## Indirect.Effect                        -0.69463064  -1.00698288  -0.44141732
## Indirect.Effect.Partially.Standardized -0.08542606  -0.12091883  -0.05512610
## Index.of.Mediation                     -0.14759552  -0.20921175  -0.09513811
## R2_4.5                                  0.16715794   0.10150088   0.24454589
## R2_4.6                                  0.02740866   0.01179722   0.05255389
## R2_4.7                                  0.06074771   0.02934006   0.10410585
## Ratio.of.Indirect.to.Total.Effect       0.26324520   0.16955615   0.37423190
## Ratio.of.Indirect.to.Direct.Effect      0.35730367   0.20425325   0.59839573
## Success.of.Surrogate.Endpoint          -7.93732181 -11.26755193  -6.04459124
## Residual.Based_Gamma                    0.13617558   0.08455354   0.19734192
## Residual.Based.Standardized_gamma       0.11596384   0.06649013   0.17293170
## SOS                                     0.53174278   0.36332238   0.68096755
## $Y.on.X
## $Y.on.X$Regression.Table
##                Estimate Std. Error   t value      p(>|t|) Low Conf Limit
## Intercept.Y_X 32.250504  1.1916591  27.06353 1.845643e-77      29.903929
## c (Regressor) -2.638721  0.2421472 -10.89718 5.213908e-23      -3.115549
##               Up Conf Limit
## Intercept.Y_X     34.597078
## c (Regressor)     -2.161893
## 
## $Y.on.X$Model.Fit
##        Residual standard error (RMSE) numerator df denomenator df F-Statistic
## Values                       6.746039            1            259    118.7485
##        p-value (F)       R^2   Adj R^2 Low Conf Limit Up Conf Limit
## Values           0 0.3143586 0.3117114      0.2214971     0.4068911
## 
## 
## $M.on.X
## $M.on.X$Regression.Table
##                Estimate Std. Error  t value      p(>|t|) Low Conf Limit
## Intercept.M_X 1.6247853 0.25477654 6.377295 8.233233e-10       1.123088
## a (Regressor) 0.3324448 0.05177103 6.421444 6.414567e-10       0.230499
##               Up Conf Limit
## Intercept.M_X     2.1264825
## a (Regressor)     0.4343905
## 
## $M.on.X$Model.Fit
##        Residual standard error (RMSE) numerator df denomenator df F-Statistic
## Values                       1.442302            1            259    41.23494
##         p-value (F)       R^2   Adj R^2 Low Conf Limit Up Conf Limit
## Values 6.414567e-10 0.1373422 0.1340115     0.06782618     0.2210089
## 
## 
## $Y.on.X.and.M
## $Y.on.X.and.M$Regression.Table
##                      Estimate Std. Error   t value      p(>|t|) Low Conf Limit
## Intercept.Y_XM      35.645430  1.1490181 31.022515 4.865857e-89      33.382782
## c.prime (Regressor) -1.944090  0.2337025 -8.318656 5.188747e-15      -2.404298
## b (Mediator)        -2.089462  0.2605229 -8.020262 3.700766e-14      -2.602484
##                     Up Conf Limit
## Intercept.Y_XM          37.908078
## c.prime (Regressor)     -1.483883
## b (Mediator)            -1.576440
## 
## $Y.on.X.and.M$Model.Fit
##        Residual standard error (RMSE) numerator df denomenator df F-Statistic
## Values                       6.047168            2            258    106.0534
##        p-value (F)       R^2   Adj R^2 Low Conf Limit Up Conf Limit
## Values           0 0.4511884 0.4469341      0.3556521     0.5349578
## 
## 
## $Effect.Sizes
##                                               [,1]
## Indirect.Effect                        -0.69463064
## Indirect.Effect.Partially.Standardized -0.08542606
## Index.of.Mediation                     -0.14759552
## R2_4.5                                  0.16715794
## R2_4.6                                  0.02740866
## R2_4.7                                  0.06074771
## Ratio.of.Indirect.to.Total.Effect       0.26324520
## Ratio.of.Indirect.to.Direct.Effect      0.35730367
## Success.of.Surrogate.Endpoint          -7.93732181
## Residual.Based_Gamma                    0.13617558
## Residual.Based.Standardized_gamma       0.11596384
## SOS                                     0.53174278

The direct effect is also called average direct effect (ADE), the indirect effect is also called average causal mediation effects (ACME)

## 
## Call:
## lm(formula = QOLIE10 ~ PHQ, data = LEEP)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -19.6956  -4.9731   0.2205   5.0269  18.8593 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  32.2505     1.1917   27.06   <2e-16 ***
## PHQ          -2.6387     0.2421  -10.90   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.746 on 259 degrees of freedom
## Multiple R-squared:  0.3144, Adjusted R-squared:  0.3117 
## F-statistic: 118.7 on 1 and 259 DF,  p-value: < 2.2e-16
## 
## Call:
## lm(formula = severe ~ PHQ, data = LEEP)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -3.284 -1.284 -0.287  1.045  4.378 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.62479    0.25478   6.377 8.23e-10 ***
## PHQ          0.33244    0.05177   6.421 6.41e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.442 on 259 degrees of freedom
## Multiple R-squared:  0.1373, Adjusted R-squared:  0.134 
## F-statistic: 41.23 on 1 and 259 DF,  p-value: 6.415e-10
## 
## Call:
## lm(formula = QOLIE10 ~ PHQ + severe, data = LEEP)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13.6007  -4.6901   0.3434   4.3099  22.4441 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  35.6454     1.1490  31.023  < 2e-16 ***
## PHQ          -1.9441     0.2337  -8.319 5.19e-15 ***
## severe       -2.0895     0.2605  -8.020 3.70e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.047 on 258 degrees of freedom
## Multiple R-squared:  0.4512, Adjusted R-squared:  0.4469 
## F-statistic: 106.1 on 2 and 258 DF,  p-value: < 2.2e-16
## 
## Mediation Analysis With only X and M as Predictors
## ==========================================================================================
##                                              Dependent variable:                          
##                     ----------------------------------------------------------------------
##                             QOLIE10                 severe                 QOLIE10        
##                               (1)                    (2)                     (3)          
## ------------------------------------------------------------------------------------------
## PHQ                        -2.64***                0.33***                -1.94***        
##                             (0.24)                  (0.05)                 (0.23)         
##                                                                                           
## severe                                                                    -2.09***        
##                                                                            (0.26)         
##                                                                                           
## Constant                   32.25***                1.62***                35.65***        
##                             (1.19)                  (0.25)                 (1.15)         
##                                                                                           
## ------------------------------------------------------------------------------------------
## Observations                  261                    261                     261          
## R2                           0.31                    0.14                   0.45          
## Adjusted R2                  0.31                    0.13                   0.45          
## Residual Std. Error     6.75 (df = 259)        1.44 (df = 259)         6.05 (df = 258)    
## F Statistic         118.75*** (df = 1; 259) 41.23*** (df = 1; 259) 106.05*** (df = 2; 258)
## ==========================================================================================
## Note:                                                        *p<0.05; **p<0.01; ***p<0.001
##  [1] ""                                                                                          
##  [2] "Mediation Analysis With only X and M as Predictors"                                        
##  [3] "=========================================================================================="
##  [4] "                                             Dependent variable:                          "
##  [5] "                    ----------------------------------------------------------------------"
##  [6] "                            QOLIE10                 severe                 QOLIE10        "
##  [7] "                              (1)                    (2)                     (3)          "
##  [8] "------------------------------------------------------------------------------------------"
##  [9] "PHQ                        -2.64***                0.33***                -1.94***        "
## [10] "                            (0.24)                  (0.05)                 (0.23)         "
## [11] "                                                                                          "
## [12] "severe                                                                    -2.09***        "
## [13] "                                                                           (0.26)         "
## [14] "                                                                                          "
## [15] "Constant                   32.25***                1.62***                35.65***        "
## [16] "                            (1.19)                  (0.25)                 (1.15)         "
## [17] "                                                                                          "
## [18] "------------------------------------------------------------------------------------------"
## [19] "Observations                  261                    261                     261          "
## [20] "R2                           0.31                    0.14                   0.45          "
## [21] "Adjusted R2                  0.31                    0.13                   0.45          "
## [22] "Residual Std. Error     6.75 (df = 259)        1.44 (df = 259)         6.05 (df = 258)    "
## [23] "F Statistic         118.75*** (df = 1; 259) 41.23*** (df = 1; 259) 106.05*** (df = 2; 258)"
## [24] "=========================================================================================="
## [25] "Note:                                                        *p<0.05; **p<0.01; ***p<0.001"

How does the new coefficient of loginc (b3) change, compared to b1? Does it decrease or disappear completely?

If the effect of X on Y completely disappears, M fully mediates between X and Y (full mediation) which rarely happens, however. If the effect of X on Y still exists, but in a smaller magnitude, M partially mediates between X and Y (partial mediation).

Sobel Test

A test, first proposed by Sobel (1982), was initially often used. The Sobel test provides an approximate estimate of the standard error of ab. However, the Sobel test is very conservative (MacKinnon, Warsi, & Dwyer, 1995), and so it has very low power. Bootstrapping has replaced the more conservative Sobel test in recent practices.

## $`Mod1: Y~X`
##              Estimate Std. Error   t value     Pr(>|t|)
## (Intercept) 32.250504  1.1916591  27.06353 1.845643e-77
## pred        -2.638721  0.2421472 -10.89718 5.213908e-23
## 
## $`Mod2: Y~X+M`
##              Estimate Std. Error   t value     Pr(>|t|)
## (Intercept) 35.645430  1.1490181 31.022515 4.865857e-89
## pred        -1.944090  0.2337025 -8.318656 5.188747e-15
## med         -2.089462  0.2605229 -8.020262 3.700766e-14
## 
## $`Mod3: M~X`
##              Estimate Std. Error  t value     Pr(>|t|)
## (Intercept) 1.6247853 0.25477654 6.377295 8.233233e-10
## pred        0.3324448 0.05177103 6.421444 6.414567e-10
## 
## $Indirect.Effect
## [1] -0.6946306
## 
## $SE
## [1] 0.1385739
## 
## $z.value
## [1] -5.012709
## 
## $N
## [1] 261

Bootstrapping

Bootstrapping is a non-parametric method based on resampling with replacement which is done many times, e.g., 5000 times. From each of these samples the indirect effect is computed and a sampling distribution can be empirically generated. Because the mean of the bootstrapped distribution will not exactly equal the indirect effect a correction for bias can be made. With the distribution, a confidence interval, a p value, or a standard error can be determined. Very typically a confidence interval is computed and it is checked to determine if zero is in the interval. If zero is not in the interval, then the researcher can be confident that the indirect effect is different from zero. Also a Z value can determined by dividing the bootstrapped estimate by its standard error, but bootstrapped standard errors suffer the same problem as the Sobel standard errors and are not recommended. (Bootstrapping does not require the assumption that a and b are uncorrelated.)

## Running nonparametric bootstrap
## 
## Causal Mediation Analysis 
## 
## Nonparametric Bootstrap Confidence Intervals with the Percentile Method
## 
##                Estimate 95% CI Lower 95% CI Upper p-value    
## ACME             -0.695       -0.991        -0.41  <2e-16 ***
## ADE              -1.944       -2.417        -1.46  <2e-16 ***
## Total Effect     -2.639       -3.122        -2.17  <2e-16 ***
## Prop. Mediated    0.263        0.164         0.37  <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 261 
## 
## 
## Simulations: 500
## Warning in plot.window(...): "title" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "title" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "title" is not a
## graphical parameter

## Warning in axis(side = side, at = at, labels = labels, ...): "title" is not a
## graphical parameter
## Warning in box(...): "title" is not a graphical parameter
## Warning in title(...): "title" is not a graphical parameter
## Warning in axis(2, at = y.axis, labels = labels, las = 1, tick = TRUE, ...):
## "title" is not a graphical parameter

References

https://stats.stackexchange.com/questions/185626/what-if-path-c-isnt-significant-but-paths-a-and-b-are-indirect-effect-in-medi file:///C:/Users/u6032404/Downloads/MakingSenseofMediatingAnalysis.pdf https://en.wikipedia.org/wiki/Mediation_(statistics) https://nmmichalak.github.io/nicholas_michalak/blog_entries/2018/nrg01/nrg01.html https://tvpollet.github.io/PY_0782/Exercise_6.html https://rpubs.com/cardiomoon/481347 https://rpubs.com/cardiomoon/468602 https://rpubs.com/markhw/processr https://rpubs.com/VivianaWu/mssp_lab10 https://rpubs.com/maureenkelly03/606717 https://rpubs.com/Tarid/fullsem