Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Programming question
From
Mike Kim <[email protected]>
To
[email protected]
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'
end
myprog
return list
-----------------------------------
Thank you for your help in advance.
Mike.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/