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: graphing interaction when direct effect is curvilinear


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: graphing interaction when direct effect is curvilinear
Date   Wed, 12 Sep 2012 10:47:51 +0200

On Wed, Sep 12, 2012 at 9:48 AM, L.M.A. Mulotte wrote:
> I would like to graph interaction effects for an OLS when the direct effect is curvilinear.
>
> Specifically, I would like to graph the impact of Z on the curvilinear relationship between Y and X, for Z being held at means plus 1 one SD and at means minus 1 SD, and all other variables being held constant. I would be very grateful for any advice.
<snip>
> The graph I would like to draw has the following characteristics
> -       Vertical axis is ln_wage
> -       Horizontal axis is age
> -       one inverted-U shaped curve for birth_yr held at means plus one SD, keeping other variables constant.
> -       one inverted-U shaped curve curve for birth_yr held at means minus one SD, keeping other variables constant.

Here is an alternative graph you could consider:

*-------------------- begin example -----------------
sysuse nlsw88, clear
//estimate the model
glm wage c.ttl_exp##c.ttl_exp##c.grade##c.grade  ///
         i.race south hours union,               ///
     link(log) vce(robust)

// predict wage	
tempfile marg
qui margins, at(ttl_exp==(.1 .5 1 2(2)28)        ///
                grade==(0(2)18)                  ///
                race==1 south==0                 ///
                hours==40 union==1)
_marg_save, saving(`marg')
clear
use `marg'

// graph wage
twoway contour _marg _at1 _at2,                  ///
    ccuts(0(1)14) xlab(0(5)15) ylab(0(5)25)      ///
    plotregion(margin(zero)) name(pred, replace)

// that graph looks pretty, but beware:
// it contains quite a few extrapolations to
// areas where there is no data	
sysuse nlsw88
scatter ttl_exp grade, xlab(0(5)15) ylab(0(5)25) ///
    name(scatter, replace)
*--------------------- end example ------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )

I learned this from Bill R.
(<http://econpapers.repec.org/paper/bocchic11/19.htm>)

Notice that you are not using an OLS but a linear regression model;
the former is the algorithm used to compute the coefficients, the
later is the model.

Also notice that it is usually a bad idea to use linear regression on
a log transformed dependent variable. Much better to use -glm- with
the -link(log)- option or -poisson-, both with -vce(robust)-. See:

Nicholas J. Cox, Jeff Warburton, Alona Armstrong, Victoria J. Holliday
(2007) "Fitting concentration and load rating curves with generalized
linear models" Earth Surface Processes and Landforms, 33(1):25--39.
<dx.doi.org/10.1002/esp.1523>

or:

<http://blog.stata.com/2011/08/22/use-poisson-rather-than-regress-tell-a-friend/>

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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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