PDF
Contents
  1. About this book
  2. 1. Foreword
Planning a Study
  1. 2. A Few Words About Causality
  2. 3. Variance and Error
  3. 4. Design
  4. 5. Effect Size and Power
  5. 6. Sample Size
Describing and Preparing Data
  1. 7. Describing Data
  2. 8. Assumptions and Outliers
  3. 9. Normalization, Standardization, and Data Transformation
Comparing Groups
  1. 10. t-Tests and Their Rank-Based Alternatives
  2. 11. Equivalence Testing
  3. 12. ANOVA: Analysis of Variance
  4. 13. Factorial ANOVA and Interactions
  5. 14. ANCOVA: Analysis of Covariance
  6. 15. MANOVA: Multiple Analysis of Variance
Repeated Measures
  1. 16. Repeated-Measures ANOVA
  2. 17. Mixed Designs
Relationships Between Variables
  1. 18. Correlations
  2. 19. Chi-Square Test
  3. 20. Simple Linear Regression
  4. 21. Multiple Linear Regression Analysis
  5. 22. Categorical Predictors
  6. 23. Multiple Logistic Regression
  7. 24. Mediation Analysis
  8. 25. Path Analysis
  1. References

In this chapter

  1. 9.1 Scaling/Rescaling
  2. 9.1.1 An Example: Comparing Different Scales
  3. 9.1.2 An Example: Mean Centering
  4. 9.2 Distribution Normalization
  5. 9.2.1 An Example: Log Transformation
  6. 9.2.2 Converting the Results Back
  7. 9.2.3 Square Root and Box-Cox
  8. 9.2.4 When a Transformation Cannot Help
  9. 9.3 Summary

9 Normalization, Standardization, and Data Transformation

In statistics the term normalization can have multiple meanings. For example, it can mean to adjust values of variables to be analyzed to a common scale when these variables are measured using different scales. Alternatively, normalization may mean to transform the values of a sample to get it closer to the normal distribution, to fulfill the assumption of normally distributed data underlying many common statistical tests. Or, in other situations, normalization could be an attempt to eliminate the effects of known influences.

Sometimes the term normalization is used interchangeably with the term standardization. While both serve the same general purpose, there is a difference:

Some of the processes that fall under the concept of normalization may be called data transformation22 IMPORTANT: A transformed value, such as the log of a value, is hard to interpret and present. Therefore, once the analysis has been performed, the results should be converted back to the original units by applying the reverse of the formula used to transform the data. Of note is the fact that the converted results do not always mean the same thing as the original statistics. The mean of log-transformed data, for example, converts back to the geometric mean, not to the ordinary (arithmetic) mean. See Converting the Results Back.. While all this may be confusing, the process always involves a purposeful conversion of the data of a data set from its current format to a different format. In most situations, the process also involves eliminating the units of measure with the intent of making the comparison easier.

2 IMPORTANT: A transformed value, such as the log of a value, is hard to interpret and present. Therefore, once the analysis has been performed, the results should be converted back to the original units by applying the reverse of the formula used to transform the data. Of note is the fact that the converted results do not always mean the same thing as the original statistics. The mean of log-transformed data, for example, converts back to the geometric mean, not to the ordinary (arithmetic) mean. See Converting the Results Back.

9.1 Scaling/Rescaling

A very simple process which aims to change the spread of the data and/or the position of the data points. The transformation uses a simple linear equation of the form y=a\times x+b, which changes the data’s median, mean (\mu), and standard deviation (\sigma), but leaves unchanged the shape of the distribution and the z-scores33 Because they are calculated as a ratio of the difference between the actual value and the sample’s mean and the sample’s standard deviation. In essence, the z-score indicates how many standard deviations from the mean the data point is..

3 Because they are calculated as a ratio of the difference between the actual value and the sample’s mean and the sample’s standard deviation. In essence, the z-score indicates how many standard deviations from the mean the data point is.

The more common are:

9.1.1 An Example: Comparing Different Scales

Let’s return to the 40 students of the course we described in Describing Data. Among other things, we know how many hours a week each of them studied and the score each obtained on the final exam. The two variables are measured on different scales: the exam scores range from 37 to 92 points, and the study hours from 3.3 to 19 hours. Is a student further from their classmates in exam score or in study time? The raw values cannot answer this question. Rescaling the two variables can.

Table 9.1: Exam scores and study hours of the first five students: raw values, min-max normalized, and z-scores
Student Exam Min-max z Hours Min-max z
1 92 1.00 1.78 9.7 0.41 -0.30
2 70 0.60 0.14 6.8 0.22 -1.16
3 79 0.76 0.81 13.1 0.62 0.71
4 67 0.55 -0.08 10.7 0.47 -0.00
5 57 0.36 -0.83 4.6 0.08 -1.81

Table 9.1 shows the three versions of both variables for the first five students. After min-max normalization, both variables range from 0 to 1, which makes them easier to compare and to combine66 For example, into an index that gives the same weight to two measures with different units.. The z-scores answer our question more precisely, because they take into account how spread out each variable is. The first student, for example, scored 92 points, 1.78 standard deviations above the class mean, while their 9.7 hours of study were 0.30 standard deviations below the mean. This student stands out much more for their exam score than for their study time.

