Section outline

  • Mediation and Effect Decomposition, part 2

     
    Faculty:  

    Location:  Rock Hall 102

    • Watch URL
    • Required Reading:

      1. Readings are the same as from last week re mediation.

    • Assignment: Optional narrative description

      Specify a hypothesis regarding a binary exposure, a continuous mediator, and a continuous outcome.  Specify how each variable affects its children (i.e., how the exposure influences the mediator) and the distribution of the random or unmeasured determinants of the child variables. 

      Using the software of your choice, generate a population with 10000 people under a causal structure consistent with this hypothesized causal structure. Use a conventional Baron-Kenny decomposition to estimate the direct and indirect effects of the exposure on the outcome.  

      Now introduce a confounder of the mediator and outcome (C) into your causal model.  Define the new causal models and simulate a new data set.  Use a conventional decomposition without control for the confounder first and then with control for the confounder to derive estimates of the direct and indirect effects of exposure on outcome. 

      Create a new version of the mediator that represents a badly measured version of that variable, for example by taking the original variable and adding some random noise to it.  Now use that mediator to evaluate the direct and indirect effects. 

      Now try estimating the CDE: 

      (1) make an identifier for your data (in stata, "gen id=_n")

      (2) make 3 copies of every observation (in stata, use "expand 3"); now you have 2 fake copies of each observation and one real copy.

      (3) for the first "fake" copy of each observation, set x to 0 and m to 0 and y to .  (missing)

      (4) for the second "fake" copy of each observation, set x to 1, m to 0 and y to . (missing)

      (5) estimate a regression model predicting the outcome as a function of exposure, mediator, the interaction of the exposure and mediator,  and the mediator-outcome confounder (C), using only the real observations.

      (6) for the first fake copy of each observation, use the predict statement to predict the counterfactual value of y,    setting x to 0 and m to 0

      (7) for the second fake copy of each observation, use the predict statement to predict the counterfactual value of y    setting x to 1 and m to 0

      (8) estimate the controlled direct effect of x on y, setting m to 0

      /* Bonus hw if you're having fun. 

      Go back to your original data (before you calculated the CDE

      (1) make an identifier for your data (in stata, "gen id=_n")

      (2) make 3 copies of every observation (in stata, use "expand 3"); now you have 2 fake copies of each observation and one real copy.

      (3) for the first "fake" copy of each observation, set x to 0 and m to . and y to . 

      (4) for the second "fake" copy of each observation, set x to 1, m to . and y to .

      (5) estimate a regression model predicting the mediator as a function of x and c, using only the real observations

      (6) predict cf_m_x0 in the first fake copy

      (7) predict cf_m_x1 in the second fake copy

      (8) estimate a regression model predicting the outcome as a function of exposure, mediator, the interaction of the exposure and mediator,  and the mediator-outcome confounder (C), usin gonly the real observation

      (9) in the first fake copy, set m to cf_m_x0 and set x to 1

      (10) in the second fake copy, set m to cf_m_x1 

      (11) in the first fake copy,  predict y based on the regression model in (8), to estimate cf_y_x1_cf_m_x0

      (12) in the second fake copy, predict y based on the regression model in (8), to estimate cf_y_x1_cf_m_x1

      (13) estimate the natural indirect effect of x on y, mediated by m

      */

      If you need coding hints for any of the above, see the scribbles above under "HWMediation"