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, statalist.org is already up and running.


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

Re: st: marginsplot and transformed dependent variable


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
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.black 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))
marginsplot
*------------------- end example -------------------
 (For more on examples I sent to the Statalist see:
 http://www.maartenbuis.nl/example_faq )

---------------------------------
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index