Transforming Data for Valid Statistical Analysis: Counts, Percentages and Proportions

The featured image shows the title across a background of women looking at data on a computer

By Roger Payne and Vanessa Cave

Why Transform Data?

To ensure the validity of your statistical analysis, it is important that the assumptions are met. For example, underpinning ANOVA there are several important assumptions, including that the residuals are Normally distributed and with constant variance. Failures of the assumptions can often be corrected by transforming the data, with different transformations appropriate for different types of data. In this blog, we look at three common types of data requiring transformations: counts, percentages and proportions. 

Transformations for Count Data

Count data occur where an experiment captures the occurrences of some event with no preset upper limit. For example, the number of accidents occurring on a section of road, numbers of hits on a website, numbers of weed plants in a plot, and so on.

A general assumption in many statistical analyses is that the variability of the response variable is constant (i.e., homogeneous) across grouping variables and predictor variables. However, the variability of count data typically increases with the mean of the response.

Conventional wisdom is to stabilize the variance, using a square-root transformation. However, if the treatments result in a proportionate increase (or decrease), the square-root transformation will not provide an additive model. (In an additive model, the effect of a treatment is a constant increase or decrease. It is very difficult to draw conclusions from a non-additive model, as the size of a predicted effect will depend on the underlying value of the response. You may also detect meaningless interactions that are merely caused by the scale.) On the other hand, a logarithmic transformation would give an additive scale for the treatments. Moreover, often it will also adequately stabilize the variance.

A graph showing the correlation between the number of plants and treatment

Zero counts pose a problem when log-transforming data as log 0 is undefined. To deal with zero counts, it is usual to add a constant to the response y before taking the logarithms. For example, LOG10(y+1) or LN(y+0.5). However, it does matter what constant you add! Thus, you must check that the constant you add (best) makes the log-transformed data conform to the assumptions of the analysis you’re performing. In the plots below, 0.1, 0.5, and 1 have been added to the count data above before natural log-transformation. Note, though, that an advantage of adding 1 is that zero transforms to zero, and the transformed values are all positive.

A graph showing the correlation between the number of plants and treatment
A graph showing the correlation between the number of plants and treatment
A graph showing the correlation between the number of plants and treatment

Transforming Proportion and Percentage Data

Proportion or percentage data can arise in several ways. Sometimes, the response variable is
a natural continuous percentage measure. For example, the percentage area of a plot that
has been infected by a disease, or the percentage of plasma in a blood sample. Alternatively, the data may count the number of occurrences (r) of some event in a population of fixed size n (i.e., binomial data). For example, the number of children vaccinated out of a class of 30, or the number of infected plants out of a sample of 100. Binomial data can be converted to percentages (p=100×r/n) for analysis.

A classic feature of Binomial data is that the variability is greatest when the mean of the response is 50%, and it becomes less variable as the mean approaches 0% and 100%. This pattern is also typically seen in data representing a continuous percentage.

