Lably
Skip to content

Log transformation (statistics)

Transforming data by taking the logarithm

  • 12 min read
  • 4 chapters

Related on Lably

Through Statistics, Function (mathematics) and Data

The log transform is invertible, continuous, and monotonic. The transformation is usually applied to a collection of comparable measurements. For example, if we are working with data on peoples' incomes in some currency unit, it would be common to transform each person's income value by the logarithm function.

Motivation

Guidance for how data should be transformed, or whether a transformation should be applied at all, should come from the particular statistical analysis to be performed. For example, a simple way to construct an approximate 95% confidence interval for the population mean is to take the sample mean plus or minus two standard error units. However, the constant factor 2 used here is particular to the normal distribution, and is only applicable if the sample mean varies approximately normally. The central limit theorem states that in many situations, the sample mean does vary normally if the sample size is reasonably large. However, if the population is substantially skewed and the sample size is at most moderate, the approximation provided by the central limit theorem can be poor, and the resulting confidence interval will likely have the wrong coverage probability. Thus, when there is evidence of substantial skew in the data, it is common to transform the data to a symmetric distribution before constructing a confidence interval. If desired, the confidence interval can be constructed for statistics in the original scale, such as the median or the mean, by transforming back to the original scale using exponent (with some adjustments for CI for the mean), the inverse of the log transformation that was applied to the data. it is possible to estimate a quantile using different methods, build a CI for it, and then transform these back to the original scale so to have a CI for the quantile in the original scale. For example, it's possible to estimate the location of the median, after the log transformation, using the arithmetic mean. Then build CI for the median using a CI for the mean and transform the CI back to the original scale using exponent. That transformed CI is then a CI for the median, not the mean.

Data can also be transformed to make them easier to visualize. For example, suppose we have a scatterplot in which the points are the countries of the world, and the data values being plotted are the land area and population of each country. If the plot is made using untransformed data (e.g. square kilometers for area and the number of people for population), most of the countries would be plotted in tight cluster of points in the lower left corner of the graph. The few countries with very large areas and/or populations would be spread thinly around most of the graph's area. Simply rescaling units (e.g., to thousand square kilometers, or to millions of people) will not change this. However, following logarithmic transformations of both area and population, the points will be spread more uniformly in the graph.

Another reason for applying the log data transformation is to improve interpretability, even if no formal statistical analysis or visualization is to be performed.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Statistics