Statalist


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

Re: st: Convert log tranformed data


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Convert log tranformed data
Date   Sun, 21 Dec 2008 10:34:12 +0000 (GMT)

--- Nikolaos Pandis <npandis@yahoo.com> wrote:
> I have transformed some continuous data into log scale. I run a
> linear regression analysis and I was wondering if there is an easy
> way to convert the coefficients and confidence intervals back to the
> original data scale.

You have two options: 
1) You can use the -eform()- option in -regress-. The results can be
interpreted as the factor by which the geometric mean of the dependent
variable in the original metric changes for a unit change in the
explanatory variable. The constant is the geometric mean of the
dependent variable in the original metric when all explanatory
variables are zero. This is discussed in (Newson 2003).

2) You can estimate your model with -glm- with the -link(log)- and
-eform- options. The results can be inerpreted as the factor by which
the arithmetic mean of the dependent variable in the original metric
changes for a unit change in the explanatory variable. The constant is
the arithmetic mean of the dependent variable in the original metric
when all explanatory variables are zero.

I am now indulging in my favorite feature request. An annoying result
of the -eform- option in Stata is that it suppresses the display of the
constant. So in the two options I have given you above I told you how
to interpret the constant, if you just add the -eform- option you won't
see it. The way to see it is to create a new variable called cons (or
baseline or one) which has the value 1, and add that to the model
together with the -nocons- option, and in case of -regress- also add
the -hascons- option. It would be so much easier if Stata did not
suppress the display of the constant, but for now we will have to work
with this indirect solution.

Consider the example below, and remember that -regress- of a log
transformed dependent variable with the -eform- option gives results in
terms of the geometric mean, while -glm- gives results in terms of the
arithmetic mean. Someone with average years of education (grade), years
of experience (ttl_exp), tenure, age, and is not a member of a union
has a geometric mean wage of 6.28 dollars an hour and a arithmetic mean
wage of 7.02 dollars an hour. A year extra in school will increase the
geometric mean wage by a factor of 1.080 (i.e. 8.0%) and the arithmetic
mean wage by a factor of 1.082 (i.e. 8.2%).

*-------------------- begin example ---------------------
sysuse nlsw88, clear
gen ln_w = ln(wage)
gen cons = 1

// center the continuous variables
// to create a meaningful constant 
foreach var of varlist grade ttl_exp tenure age {
	sum `var', meanonly
	gen c_`var' = `var' - r(mean)
}

reg ln_w c_grade union c_ttl_exp c_tenure c_age cons, ///
         eform("exp(b)") nocons hascons

glm wage c_grade union c_ttl_exp c_tenure c_age cons, ///
         link(log) eform nocons
*--------------------- end example ----------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

Roger Newson (2003) Stata tip 1: The eform() option of regress, The
Stata Journal, 3(4): 445.
http://www.stata-journal.com/article.html?article=st0054

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


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