6 For example, into an index that gives the same weight to two measures with different units.

Figure 9.1: Weekly study hours before (left) and after (right) the z-transformation

Rescaling changes only the numbers on the axis. As Figure 9.1 shows, the histogram of the z-scores has exactly the same shape as the histogram of the hours: the transformation does not make the data any more, or any less, normal77 For the same reason, the correlation between the two variables does not change: it is 0.56 for the raw values and 0.56 for the z-scores..

7 For the same reason, the correlation between the two variables does not change: it is 0.56 for the raw values and 0.56 for the z-scores.

9.1.2 An Example: Mean Centering

In Simple Linear Regression we predicted the exam scores of the same students from their study time. The intercept of that model, 44.34 points, is the predicted score of a student who does not study at all. Because none of the students studied less than 3.3 hours a week, the intercept was needed to position the line, but it did not describe an actual student. Mean centering the predictor solves this problem. Let’s subtract the mean study time, 10.70 hours, from each student’s hours and fit the model again.


Call:
lm(formula = exam ~ hours, data = cs)

Coefficients:
(Intercept)        hours  
     44.341        2.222  

Call:
lm(formula = exam ~ hours_c, data = cs)

Coefficients:
(Intercept)      hours_c  
     68.125        2.222  

The slope is the same in both models, 2.22 points per hour, because centering does not change the spread of the predictor. Only the intercept changes. In the centered model, a value of 0 for the predictor means “an average amount of study”, so the intercept, 68.12 points, is the predicted score of a student who studies an average number of hours88 In a simple linear regression, the intercept of the centered model is always equal to the mean of the criterion, because the line passes through the point defined by the two means.. Centering makes the intercept meaningful without changing anything else in the model. It becomes even more useful in Multiple Linear Regression, especially when the model includes interactions between predictors.

8 In a simple linear regression, the intercept of the centered model is always equal to the mean of the criterion, because the line passes through the point defined by the two means.

9.2 Distribution Normalization

There are many real world processes that generate data that do not follow the normal, Gaussian, distribution. Assumptions and Outliers already discussed how to determine if the data are normally distributed or not. Non-normal data usually fits in one of two categories: 1) follows a different distribution or 2) is a mixture of distributions and data generation processes.

For the data that follows a known distribution99 E.g., binomial, log-normal, exponential, etc., one can either identify the theoretical distribution it follows and analyze the data using tests appropriate for that distribution or somehow transform it to a normal distribution before analysis and then use tests that assume data distribution to be normal.

9 E.g., binomial, log-normal, exponential, etc.

Dealing with the 2nd category of non-normal data, which displays a mixture of distributions, is more complicated because few, if any, transformations would be able to deal with all that variability for the entire data set. In this case, the data needs to be studied and refined before analysis. For example, an attempt to break down the data can produce sub-samples or categories for which, individually, the distributions are known or recognizable. In this case, transformations can be applied to each sub-sample or category. If the observed data is produced by multiple processes, such as business data produced by complex work activities, multiple shifts, locations, customers, seasonality, etc., an attempt to review the individual process that produced data points and find a common denominator to transform the data to can sometimes help bring the data close enough to the normal distribution so that analysis is possible1010 The process always works better for larger samples.. An example is discussed in When a Transformation Cannot Help.

10 The process always works better for larger samples.

Some of the common options are:

9.2.1 An Example: Log Transformation

The team that runs the course website redesigned its pages and wants to know whether the new version is easier to use. 70 participants were randomly assigned to complete the same task1414 Finding an assignment’s due date and submitting a file. on either the old or the new version of the website, 35 on each, and the time each of them took was recorded, in seconds. The data set1515 Column labels are: participant, group (old or new), time, and errors. was made up for this example.

14 Finding an assignment’s due date and submitting a file.

15 Column labels are: participant, group (old or new), time, and errors.

Completion times are a classic example of data that is not normally distributed. They cannot be shorter than zero, most people finish in a similar time, and a few take much longer. Let’s look at the data before choosing a test.

Figure 9.2: Completion times with the old (left) and the new (right) version of the website, with the normal curve of the same mean and standard deviation

The histograms in Figure 9.2 show the typical shape of completion times: a peak on the left and a long tail to the right1616 The normal curve with the same mean and standard deviation even extends below zero, which completion times cannot do.. The Shapiro-Wilk test confirms the departure from normality for both the old version (p < .001) and the new version (p = .007). The assumption of normality of the independent samples t-Test is not met. Let’s take the natural logarithm of the times.

16 The normal curve with the same mean and standard deviation even extends below zero, which completion times cannot do.

Figure 9.3: Log-transformed completion times with the old (left) and the new (right) version of the website

The log-transformed times (Figure 9.3) are much closer to the normal curve, and the Shapiro-Wilk test no longer indicates a departure from normality, for either the old version (p = .775) or the new version (p = .708). Much better. The analysis can now continue, on the log-transformed data.

