0
$\begingroup$

The data I am attempting to transform does not respond well to the traditional $\log (x + 1)$ transformation due to its distribution.

The data ranges from 0 to 52.99183.

The .RData file containing the data, the constant values, and the log.start function can be found at: Link to .RData

According to the code posted in this post: Choosing c such that log(x + c) would remove skew from the population , the $C$ value should be 0.001821598. I have plotted the data using R's density function and have attached the before and after photos below. Before Transformation After Transformation

Is it acceptable to use a value of $C$ which is smaller than 1 in order to transform the data? I would assume $C$ is any real number; however, I am not as well caught up on data transformations as I wish I was.

$\endgroup$
2
  • $\begingroup$ Hint: Suppose $x$ were originally in meters and then you changed it to kilometers. What should you use in place of $\log(x+1)$ in the new units? $\endgroup$
    – whuber
    Jul 8, 2015 at 19:43
  • 1
    $\begingroup$ log(x + 0.001)? $\endgroup$ Jul 8, 2015 at 19:44

1 Answer 1

3
$\begingroup$

I don't think there is anything traditional about this transformation, which divides statistical people right down the middle. In my view, which is shared by some, it's at best a fudge, but if you don't mind that, then any fudge that suits is defensible.

Specifically, on your example

  1. Contrary to the post, the transformation seems to work quite well for your data. The approximately symmetric distribution looks well behaved for most purposes.

  2. The density estimate may smooth over discreteness or granularity of real or at least notable scientific or statistical importance. In particular, the spike around -5 may reflect a minor mode at around 0.01 in the data.

Generally,

  1. Whatever you are doing, the reasons why some values are zero need consideration. The simplest situation is that the zeros could in principle have been positive, but that's just the way the data fell out. It's hard to add to that without substantive knowledge of what the variable is.

  2. It is not a good idea do to be over-fussy about estimating the constant $C$ which doesn't obviously have physical or other substantive meaning and may not be exactly replicated for another sample any way. The constant $C$ can be any positive number if $X \ge 0$: there is a rough logic to 1 if the data are counts, but evidently your data are measured, not counted. There is also a rough logic to $C$ being half the smallest positive number recordable; not all measurement methods make that a level you can identify. (To make this concrete, suppose that something could be reported as 0, 0.01, 0.02, and so forth; then $C = 0.005$ would be one choice.)

  3. Last, and most important, why is a transformation thought important here any way? For example, if this is a response or outcome variable, then some generalised linear model with logarithmic link is a better idea than an ad hoc transformation.

Note: Not all members here use R. I've not tried to access the data.

UPDATE The transformation is viewed in the question as a transformation to work on the distribution. The principle being invoked is perhaps that (nearly) symmetric distributions can be (much) easier to work with than (highly) skewed distributions, with nothing else said. (Note that this is not being presented as "distributions should be normal (Gaussian)", an enormously stronger assertion, and one often invoked unduly, especially when other principles are neglected.)

Another way to think about transformations (and if we had to choose which is more important, I would suggest this one) is to see what transformations do to functional relationships between variables. Again, a graph is crucial for thinking about this. Taking the range of the data here and the constant chosen, here is what the transformation does to the data:

enter image description here

The important qualitative feature here is that the smaller $C$ is, the more the very small values are stretched apart and the more the relatively large values are squeezed together. Concretely, with these data and this transformation, the range from 0 to 0.309 is rendered equal to that from 0.309 to 52.99. Whether that's a good idea, particularly biologically, is for a researcher familiar with this kind of data to decide, partly in view of how the downstream (*) multivariate analysis actually works out.

My instinct as a data analyst would be to prefer a gentler transformation here such as the cube root. That has qualitatively the same property of stretching apart low values and squeezing together high values; it is fairly easy to explain as being a mathematical idea that researchers should recall from their early education; it works automatically for zeros by mapping zeros to zeros; and for the more statistically-minded there is an arm-waving association as a transformation that works well for symmetrizing gamma distributions. More on this, including key points pertinent when values can be negative too, is given in this paper.

For comparison, here is a graph of the cube root over the same range:

enter image description here

The gentler curvature shows that it is a weaker transformation than the previous transformation, which does not mean poorer. Square roots are gentler yet; fourth roots, etc., would move the other way.

More generally, a plot of a transformation over the observed range of the data should often be made quickly to let you think about what it is doing. (A different kind of example leads to a realisation that the observed range of the data is so small that the effect of a transformation is very close to linear, raising the question of whether it is really needed.)

(*) All puns should be considered intentional.

$\endgroup$
7
  • $\begingroup$ The data are measurements of biomass of insects from a stream. The following procedure will be multivariate ordination including PCA and NMDS. $\endgroup$ Jul 8, 2015 at 20:07
  • $\begingroup$ If you would like to have access to the data, what format would you prefer? $\endgroup$ Jul 8, 2015 at 20:11
  • $\begingroup$ OK. For those purposes, I would say that approximate symmetry is not essential, but often convenient. Extreme skewness can certainly be problematic. $\endgroup$
    – Nick Cox
    Jul 8, 2015 at 20:11
  • $\begingroup$ Thanks; in this case the graphs seem clear and I don't particularly want to see the data. it's for you to think about that small spike and whether it means anything much. $\endgroup$
    – Nick Cox
    Jul 8, 2015 at 20:13
  • $\begingroup$ In this context of this data, the small spike could indicate a subset of individuals which have a similar biomass around 0.0067; however, I am not sure this is of interest to me. I expect the data to be quite varied due to its nature, but I would like to reduce this variation for downstream analysis. If I understand you correctly, you are saying the transformation I have suggested may be proper here? $\endgroup$ Jul 8, 2015 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.