Introduction to for Clinical Trials

Transformations

Martin Bland Professor of Health Statistics University of York http://www-users.york.ac.uk/~mb55/

The need for transformations Instead of analysing the as observed, we can carry out a mathematical transformation first. These can make data more suitable for analysis.

Serum triglyceride from cord blood 0 0 8 8 0 0 y y 6 6 c c n n e e 0 0 u u 4 4 q q e e r r 0 0 F F 2 2 0 0

0 .5 1 1.5 2 -1 -.5 0 .5 Triglyceride Triglyceride, log 10 transformed

The need for transformations Instead of analysing the data as observed, we can carry out a mathematical transformation first. These can make data more suitable for analysis.

Area of venous ulcer at recruitment, VenUS I trial

.15 .8

y y .6 t .1 t i i s s n n

e e .4 D .05 D .2

0 0 0 50 100 150 200 250 -1 0 1 2 3 Ulcer area (sq cm) Log10(Ulcer area)

1 The need for transformations Instead of analysing the data as observed, we can carry out a mathematical transformation first. These can make data more suitable for analysis.

Prostate specific antigen (PSA) by prostate diagnosis

2000 3

1500 A 2 S P A

S 1000 0

1 1 P g o 500 L 0

0 -1 Benign Prostititis Cancer Benign Prostititis Cancer Histology Histology

The need for transformations Instead of analysing the data as observed, we can carry out a mathematical transformation first. These can make data more suitable for analysis.

Arm blood flow in rheumatoid arthritis with oedema s r y u

20 t 5 i o v i h t 4 c o 15 a w t t 3 o r o e 10 t r f 2 a e

r y a t 5 i

u 1 v i q t S c 0 0 A No RA, no oedema RA RA+oedema No RA, no oedema RA RA+oedema Group Group

Right arm Left arm Right arm Left arm

The need for transformations It can be shown that if we take several samples from the same population, the means and variances of these samples will be independent if and only if the distribution is Normal. Thus uniform variances tend to go with a Normal Distribution. Addition and Normal distribution go together, so transformations which Normalize will often linearize.

2 Commonly used transformations for quantitative data: ‹ logarithm, ‹ square root, ‹ reciprocal. Variance-stabilising and Normalising

for qualitative data: ‹ logit. Linearizing

Logarithms Mathematical function widely used in statistics.

2 10 = 10×10 = 100 log10(100) = 2 3 10 = 10×10×10 = 1000 log10(1000) = 3 5 10 = 10×10×10×10×10 = 100000 log10(100000) = 5 1 10 = 10 log10(10) = 1 log10(1000) + log10(100) = 3 + 2 = 5 = log10(100000) 1000 × 100 = 100000 Add on the log scale Ï multiply on the natural scale. log10(1000) – log10(100) = 3 – 2 = 1 = log10(10) 1000 ÷ 100 = 10 Subtract on the log scale Ï divide on the natural scale.

Logarithms

0 10 = 1 log10(1) = 0 Why is this? log10(10) – log10(10) = 1 – 1 = 0 10 ÷ 10 = 1 Logarithms do not have to be whole numbers. 100.5 =10½ = root 10 = 3.1622777 We know this because 10½ × 10½ = 10½+½ = 101 = 10.

½ is the log10 of the square root of 10.

3 Logarithms

What is log10(0)? It does not exist. There is no power to which we can raise 10 to give zero. Logarithms of negative numbers do not exist, either. We can only use logarithmic transformations for positive numbers.

Logarithms If we multiple a logarithm by a number, on the natural scale we raise to the power of that number.

For example, 3×log10(100) = 3×2 = 6 = log10(1000000) and 1003 = 1000000. If we divide a logarithm by a number, on the natural scale we take that number root.

For example, log10(1000)/3 = 3/3 = 1 = log10(10) and the cube root of 1000 is 10, i.e. 10 ×10 ×10 = 1000.

