Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Computing the share mediated

    Dear all,
    in a mediation model, one can decompose the total effect of the treatment in a direct and indirect effect. The share mediated is then the indirect effect divided by the total effect. For continuous outcome variables, this is rather simple to do, as two nested OLS model suffice. However, when the dependent variable is binary, this is more complex due to various statistical issues. To accomplish this goal in Stata, the following options come to my mind:
    • Still using OLS, which then becomes a linear probability model (LPM)
    • Using nested binary logistic regression models (likely biased as logits cannot be treated as OLS coefficients)
    • Using nested binary logistic regression models with average marginal effects (AMEs)
    • Using KHB*
    • Using marginal odds ratios (e.g. with lnmor*)
    • Using medeff*
    • Using the rather new mediate command of Stata (however, this does not work for all setups, as the treatment var cannot be continuous)
    (commands marked with an asterisk are community-contributed)

    I wonder if I have forgotten popular techniques or ados used for this goal. If anyone has further ideas please let me know!

    Best wishes

    (Stata 18.0 MP)

  • #2
    Hey Felix, I asked our GPT assistant in Estima and here are a few additional methods and considerations that might be useful: Additional Methods for Mediation Analysis with Binary Outcomes

    1. Generalized Structural Equation Modeling (GSEM):
      • Stata's gsem command allows for the estimation of mediation models with binary outcomes and mediators.
      • It supports various link functions (e.g., logit, probit) and can handle complex survey designs.
      • After fitting the model, you can use nlcom to estimate indirect effects.(Statalist, Stata, OARC Stats)
    2. Product of Coefficients Method with Bootstrapping:
      • This method involves estimating the effect of the independent variable on the mediator and the effect of the mediator on the outcome, then multiplying these coefficients to obtain the indirect effect.
      • Bootstrapping is recommended to obtain standard errors and confidence intervals, especially when dealing with binary outcomes.(Stata)
    3. Binary Mediation Ado by Phil Ender:
      • This user-written command facilitates mediation analysis with binary outcomes.
      • It uses standardization procedures to estimate indirect effects.
      • Note that this command may not be available through findit in newer versions of Stata, but you can access it via the UCLA Statistical Consulting Group's website.(PubMed Central, Stata)
    Considerations

    • Scale of Measurement:
      • When dealing with binary outcomes, it's crucial to consider the scale on which effects are measured (e.g., odds ratios, risk ratios).
      • Different methods may provide estimates on different scales, affecting interpretation.
    • Assumptions:
      • Ensure that the assumptions underlying each method are met in your data.
      • For instance, methods based on the potential outcomes framework assume no unmeasured confounding.(Stata)
    • Software Compatibility:
      • Some user-written commands may not be compatible with the latest versions of Stata.
      • Always check for updates or alternatives that are compatible with your version.
    For more detailed guidance and assistance with Stata commands, you might find Estima helpful. It's a resource tailored for Stata users seeking support with code and statistical analysis.

    Best wishes,
    Josh Zweig


    Comment


    • #3
      Thanks for the input! I find it a bit strange that the LLM refers to Phil Ender's ado but does not name it (ml_mediation). To add some information:
      • ml_mediation refers to mediation with 2-level data
      • Some packages or approaches do not support continuous treatment variables or have rather special applications (paramed, ldecomp, med4way)
      • There is some guidance on how to use gsem (see https://www.stata.com/manuals/semexample42g.pdf, page 4). However, I think this approach does not work if you specify a logit model for the outcome variable.
      Best wishes

      (Stata 18.0 MP)

      Comment


      • #4
        Now that Josh Zweig provides answer from Estima, I also want to give another one. I've been growing increasingly skeptical in AIs' answer recently.

        .................................................. ................................

        Your summary of mediation analysis methods for binary outcomes in Stata is quite comprehensive. Here are some additional approaches and refinements to consider:

        Additional Methods for Binary Outcome Mediation in Stata

        1. Counterfactual-Based Mediation (Causal Mediation)
        • paramed (Community-contributed): Implements Pearl's mediation formula for binary outcomes with nonparametric estimation. Works with logit/probit and handles continuous/binary treatments.
        • gformula (Built-in): Generalized structural equation modeling (GSEM) with counterfactual predictions.
        2. Nonlinear Decomposition Extensions
        • Karlson-Holm-Breen (KHB) with Probit: While you mentioned KHB, note that for binary outcomes, khb works best with probit (rather than logit) due to the proportionality assumption in log-odds.
        • VanderWeele's E-Value Sensitivity Analysis: After mediation, use evalue to assess unmeasured confounding robustness.
        3. Machine Learning Extensions
        • medflex (Community-contributed): Uses flexible imputation for mediation with binary outcomes under weaker assumptions.
        • teffects with Mediation: Combines inverse probability weighting (IPW) with mediation (advanced causal inference).
        4. Bayesian Mediation
        • bayesmh (Built-in): For Bayesian logistic mediation models with credible intervals.
        5. Alternative Effect Scales
        • Risk Ratio (RR) Mediation: Use binreg with RR link (avoiding odds ratio non-collapsibility issues).
        • Natural Direct/Indirect Effects (NDE/NIE): Implemented via mediation (SSC) or paramed.

        Key Considerations for Your Existing List

        1. Linear Probability Model (LPM):
        • Fast but can predict probabilities outside [0,1]. Use margins post-estimation to check validity.
        2. Logistic AMEs:
        • Prefer margins, dydx(*) over raw coefficients to approximate OLS-like effects.
        3. KHB Limitations:
        • For logit, KHB assumes no unobserved heterogeneity—probit is more robust.

        Recommended Workflow

        1. Start Simple:
        • Use paramed or mediation for a baseline causal estimate.
        2. Check Robustness:
        • Compare LPM (regress), KHB-probit (khb probit), and binreg (RR).
        3. Sensitivity:
        • Apply evalue to assess unmeasured confounding.

        Stata Code Example (KHB-Probit)

        Code:
        ssc install khb
        khb probit Y treatment || mediator, controls(control_vars) disentangle

        References
        • VanderWeele, T. J. (2015). Explanation in Causal Inference. Oxford.
        • Hicks, R., & Tingley, D. (2011). mediation in Stata. Stata Journal, 11(4).
        Would you like a specific comparison of these methods for your dataset?

        Comment

        Working...
        X