Regression : Transform Negative Values

Live Online Training : Predictive Modeling using SAS

- Explain Advanced Algorithms in Simple English
- Live Projects & Case Studies
- Domain Knowledge
- Job Placement Assistance
- Get 10% off till Sept 25, 2017
- Batch starts from October 8, 2017

In linear regression, box-cox transformation is widely used to transform target variable so that linearity and normality assumptions can be met. But box-cox transformation can be used only for strictly positive target values. If you have negative values in your target (dependent) variable, the box-cox and log transformation cannot be used.

How to handle negative data values

1. Cube Root (Power- 1/3)
Cube root can be used to transform negative, zero and positive data values. The best part about this transformation is it is very easy to perform 'back transformation' of this form to get back real values.

Back Transformation : Cube of the transformed value

2. Yeo-Johnson Power Transformations

It is an extension of Box cox transformation. It allows transformation of negative values.

R Code :
lambda.fm1 <- boxcox(mydata$y ~ mydata$x1 + mydata$x2), family="yjPower")
lambda.max <- lambda.fm1$x[which.max(lambda.fm1$y)]
mydata$y = yjPower(mydata$y, lambda=lambda.max, jacobian.adjusted=FALSE)
It can be easily implemented manually. Look at the property shown below :
For Y  <  0 ===> - log( -y + 1)
For Y >= 0 ===>   log( y + 1)
Yeo-Johnson Power Transformation
LN : Natural Log (base e)

With both negative and positive values, the transformation is a mixture of these
two, so different powers are used for positive and negative values. In this latter case,
interpretation of the transformation parameter is difficult, as it has a different meaning
for y<0 and y>=0.

3. Adjusted Log Transformation
= log(1+Y-min(Y))
Note : Both log to base e and log to base 10 can be used.

Back Transformation :  = exp(transformed value) -1+ min(Y)

Statistics Tutorials : 50 Statistics Tutorials

About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has close to 7 years of experience in data science and predictive modeling. During his tenure, he has worked with global clients in various domains like retail and commercial banking, Telecom, HR and Automotive.

While I love having friends who agree, I only learn from those who don't.

Let's Get Connected: Email | LinkedIn

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

1 Response to "Regression : Transform Negative Values"

  1. Isn't the cube root of a negative number another negative number too?


Next → ← Prev