Logarithms To convert from logarithms to the natural scale, we antilog.

2 antilog10(2) = 10 = 100 On a calculator, use the 10x key.

4 Logarithms The logarithmic curve and logarithmic scale

2 100 ) e 10 l 1 a c s

c ) i x ( m g

0 1 h t o i l r a g o l (

-1 .1 x

-2 .01 0 10 20 30 40 50 60 70 80 90 100 x

2000 Logarithms 1500

Logarithmic scales A S 1000 P

500

0 Benign Prostititis Cancer Histology

3 1000

A 2 S 100 P A

S 0

1 1 P 10 g o L 0 1

-1 .1 Benign Prostititis Cancer Benign Prostititis Cancer Histology Histology

Logarithms We can use logarithms to multiply or divide large numbers. Logarithms to the base 10 are called common logarithms. They were used for calculation before the age of cheap electronic calculators. Mathematicians find it convenient to use a different base, called ‘e’, to give natural logarithms.

5 Logarithms Mathematicians find it convenient to use a different base, called ‘e’, to give natural logarithms. ‘e’ is a number which cannot be written down exactly, like . e = 2.718281 . . . They use this because the slope of the curve

y = log10(x) is log10(e)/x. The slope of the curve

y = loge(x) is 1/x. Using natural logs avoids awkward constants in formulae. When you see ‘log’ written in statistics, it is the natural log.

Logarithms To antilog from logs to base e on a calculator, use the key labelled ‘ex’ or ‘exp(x)’.

Transformations for a single sample

Serum triglyceride and log10 serum triglyceride in cord blood for 282 babies, with corresponding Normal Distribution curve. The log transformation gives a good fit to the Normal. 0 0 8 8 0 0 y y 6 6 c c n n e e 0 0 u u 4 4 q q e e r r 0 0 F F 2 2 0 0

0 .5 1 1.5 2 -1 -.5 0 .5 Triglyceride Triglyceride, log 10 transformed

6 Transformations for a single sample Back transformation Serum triglyceride: mean = 0.51, SD = 0.22. log10 serum triglyceride: mean = –0.33, SD = 0.17. If we take the mean on the transformed scale and back-transform by taking the antilog, we get 10–0.33 = 0.47. This is less than the mean for the raw data. The antilog of the mean log is not the same as the untransformed . This the geometric mean, which is found by multiplying all the observations and taking the n’th root.

Transformations for a single sample Geometric mean If we add the logs of two numbers we get the log of their product. Thus when we add the logs of a sample of observations together we get the log of their product. If we multiply the log of a number by a second number, we get the log of the first raised to the power of the second. So if we divide the log by n, we get the log of the n’th root. Thus the mean of the logs is the log of the geometric mean.

Transformations for a single sample Back transformation If triglyceride is measured in mmol/litre, the log of a single observation is the log of a measurement in mmol/litre. The sum of n logs is the log of the product of n measurements in mmol/litre and is the log of a measurement in mmol/litre to the power n. The n’th root is thus again the log of a number in mmol/litre and the antilog is back in the original units, mmol/litre.

7 Transformations for a single sample Back transformation The antilog of the is not measured in mmol/litre. To find a standard deviation, we calculate the differences between each observation and the mean, square and add. On the log scale, we take the difference between each log transformed observation and subtract the log geometric mean.

Transformations for a single sample Back transformation The antilog of the standard deviation is not measured in mmol/litre. On the log scale, we take the difference between each log transformed observation and subtract the log geometric mean. We have the difference between the log of two numbers each measured in mmol/litre, giving the log of their ratio which is the log of a dimensionless pure number. We cannot transform the standard deviation back to the original scale.

Transformations for a single sample Back transformation If we want to use the standard deviation, it is easiest to do all calculations on the transformed scale and transform back, if necessary, at the end. E.g., the 95% confidence interval for the mean. On the log scale standard error = 0.010 so the 95% confidence interval for the mean is –0.33 – 1.96 × 0.010 to –0.33 + 1.96 × 0.010 = –0.35 to –0.31.

8 Transformations for a single sample Back transformation On the log scale standard error = 0.010 so the 95% confidence interval for the mean is –0.33 – 1.96 × 0.010 to –0.33 + 1.96 × 0.010 = –0.35 to –0.31. To get these we took the log of something in mmol/litre and added or subtracted the log of a pure number, so we still have the log of something in mmol/litre. To get back to the original scale we antilog to give a 95% confidence interval for the geometric mean (0.47) of 0.45 to 0.49 mmol/litre.

Transformations for a single sample Back transformation To get back to the original scale we antilog to give a 95% confidence interval for the geometric mean (0.47) of 0.45 to 0.49 mmol/litre. For the arithmetic mean, using the raw, untransformed data we get 0.48 to 0.54 mmol/litre. This interval is wider than for the geometric mean. In highly skew data the extreme observations have a large influence on the arithmetic mean, making it more prone to sampling error.

Transformations when comparing two groups Biceps skinfold thickness (mm) in two groups of patients Crohn's Disease Coeliac Disease 1.8 2.8 4.2 6.2 1.8 3.8 2.2 3.2 4.4 6.6 2.0 4.2 2.4 3.6 4.8 7.0 2.0 5.4 2.5 3.8 5.6 10.0 2.0 7.6 2.8 4.0 6.0 10.4 3.0 6 15 n

10 a e ) 4 m

y m 8 - c m 10 ) n ( 2

e 6 m d u l m q o ( f 0

e r n 4 d i 5 l F k o 2 f S -

2 n i k 4 S 0 0 - Crohn's Coeliac -6 -4 -2 0 2 4 6 -4 -2 0 2 4 Group Skinfold (mm) - mean Inverse Normal

9 Transformations when comparing two groups Biceps skinfold thickness (mm) in two groups of patients Crohn's Disease Coeliac Disease 1.8 2.8 4.2 6.2 1.8 3.8 2.2 3.2 4.4 6.6 2.0 4.2 2.4 3.6 4.8 7.0 2.0 5.4 2.5 3.8 5.6 10.0 2.0 7.6 2.8 4.0 6.0 10.4 3.0

4 n 1 10 a e d l m y 5 3 o . - c f

n n d i l e k o u f s 2 0

q n t 5 i e o k r o s F 5

. t R

1 - o o R 1

0 0 - Crohn's Coeliac -2 -1 0 1 2 -1 -.5 0 .5 1 Group Root skinfold - mean Inverse Normal

Transformations when comparing two groups Biceps skinfold thickness (mm) in two groups of patients Crohn's Disease Coeliac Disease 1.8 2.8 4.2 6.2 1.8 3.8 2.2 3.2 4.4 6.6 2.0 4.2 2.4 3.6 4.8 7.0 2.0 5.4 2.5 3.8 5.6 10.0 2.0 7.6 2.8 4.0 6.0 10.4 3.0 4 1.5 6 . n a e 2 d l . y m

c o - f 1 4 n n d i e l k 0 u o f s q

n e i g r k o .5 2 2 F s . L

- g o L 4 .

0 0 - Crohn's Coeliac -.6 -.4 -.2 0 .2 .4 .6 -.4 -.2 0 .2 .4 Group Log skinfold - mean Inverse Normal

Transformations when comparing two groups Biceps skinfold thickness (mm) in two groups of patients Crohn's Disease Coeliac Disease 1.8 2.8 4.2 6.2 1.8 3.8 2.2 3.2 4.4 6.6 2.0 4.2 2.4 3.6 4.8 7.0 2.0 5.4 2.5 3.8 5.6 10.0 2.0 7.6 2.8 4.0 6.0 10.4 3.0 3 .6 10 . d l n o 2 a f .5 .

8 e n y i c k m 1 .4 . s n -

l

e 6 d a u .3 l c 0 q o f o e 4 r r n i 1 p .2 F . i k - c s / e .1 2 2 1 . R 0 0 - Crohn's Coeliac -.4 -.2 0 .2 .4 -.2 0 .2 Group 1/skinfold - mean Inverse Normal

10 n a 6 10 15 e ) m

4 m y -

8 c m ) n ( 10 2

e m

d 6 u l m q o ( 0 f

4 e n r d i 5 l 2 F k o - 2 f S n i 4 - 0 0 k S Crohn's Coeliac -6 -4 -2 0 2 4 6 -4 -2 0 2 4 Group Skinfold (mm) - mean Inverse Normal n

4 a 1 10 e d l m y o - 5 c f 3

. n n d i l e k o u f 0 s 2

q

5 n t i e o k r 5 o s . F

1 - t R o 1 o

0 0 - R Crohn's Coeliac -2 -1 0 1 2 -1 -.5 0 .5 1 Group Root skinfold - mean Inverse Normal n 4 . 1.5 6 a e d l m y 2

. c o - f

1 n 4 n d i e l k u 0 o f s q

n i e g r

.5 2 2 k o . F s - L

g 4 o . L

0 0 - Crohn's Coeliac -.6 -.4 -.2 0 .2 .4 .6 -.4 -.2 0 .2 .4 Group Log skinfold - mean Inverse Normal 3 d l . .6 10 n o a f 2 e n .

.5 y i 8 c k m

1 s n -

.4 .

l e 6 d a u l

.3 0 c q o f o

e 4 r r 1 n

.2 i . p F - i k

c 2 s

.1 2 / . e - 1

R 0 0 Crohn's Coeliac -.4 -.2 0 .2 .4 -.2 0 .2 Group 1/skinfold - mean Inverse Normal

Transformations when comparing two groups Biceps skinfold thickness compared for two groups of patients, using different transformations Transform- Two sample 95% confidence Variance ation t test, interval ratio 27 d.f. for difference larger/ t P on transformed smaller scale None 1.28 0.21 -0.71mm to 3.07mm 1.52 square root 1.38 0.18 -0.140 to 0.714 1.16 logarithm 1.48 0.15 -0.114 to 0.706 1.10 reciprocal -1.65 0.11 -0.203 to 0.022 1.63

Transformations when comparing two groups Trans t P 95% CI for diff Var ratio None 1.28 0.21 -0.71mm to 3.07mm 1.52 square root 1.38 0.18 -0.140 to 0.714 1.16 logarithm 1.48 0.15 -0.114 to 0.706 1.10 reciprocal -1.65 0.11 -0.203 to 0.022 1.63 The transformed data clearly gives a better test of significance than the raw data. Confidence intervals for the transformed data are more difficult to interpret. Confidence limits for the difference cannot be transformed back to the original scale.

11 Transformations when comparing two groups Trans t P 95% CI for diff Var ratio None 1.28 0.21 -0.71mm to 3.07mm 1.52 square root 1.38 0.18 -0.140 to 0.714 1.16 logarithm 1.48 0.15 -0.114 to 0.706 1.10 reciprocal -1.65 0.11 -0.203 to 0.022 1.63 Confidence limits for the difference cannot be transformed back to the original scale. The lower (negative limit) for the square root transformation is undefined.

Transformations when comparing two groups Trans t P 95% CI for diff Var ratio None 1.28 0.21 -0.71mm to 3.07mm 1.52 square root 1.38 0.18 -0.140 to 0.714 1.16 logarithm 1.48 0.15 -0.114 to 0.706 1.10 reciprocal -1.65 0.11 -0.203 to 0.022 1.63 Confidence limits for the difference cannot be transformed back to the original scale. The upper limit for the reciprocal is very small (0.022) with reciprocal 45.5.

Transformations when comparing two groups Trans t P 95% CI for diff Var ratio None 1.28 0.21 -0.71mm to 3.07mm 1.52 square root 1.38 0.18 -0.140 to 0.714 1.16 logarithm 1.48 0.15 -0.114 to 0.706 1.10 reciprocal -1.65 0.11 -0.203 to 0.022 1.63 Confidence limits for the difference cannot be transformed back to the original scale. The log gives interpretable results (0.89 to 2.03) but these are not limits for the difference in millimetres. They do not contain zero yet the difference is not significant.

12 Transformations when comparing two groups Trans t P 95% CI for diff Var ratio None 1.28 0.21 -0.71mm to 3.07mm 1.52 square root 1.38 0.18 -0.140 to 0.714 1.16 logarithm 1.48 0.15 -0.114 to 0.706 1.10 reciprocal -1.65 0.11 -0.203 to 0.022 1.63 The back-transformed 95% confidence interval using the log transformation, 0.89 to 2.03, are the 95% confidence limits for the ratio of the Crohn's disease mean to the coeliac disease mean. When we take the difference between the logarithms of the two geometric means, we get the logarithm of their ratio, not of their difference.

Transformations when comparing two groups Trans t P 95% CI for diff Var ratio None 1.28 0.21 -0.71mm to 3.07mm 1.52 square root 1.38 0.18 -0.140 to 0.714 1.16 logarithm 1.48 0.15 -0.114 to 0.706 1.10 reciprocal -1.65 0.11 -0.203 to 0.022 1.63 When we take the difference between the logarithms of the two geometric means, we get the logarithm of their ratio, not of their difference. We thus have the log of a pure number and we antilog this to give the dimensionless ratio of the two geometric means. If there were no difference, of course, the expected value of this ratio would be one, not zero, and so lies within the limits 0.89 to 2.03.

Transformations when comparing two groups Trans t P 95% CI for diff Var ratio None 1.28 0.21 -0.71mm to 3.07mm 1.52 square root 1.38 0.18 -0.140 to 0.714 1.16 logarithm 1.48 0.15 -0.114 to 0.706 1.10 reciprocal -1.65 0.11 -0.203 to 0.022 1.63 Transformed data give us only a P value when comparing groups, unless we use the log, in which case we can get confidence intervals for ratios.

13 Transformations for paired data

Patient Placebo Pronethalol Placebo – Pronethalol Differences 1 71 29 42 are often 2 323 348 -25 negative. 3 8 1 7 We cannot 4 14 7 7 log or square 5 23 16 7 root negative 6 34 25 9 numbers. 7 79 65 14 We transform 8 60 41 19 the original 9 2 0 2 observations 10 3 0 3 then subtract 11 17 15 2 again. 12 7 2 5

Transformations for paired data

Patient Placebo Pronethalol Placebo – Pronethalol We could 1 8.426149 5.385165 3.040985 take square 2 17.972200 18.654760 –0.682558 roots. 3 2.828427 1.000000 1.828427 4 3.741657 2.645751 1.095906 5 4.795832 4.000000 0.795832 6 5.830952 5.000000 0.830952 7 8.888194 8.062258 0.825936 8 7.745967 6.403124 1.342843 9 1.414214 0.000000 1.414214 10 1.732051 0.000000 1.732051 11 4.123106 3.872983 0.250122 12 2.645751 1.414214 1.231538

Transformations for paired data

Patient Placebo Pronethalol Placebo – Pronethalol We could 1 71 29 take logs. 2 323 348 Problem: 0 3 8 1 has no 4 14 7 logarithm. 5 23 16 6 34 25 Either add a small 7 79 65 constant to 8 60 41 everything, 9 2 0 e.g. 1. 10 3 0 11 17 15 12 7 2

14 Transformations for paired data

Patient Placebo Pronethalol Placebo – Pronethalol We could 1 71+1=72 29 +1=30 take logs. 2 323+1=323 348+1=349 Problem: 0 3 8 +1=9 1 +1=2 has no 4 14 +1=15 7 +1=8 logarithm. 5 23 +1=24 16 +1=17 6 34 +1=35 25 +1=26 Add a small constant to 7 79 +1=80 65 +1=66 everything, 8 60 +1=61 41 +1=42 e.g. 1. 9 2 +1=3 0 +1=1 10 3 +1=4 0 +1=1 11 17 +1=18 15 +1=16 12 7 +1=8 2 +1=3

Transformations for paired data

Patient Placebo Pronethalol Placebo – Pronethalol We could 1 4.276666 3.401197 0.875469 take logs. 2 5.780744 5.855072 –0.074328 Log(x+1). 3 2.197225 0.693147 1.504077 4 2.708050 2.079442 0.628609 5 3.178054 2.833213 0.344841 6 3.555348 3.258096 0.297252 7 4.382027 4.189655 0.192372 8 4.110874 3.737670 0.373204 9 1.098612 0.000000 1.098612 10 1.386294 0.000000 1.386294 11 2.890372 2.772589 0.117783 12 2.079442 1.098612 0.980830

Transformations for paired data Both square root and log seem to improve the fit to the Normal.

Natural Square root Log(x+1) Paired t tests 4 40 2 Natural scale: P=0.11 2 e e e c c c

n n n Square root scale: e e e

r r r 1

e 0 e e f f f f f f P=0.0011 i i i D D D 0 Log(x+1) scale: P=0.0012 0 -40 -2 -20 0 20 40 0 2 4 -1 0 1 2 Inverse Normal Inverse Normal Inverse Normal

15 Which transformation? To make Normal ‹ counts: try square root, ‹ concentrations in blood: try log, then reciprocal, ‹ ratios: try log, then reciprocal. To make variability uniform ‹ variance proportional to mean: square root, ‹ standard deviation proportional to mean: log, ‹ standard deviation proportional to mean squared: reciprocal.

Can all data be transformed? Sometimes we have very long tails at both ends of the distribution, which makes transformation by log, square root or reciprocal ineffective. Blood sodium in ITU patients: We can often ignore 100 this departure from the Normal y distribution. c n e u 50 It is possible to q e

r transform, but F difficult to interpret afterwards. 0 100 120 140 160 180 Sodium

Can all data be transformed? Sometimes we have a bimodal distribution, which makes transformation by log, square root or reciprocal ineffective. Systolic blood pressure in ITU patients:

60 We should not ignore this departure y from the Normal c 40 n

e distribution. u q e r 20 It is possible to F transform, but difficult to interpret 0 0 100 200 300 afterwards. Systolic blood pressure

16 Can all data be transformed? Sometimes we have a large number of identical observations, usually at zero. Coronary artery calcium: Any transformation 2000 will leave half the observations with 1500 1,153 zero observations the same value, at y c n the extreme of the e u 1000 q distribution. e r F It is impossible to 500 transform these data to a Normal 0 distribution. 0 500 1000 1500 2000 Coronary artery calcium (Agatston units)

What can we do if we cannot transform data to a suitable form? We can use non-parametric methods, such as the Mann-Whitney U test. These will give us a significance test, but usually no confidence interval.

Are there data which should not be transformed? Sometimes we are interested in the data in the actual units only. Cost data is a good example. Costs of treatment usually have distributions which are highly skew to the right. However, in a trial we need to estimate the difference in mean costs in pounds. No other scale is of interest. We should not transform such data. We rely on large sample comparisons or on methods which do not involve any distributions (e.g. bootstrap methods,)

17 Are transformations cheating? Is the linear scale the only scale? Some variables are always measured on a log scale: e.g. pH, Richter scale. Should we measure spectacle lenses by focal length or in dioptres (reciprocal)? Concentrations are measured in units of solute in contained in one unit of solvent. Arbitrary choice. Could measure in units of solvent required to contain one unit of solute — the reciprocal. We often choose scales for convenience, so why not choose the scale for ease of statistical analysis?

18