Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: Programming question


From   Mike Kim <kalisperos@gmail.com>
To   statalist@hsphsun2.harvard.edu
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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index