Analysts often stabilize the variance of percentage data by taking an angular transformation, arcsin(sqrt(p /100)). However, this will generally not give an additive model, so it may be better to use a logit transformation, LN(p/(100-p), instead. In addition, the logit transformation maybe preferable, as unlike the angular transformation, it has an intuitive interpretation, representing the odds on a logarithmic scale.

A graph showing the correlation between the percentage of plasma and treatment

Values of 0 and 100% pose no issue for the angular transformation, however they do for the logit
transformation. For Binomial data, 0 or 100% can be handled by calculating the percentage as
p=100×(r +0.5)/(n +1). For percentage data, you’ll need to use a different trick: remapping the
percentages to the interval (c, 100-c) prior to transformation. Again, it does matter what constant c
you use, so care must be taken.

Making Sense of Transformed Results

If you are analysing transformed data, it is important to remember that the statistical properties of the analysis apply only on the transformed scale. So, for example, comparisons between means must be assessed on the transformed scale (i.e., using the tables of means and s.e.d.’s, or l.s.d.’s, from the analysis of the transformed data).

For interpretation, though, it is often helpful also to present the tables of means back-transformed to the original scale. Transforming an estimated mean back to the original scale is fairly straightforward: we just apply the inverse function of the transformation. For example, to “reverse” the square-root transformation, we take the square. Or to “reverse” the natural log transformation, we take the exponential. However, if you want to back-transform the standard-errors, this is not quite so simple!

To find out how to calculate an approximate standard error for a back-transformed mean, check out the blog Back-transforming standard errors using the Delta method.

Transformation or Generalized Linear Model?

As an alternative to transforming the response, you should consider whether a Generalized Linear Model is more appropriate for your purposes. To find out more, check out the blog Are you linked or transformed? Data transformation vs links in Generalized Linear Models. 

If you’re interested in learning more about data analysis, head to our E-Learning catalog to see all the courses on offer.

Have a specific dataset in mind? Contact our team for expert advice – you can use a contact form or pre-book a slot for a call with one of our experts.

Picture of Dr. Vanessa Cave
Dr. Vanessa Cave
Dr. Vanessa Cave is an applied statistician interested in the application of statistics to the biosciences, in particular agriculture and ecology, and is a developer of the Genstat statistical software package. She has over 15 years of experience collaborating with scientists, using statistics to solve real-world problems. Vanessa provides expertise on experiment and survey design, data collection and management, statistical analysis, and the interpretation of statistical findings. Her interests include statistical consultancy, mixed models, multivariate methods, statistical ecology, statistical graphics and data visualisation, and the statistical challenges related to digital agriculture. Vanessa is a past President of both the Australasian Region of the International Biometric Society and the New Zealand Statistical Association, on the Editorial Board of The New Zealand Veterinary Journal and an honorary academic at the University of Auckland. She has a PhD in statistics from the University of St Andrew.

Comments

5 Responses

  1. It was an interesting read. However, I do have a question. For ANOVA to be valid for a large data set, is it not necessary that the response variable (such as body weight) follows a normal distribution?
    How much deviation in the residuals is generally permissible to indicate that the data follows a normal distribution? Does it have to be very strict, or are slight deviations ok to proceed with?
    If the response variable is count data or a proportion, is it always required to transform it before proceeding to ANOVA, even if it is normally distributed and the residuals are also normally distributed? How to decide whether which transformation is better the sqrt or log for count data, or the arcsine or logit for the proportion?

    1. Hello Mujahidkhan,

      Thank you so much for your comment.

      ANOVA (and other methods like linear regression and mixed models) are quite robust to moderate departures from Normality, so we don’t have to be overly strict. In my opinion, the best way to assess the Normality assumption is to inspect the residual plots. If the histogram is approximately symmetrical and the Normal Q-Q plot follows a reasonably straight line, I’m happy. (See https://vsni.co.uk/checking-those-all-important-anova-residual-diagnostic-plots/ for more on this).

      FYI – I generally avoid using hypothesis tests for Normality. With large datasets, they can detect very minor, and often irrelevant, departures from Normality, while with small datasets, they tend to lack power. (I discuss this further in an older blog: Beyond the P-Value: Rethinking Normality & Homogeneity Tests.)

      It’s also worth noting that while Normality is important, homogeneity of residual variance is often more critical in ANOVA. Unequal variances can lead to incorrect standard errors and, as a result, misleading conclusions. So, it’s always important to also check the plot of the residuals against the fitted values for any “fanning out” – indicating unequal variances.

      And no, it’s not always necessary to transform count or proportion data—sometimes the residual assumptions are adequately met without transformation. For example, when proportion data falls within the range of approximately 0.3 to 0.7, the Normality assumption often holds reasonably well. Similarly, if count values are relatively high, assuming Normality can also be appropriate.

      Regarding which transformation to use, I typically start with the log for count data and the logit for proportion data, as these have intuitive interpretations. If those don’t result in adequate alignment with the residual assumptions, I might try the square-root or the arcsine square-root transformation.

      And one final crucial point … our decision to transform (or not), and which transformation to use, should be made independently of the analysis results. For example, we should never choose a transformation simply because it leads to a significant treatment effect in the ANOVA. Instead, our choice should be guided by whether the residuals are acceptable and whether the transformation makes sense for the data.

      Thanks again!
      Vanessa

Leave a Reply

Your email address will not be published. Required fields are marked *

Related articles

How much of the variation in your field trial comes from the treatments, and how much comes from...
What should you do when count data are more variable than your model expects? Vanessa Cave and David...
Precision breeding can deliver scientifically impressive traits, but practical value depends on more than technical success. Owen McIntosh...