Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Programming question

From   Mike Kim <>
Subject   st: Programming question
Date   Sun, 19 Jun 2011 10:32:12 -0500

Hi All,

I would like to get total effect after running the following two
separate regressions. Giw can I get m2 in the following program?

m1=direct effect of x1 on y1.
m2=indirect (mediated) effect of x1 on y1 through y2

capture program drop myprog
program define myprog, rclass
reg y1 y2 x1 x2  y2*x2
margins, dydx(y2)
   tempname m1 m2
scalar `m1' = _b[x1]
scalar `m2' = “want to get dydx(y2) here”
reg y2 x1 x3
tempname m3
scalar `m3' = _b[x1]
return scalar toteff =`m1'+`mx2'*`mx3'

return list

Thank you for your help in advance.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index