I have a continuous dependent variable which has a somewhat skewed distribution and hence I want to apply a log transform to it. But the problem is that the target variable can have negative values.

To counter this, I added the minimum(target variable) +1 to the target variable and then did a log transform. This was done on the training data.

The problem with this approach is that in my holdout data, I can have a value that is lower than the minimum value and in that case, I'll be attempting a log transform on negative data which will return an error.

Is there a way I can log transform a continuous dependent variable that may have negative values without having to bother about them?

  • 2
    $\begingroup$ Consider cube root, $\text{sign}(x) \log (1 + |x|)$ or inverse hyperbolic sine which all treat positive and negative values symmetrically and map 0 to 0. I'll mention Lambert's W and others can add advocacy if they wish. $\endgroup$
    – Nick Cox
    Apr 11, 2018 at 8:25
  • $\begingroup$ The title alone of the suggested duplicate suggests that it is not a good fit as it specifically mentions non-negative data. But looking at the answers shows that all the possibilities identified in my first comment for data including negative values are mentioned at length in that thread. $\endgroup$
    – Nick Cox
    Apr 11, 2018 at 8:33
  • $\begingroup$ @NickCox. Thanks for the link. I found a couple of useful suggestions: Yeo-Johnson and sign(y)*(log(|y|+1)) $\endgroup$ Apr 11, 2018 at 8:54
  • $\begingroup$ @NickCox, found your work here: fmwww.bc.edu/RePEc/bocode/t/transint.html. $\endgroup$ Apr 11, 2018 at 9:10


Browse other questions tagged or ask your own question.