Announcement

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

  • Mediation using xtreg (indirect, direct, and total effects)

    Dear Stata Users

    I'm currently testing a mediation model with a panel data structure using xtreg in Stata.
    This is because it appears the gsem command is incompatible with a panel data structure.

    The logic of the mediation model is based on Baron & Kenny (1986), where

    1. Explanatory variable is significantly associated with the mediator
    2. Mediator is significantly associated with DV
    3. When explanatory variable and mediator are included together, the influence of the explanatory V is reduced.

    Thus, my code looks something like:
    Code:
    xtreg M IV $key_control  i.year 
    xtreg DV M $key_control i.year 
    xtreg DV IV M $key_control i.year
    Afterwards, I'm trying to calculate the
    1. indirect effect of the explanatory variable mediated by the mediator
    2. direct effects of both the explanatory variable and the mediator on the DV
    3. the total effects of the explanatory variable and the mediator on the DV

    with the boot estimates, standard errors, and the confidence intervals.

    Doing this was not challenging with gsem, but I'm currently stuck on how I should proceed when using the xtreg command.
    I think there should be a way to simultaneously run the models, but I am not sure.

    There was a similar thread that I attach, but the contents appeared inconclusive
    https://www.statalist.org/forums/for...sing-bootstrap

    If you have any advice on the matter, I would greatly appreciate it.
    Thank you.

  • #2
    To my knowledge, Stata does not have a command that estimates simultaneous -xtreg- models. But, you are doing -xtreg, re-, which is the simplest case of a random effects model. You can do random effects models in -gsem-, and do them simultaneously:

    Code:
    gsem (M <- IV `key_control' i.year U1[panel_var]) (DV<- M IV `key_control' i.year U2[panel_var])
    U1 and U2 are latent variables that serve as random intercepts at the panel variable level.

    Comment


    • #3
      Thank you so much for the response Dr. Schechter

      I have tried your code and unfortunately Stata returns the message:
      cannot compute an improvement -- discontinuous region encountered

      Without seeing the data I understand that this may be difficult to interpret, but do you have any wisdom or general advice on this matter?
      Thank you in advance.

      Comment


      • #4
        So it's having trouble converging. Likelihoods for these structural equations models can be very complicated and messy to work with. These problems can be difficult--and sometimes there is no solution found after lots of effort.

        I would recommend retrying the model without the random effects,, and storing those estimates in a matrix. Then use the matrix as a starting point for the full model and see if you can get it to converge that way.
        Code:
        gsem simplified model
        matrix b = e(b)
        gsem original model, from(b)
        If it doesn't work just removing the random effects, try removing some, or all, of the "key control" variables as well.

        Comment


        • #5
          Thank you Dr. Schechter

          I've tried your suggestions and it seems it may be one of those cases where "there is no solution found after lots of effort".
          No matter whether it is a simplified model, the gsem model fails to converge.

          Nonetheless, I greatly appreciate your help in the matter.
          If anything else comes to your mind, please share your thoughts or advices with me.
          Thank you.

          Comment

          Working...
          X