Inquiry regarding mediation analysis in Cox regression

I am currently conducting an observational cohort study to assess the association between a psychological scale and the risk of dementia. This study includes 30,000 participants followed up for a period of 10 years. I have employed the Cox proportional hazards model to analyze the association. The formula I have used is:
Surv(personyears, dementia) ~ age + sex + psychological_scale.

Now, I am interested in exploring whether depression, as measured by the GDS15 scale, acts as a mediator for this association. While I am familiar with conducting mediation analysis in linear regression models (using the lavaan package), I am unsure about the appropriate approach to apply in the context of survival analysis using the Cox model.

I would appreciate your valuable guidance and advice on this matter.


I cannot speak from personal experience, however, there appear to be two R packages, one on CRAN, the other on Github, that may be of help to you.

The first is the ‘mediation’ package on CRAN:

which from their vignette table 1, appears to support parametric survival models using survreg().

The second is the ‘mediator’ package on Github:

which from their slide deck:

appears to support Cox models using coxph().

The one potential issue with both of the above packages is that it has been a few years since they were updated, which might suggest potential code update/bug fix issues due to the lack of active maintenance, and there are some open issues on Github for the second package.

A couple of additional resources for you, would be a 2021 thread on StackExchange:

and a 2018 paper on BMC:

Barring responses from others here, the above may be helpful to get you moving in the right direction.


Thank you very much for the valuable information and insights.

The ‘mediation’ package appears to be helpful, and I plan to utilize both it and the methods discussed in the AJE paper, as mentioned on the Cross Validated site, to conduct mediation analysis, and verify the consistency of the two methods. :+1: :+1: :+1:

1 Like