Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: marginsplot and transformed dependent variable

From   Maarten Buis <>
Subject   Re: st: marginsplot and transformed dependent variable
Date   Thu, 25 Apr 2013 09:28:14 +0200

On Thu, Apr 25, 2013 at 7:11 AM, Tom Robinson wrote:
> If I transform the dependent variables (log or inverse) the models are much
> better.  But then it is difficult to present the results to a general
> readership.  Is it possible to take the transformed margins estimates and
> un-transform them?  When I do it by hand they don't look right so maybe
> this doesn't make sense.

The problem is you are now modeling the mean(log(y)) or mean(1/y) and
exp(mean(log(y))) != mean(y) or 1/(mean(1/y))) != mean(y) as the
inverse and the log transformation are nonlinear transformations. The
best way to avoid this problem is not to use linear regression on
transformed variables but a GLM (using the aptly named -glm- command)
with the link function of your choice (log or inverse). That way you
are still modeling the transformed mean of y rather than the mean of
transformed y.

Below is an example were I model the log of mean wage with a quadratic
term and an interaction and use -marginsplot- to see the results.

*------------------ begin example ------------------
sysuse nlsw88, clear

gen byte black = race == 2 if race < 3
label variable black "race"
label define black 0 "white" ///
                   1 "black"
label value black black

gen byte edcat = cond(grade <  12, 1,     ///
                 cond(grade == 12, 2, 3)) ///
                 if grade < .
label define edcat 1 "less than high school" ///
                   2 "high school"           ///
                   3 "more than high school"
label value edcat edcat
label variable edcat "education in categories"

glm wage i.south i.union i.edcat##c.ttl_exp##c.ttl_exp, ///
    link(log) vce(robust)

margins, at(ttl_exp=(.5(.5)20) south=0 black=0 union=0 edcat=(1 2 3))
*------------------- end example -------------------
 (For more on examples I sent to the Statalist see: )

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

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