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 at the end of May, and its replacement, is already up and running.

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

Re: st: graphing interaction when direct effect is curvilinear

From   Maarten Buis <>
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.
> 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')
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: )

I learned this from Bill R.

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.



Hope this helps,

Maarten L. Buis
Reichpietschufer 50
10785 Berlin
*   For searches and help try:

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