Announcement

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

  • obtaining p values after KHB disentangle

    Hello,

    I'm using Stata MP/16.1 and the user written command khb

    I have the following multiple mediation model
    Code:
    khb logit y i.x || i.m1 i.m2 m3, concomitant(age sex) summary disentangle verbose

    Question 1: I want to obtain the p value for each of the indirect effects - but i cant work out how to do it...

    From reading other posts on here, i think i need to extract the coef and se from the matrix for disentangle and apply the correct formula to get the p values - but im stuck and i cant work out how to do this. Would be very grateful if someone could point me in the right direction.

    So far i have obtained the correct matrix using
    Code:
    matrix list e(disentangle)
    But when i run the following i get nothing, it doesnt display the p value (not even an error msg), so not sure where im going wrong
    Code:
    local t =b[1,1/b[1,2]
    di 2*ttail(e(df_r),abs(`t'))
    Question 2: is it necessary to present the p value for each indirect effect or is it enough to show that the direct effect of the mediators on y is significant (or not)?

    Thank you,
    Joanna

  • #2
    Slept on this and realised the basic mistake i was making...i need z not t!

    So, the solution to get the p values for anyone else struggling with this...

    Code:
    matrix list e(disentangle)
    mat b = e(disentangle)
    /*get z score*/
    di b[1,1]/b[1,2] /*to divide coef by se, corresponds to position on matrix*/
    /*get p value*/
    di 2*normal(-abs(z)) /*NB i manually added z but could probably automate*/
    /*get ci*/
    di b[1,1] - invnormal(0.975)*b[1,2]
    di b[1,1] + invnormal(0.975)*b[1,2]
    all helpfully explained here: https://www.stata-journal.com/sjpdf....iclenum=st0137

    Comment


    • #3
      The code in #2 does not actually define z. Here is a revised version that does

      Code:
      /*get z score*/
      scalar z = e(disentangle)[1,1] / e(disentangle)[1,2]
      /*get p value*/
      di 2*normal(-abs(z))
      /*get ci*/
      di e(disentangle)[1,1] - invnormal(0.975)*e(disentangle)[1,2]
      di e(disentangle)[1,1] + invnormal(0.975)*e(disentangle)[1,2]

      Comment

      Working...
      X