Hypotheses.

Decision criteria. The significance level is set at \alpha = .05, and the test is two-tailed. The test is the independent samples t-Test on the log-transformed times. H0 is rejected if the p-value is smaller than \alpha.


    Welch Two Sample t-test

data:  l.new and l.old
t = -2.2915, df = 66.303, p-value = 0.02512
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.47261252 -0.03252878
sample estimates:
mean of x mean of y 
 4.235494  4.488065 

Decision. t(66.3) = -2.29, p = .025. The p-value is smaller than \alpha = .05. The null hypothesis is rejected: the completion times differ between the two versions of the website.

Effect size. On the log scale, Cohen’s d = 0.551717 See Effect Size and Power.. As discussed below, the difference is easier to understand once it is converted back to seconds.

9.2.2 Converting the Results Back

Nobody thinks of time in “log seconds”, so the results have to be converted back to seconds. This is where log transformations are most often misreported. The reverse of the natural logarithm is the exponential function, e^x, and applying it to the results changes their meaning:

In other words, a typical participant completed the task in about 22% less time with the new version of the website than with the old one (95% CI: 3% to 38%). A log transformation turns a question about differences into a question about ratios, which is often a more natural way to describe times, prices, or incomes.

Finally, here is an example of how to write up the results in a publication.

Completion times were positively skewed (Shapiro-Wilk p < .001 for the old version and p = .007 for the new version) and were log-transformed before the analysis. The log-transformed times did not depart significantly from normality (p = .775 and p = .708). An independent samples t-test on the log-transformed times showed that participants completed the task faster with the new version of the website (geometric mean = 69.1 s) than with the old version (geometric mean = 88.9 s), t(66.3) = -2.29, p = .025, d = 0.55. The ratio of the geometric means was 0.78, 95% CI [0.62, 0.97], a reduction of about 22% in completion time.

9.2.3 Square Root and Box-Cox

The participants in the study above also made a number of errors while completing the task. Counts like these have a property that complicates many tests: their variance grows with their mean. The participants who used the old version made 3.49 errors on average, with a variance of 4.49, while those who used the new version made 2.51 errors, with a variance of 2.26. The square root brings the variances closer together1919 After the transformation, the variances are 0.37 and 0.26. Their ratio drops from 1.99 to 1.42., which helps meet the assumption of homogeneity of variance2020 See Assumptions and Outliers..

19 After the transformation, the variances are 0.37 and 0.26. Their ratio drops from 1.99 to 1.42.

Instead of guessing which transformation to use, the Box-Cox procedure can search for it. For the completion times, the best power is \lambda = 0.05, with a 95% confidence interval from -0.30 to 0.40. Because the interval includes 0, the log transformation used above is a good choice2121 In practice, a “round” value inside the confidence interval, such as 0 (log), 0.5 (square root), or 1 (no transformation), is preferred to the exact value, because it is much easier to interpret..

21 In practice, a “round” value inside the confidence interval, such as 0 (log), 0.5 (square root), or 1 (no transformation), is preferred to the exact value, because it is much easier to interpret.

9.2.4 When a Transformation Cannot Help

Transformations work when the data comes from a single process with a skewed distribution, such as the completion times above. They do not work when the data is a mixture. Consider the hours of paid work of the 40 students in the course. 13 of them (32%) do not work at all, and the others work from 1 to 43 hours a week. The data is not normally distributed (Shapiro-Wilk p < .001).

The log cannot be applied directly, because the logarithm of zero is not defined. A common workaround is to add 1 to every value before taking the log. It does not help here: the 13 zeros become 13 identical values at the bottom of the distribution, and the transformed data is still far from normal (p = .001)2222 No transformation can spread out 13 identical values. Whatever the formula, they stay identical..

22 No transformation can spread out 13 identical values. Whatever the formula, they stay identical.

Figure 9.4: Hours of paid work: all students, after adding 1 and taking the log (left), and only the students who work, after taking the log (right)

The data describes two different groups: the students who do not work, and those who do. As discussed earlier in this chapter, the better approach is to separate them. The question “Does the student work?” becomes a categorical variable, analyzed with the methods for categorical data, and the hours of the 27 students who work can be studied on their own. For them alone, the log transformation works well (Figure 9.4, right): the log-transformed hours do not depart from normality (p = .919).

9.3 Summary

Rescaling, such as min-max normalization, mean centering, and z-scores, changes the units of the data but not its shape. It is used to compare or combine variables measured on different scales, and to make the results of a model easier to interpret. It does not make data any more normal.

Transformations such as the log, the square root, or the Box-Cox family change the shape of the data, and can bring a skewed distribution close enough to normal for tests that assume normality. Of note is the fact that the results of a transformed analysis must be converted back, and that the converted results change meaning: the mean of log values becomes a geometric mean, and a difference becomes a ratio. Finally, no transformation can fix data that mixes different groups or processes. Such data has to be separated first.

↑ Contents