Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • log of negative value

    Hello,

    I am looking at the impact of deficit on an outcome variable (Spending). All variables are positve in my datset, except for deficit. People can sometimes have a deficit in their spending (postive value of deficit), or surplus (negative value). I wanted to take natural logs of these variables. However, taking a natural variable makes no sense if I have a surplus (negative value). Does anyone have suggestions?

    Thank you

  • #2
    Why do you want to take a logarithm of the deficit variable? If you have no real reason to do so, just use the variable as is. If you have a reason, explain what you are trying to accomplish with the logarithm and it may be possible to suggest a different approach that will accomplish that goal. You are quite right that log-transforming a variable with negative values makes no sense.
    Last edited by Clyde Schechter; 06 Aug 2022, 17:59.

    Comment


    • #3
      There is sometimes a case for transforming variables that are variously positive or negative, or indeed zero, which is possible here and quite commonly. The case could arise because

      1. Visualization is made easier thereby.

      2. A variable is so skew or long-tailed that a model fit is distorted, or at least you want to check how far results are sensitive to one or both tails of such a variable.

      3. The relationship involving problematic x is closer to what is postulated (e.g.) linear when x is transformed than not.

      There may be other reasons, but these spring to mind, and two or even three can arise together.

      Logarithm-like transformations that have been tried include so-called

      neglog which is sign(x) * log(1 + abs(x)) which behaves like log x for x >> 0, like x for x ~ 0 and like -log(- x) for x << 0. Note that Stata now has function log1p(), so this is better computed as sign(x) * log1p(abs(x)).

      asinh, or asinh(x) which is a sister under the skin and can be tuned by asinh(k * x) for some suitable k. In other wording, this is the inverse hyperbolic sine or even IHS, an abbreviation which is disturbing to those accustomed to other uses of IHS.

      On the other hand:

      cube root when implemented as sign(x) * abs(x)^(1/3). A little thought shows that other odd integer roots with powers 1/5. 1/7, .... have qualitatively similar behaviour. although I can't recall examples of any of those in statistical applications, beyond cube root. Watch out: although every high school graduate should ideally know that -2 is the cube root of -8, you can't get there in Stata with (-8)^(1/3) as explained in excruciating detail in https://www.stata-journal.com/articl...article=st0223

      Cube roots can arise quite naturally, as when the cube root of a volume is a length, or statistically (e.g. to a very good approximation the cube root of a gamma distribution is a normal distribution), but if used for negative, zero, positive variables expect reactions from reviewers between puzzlement and hostility. That can happen with the other transformations mentioned here too.

      The reaction to any of these may be that they are ad hoc, which here can be translated positively as "fir for purpose".

      I

      Comment


      • #4
        #3 I meant fit for purpose.

        Comment

        Working...
        X