Regression : Transform Negative Values (2024)

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 :

require(car)
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)
Regression : Transform Negative Values (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)

Related Posts

Statistics Tutorials : Top 50 Statistics Tutorials

Spread the Word!
ShareShareTweet

About Author:
Regression : Transform Negative Values (2)

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and HR.

While I love having friends who agree, I only learn from those who don't
Let's Get Connected Email LinkedIn

Regression : Transform Negative Values (2024)
Top Articles
Latest Posts
Article information

Author: Lakeisha Bayer VM

Last Updated:

Views: 6128

Rating: 4.9 / 5 (49 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Lakeisha Bayer VM

Birthday: 1997-10-17

Address: Suite 835 34136 Adrian Mountains, Floydton, UT 81036

Phone: +3571527672278

Job: Manufacturing Agent

Hobby: Skimboarding, Photography, Roller skating, Knife making, Paintball, Embroidery, Gunsmithing

Introduction: My name is Lakeisha Bayer VM, I am a brainy, kind, enchanting, healthy, lovely, clean, witty person who loves writing and wants to share my knowledge and understanding with you.