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]

st: Automating back-transforming variables


From   Eduardo Nunez <enunezb@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Automating back-transforming variables
Date   Fri, 20 Aug 2010 16:20:53 -0400

Dear Statalist,

I have a dataset  that needs to be imputed (I used ice) and has many
continuous variables. Because none of them achieved the normality
assumption, I decided to log-transform them before imputation. Once
the dataset was imputed, I need those variables back-transformed to
the scale they were initially.
This is my code:
------------------------------------------------------------------------------------
// looking for the most appropriate transformation

. qladder ca125
. ladder ca125
. lnskew0 lnca125= ca125

. qladder bnp
. ladder bnp
. lnskew0 lnbnp =bnp

Imputation with ice [include all log-transformed variables (in this
case lnca125 & lnbnp)]......dataset imputed [missing values
for log-transformed variables imputed (lnca125_i & lnbnp_i)]

// Back-transformation of imputed variables:

. ds lnca125, d
lnca125         float  %9.0g                  ln(ca125-2.120054)

. gen double ca125_i=exp(lnca125_i)+ 2.120054
. label var ca125_i "exp(lnca125_i)+ 2.120054"
. replace ca125_i=ca125 if ca125~=.

. ds lnbnp, d
lnbnp           float  %9.0g                  ln(bnp-1.681753)

. gen double bnp_i=exp(lnbnp_i)+ 1.681753
. label var bnp_i "exp(lnbnp_i)+ 1.681753"
. replace bnp_i=bnp if bnp~=.

------------------------------------------------------------------------------------
I wouldn't mind to do it for a couple variables. However, when you
have 30-40 continuous variables, you
start looking for ways to speed-up the process.

Any help on how to automate this back-transformation?


Best wishes,

Eduardo
*
*   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   |   Site index