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: Ploting marginal effects extracted with -nlcom- when -margins- isn't an option (and therefore marginsplot as well)


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Ploting marginal effects extracted with -nlcom- when -margins- isn't an option (and therefore marginsplot as well)
Date   Thu, 16 Jan 2014 09:54:49 +0100

On Thu, Jan 16, 2014 at 8:50 AM, Suyin Chang wrote:
> In the last days I've found a past reply from Mark Schaffer (and I've
> asked some follo-ups myself) on how to extract marginal effects of
> interactions in models fitted with -ivreg2-, as this command is not
> yet integrated to -margins-.
>
> So, Mark gave an easy workaround with -nlcom- that may be quite useful
> in many cases of commands that do not work with -margins-:
>
>    sysuse auto, clear
>    gen mpgturn=mpg*turn
>
>    regress price mpg turn mpgturn
>    forvalues x=31(1)51 {
>            nlcom _b[mpg] + _b[mpgturn]*(`x')
>    }
>
> The only problem is while -margins- makes it very straight-forward to
> plot the marginal effects through -marginsplot-, the above solution
> using -nlcom- of course does not have such facility.

I would change the data such that it covers the grid you want to plot
over and fixes all other covariates, and than use -predictnl- to
compute the relavant values. -predictnl- has the added bonus that it
makes it easy to also compute confidence intervals. After that you can
just use straightforward graphing commands in Stata.

I wrote a Stata tip just before the release of Stata 12 that
illustrated that trick. I withdrew that submission after the release
of Stata 12 as -marginsplot- pretty much did what I showed you could
do with -predict- or -predictnl-. Anyhow, the tip, together with some
extra examples, can be read here:
http://www.maartenbuis.nl/wp/inter_quadr/inter_quadr.html

Hope this helps,
Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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