Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Automating back-transforming variables
From
Eduardo Nunez <[email protected]>
To
[email protected]
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/