Bookmark and Share

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]

Re: st: xtmixied: Marginal Effect with Interactions


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: xtmixied: Marginal Effect with Interactions
Date   Mon, 30 Aug 2010 09:43:18 +0000 (GMT)

--- On Sun, 29/8/10, Guy Grossman wrote:
> I am using Stata 10.1 on Mac to estimate the following
> model:
> 
> xtmixed change x1 x2 x1Xx2 c1 c2 c3 c4 c5  || group:
> || id:, mle nolog
> 
> in which both x1 and x2 are dummies and x1 is a treatment
> variable in a randomized experiment. I have two questions:
> 
> 1. how can I calculate the effect of x1 conditional on
> x2==1, while setting the control variables to their mean
> (continuous variables) or median (categorical)?

-xtmixed- is a linear model so there is no need to fix the 
other covariates, as the marginal effect will be the same 
regardless of what value you fix them at. Since x2 is a 
dummie, x1 has basically two effects: the effect when 
x2 is 0 and the effect when x2 is 1. The former is just the
coefficient of x1 the latter is the coefficient of x1 + 
the coefficient of x1Xx2. You can use -lincom- for that.
See -help lincom- and the example below.
 
> 2. what do you suggest would be the best way to graphically
> present the results given that both x1 and x2 are dummies?

Below is one sugestion:

*---------------- begin example -----------------
webuse productivity, clear
// create some dummies and the interaction variable
sum private, meanonly
gen x1 = private > r(mean)
sum emp, meanonly
gen x2 = emp > r(mean)
gen x1Xx2 = x1*x2

// estimate the model
xtmixed gsp x1 x2 x1Xx2 hwy water other unemp || region: || state:, mle

// get the effect of x1 when x2 == 1
lincom x1 + x1Xx2


// turn the estimates into variables, so they
// can be graphed
gen x = 1 in 1
gen y = r(estimate) in 1
gen lb = y - invnormal(0.975)*r(se) in 1
gen ub = y + invnormal(0.975)*r(se) in 1

replace x = 0 in 2
replace y = _b[x1] in 2
replace lb = y - invnormal(0.975)*_se[x1] in 2
replace ub = y + invnormal(0.975)*_se[x1] in 2

// the graph
twoway scatter y x ||                   ///
       rcap lb ub x,                    ///
       xlab(0 1)                        ///
       xscale(range(-.5 1.5))           ///
       xtitle(x2)                       ///
       ytitle(effect x1)                ///
       legend(order(1 "effect"          ///
                    2 "conf. interval"))
*---------------- end example ------------------
(For more on examples I sent to the Statalist see: 
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index