# What is the most appropriate way to transform proportions when they are an independent variable?

I thought I understood this issue, but now I'm not as sure and I'd like to check with others before I proceed.

I have two variables, X and Y. Y is a ratio, and it is not bounded by 0 and 1 and is generally normally distributed. X is a proportion, and it is bounded by 0 and 1 (it runs from 0.0 to 0.6). When I run a linear regression of Y ~ X and I find out that X and Y are significantly linearly related. So far, so good.

But then I investigate further and I start to think that maybe X and Y's relationship might be more curvilinear than linear. To me, it looks like the relationship of X and Y might be closer to Y ~ log(X), Y ~ sqrt(X), or Y ~ X + X^2, or something like that. I have empirical reasons to assume the relationship might be curvilinear, but not reasons to assume that any one non-linear relationship might be better than any other.

I have a couple of related questions from here. First, my X variable takes four values: 0, 0.2, 0.4, and 0.6. When I log- or square-root-transform these data, the spacing between these values distorts so that the 0 values are much further away from all the others. For lack of a better way of asking, is this what I want? I assume it isn't, because I get very different results depending on the level of distortion I accept. If this isn't what I want, how should I avoid it?

Second, to log-transform these data, I have to add some amount to each X value because you can't take the log of 0. When I add a very small amount, say 0.001, I get very substantial distortion. When I add a larger amount, say 1, I get very little distortion. Is there a "correct" amount to add to an X variable? Or is it inappropriate to add anything to an X variable in lieu of choosing an alternative transformation (e.g. cube-root) or model (e.g. logistic regression)?

What little I've been able to find out there on this issue leaves me feeling like I should tread carefully. For fellow R users, this code would create some data with a sort of similar structure as mine.

X = rep(c(0, 0.2,0.4,0.6), each = 20)
Y1 = runif(20, 6, 10)
Y2 = runif(20, 6, 9.5)
Y3 = runif(20, 6, 9)
Y4 = runif(20, 6, 8.5)
Y = c(Y4, Y3, Y2, Y1)
plot(Y~X)

• You say that Y is a proportion, but in your data it is between 6 and 10 ?
– user83346
Feb 13, 2016 at 12:42
• Yeah I fixed this above--it's a ratio, not a proportion. Feb 13, 2016 at 13:37

The main question about transforming proportions (I'll use $x$ as symbol, similarly but not identically to your notation) allows some general comments.

In what follows I take it that the main motive for transforming proportions that are covariates (predictors, independent variables) is to improve the approximation to linearity of relationship, or if in exploratory mode to get a clearer idea graphically of the shape or indeed existence of any relationship. As usual whether a covariate is (e.g.) approximately normally distributed is not crucial as such. (Proportions are a not too distant relative of indicator variables with values $0, 1$ which can never be distributed normally, and proportions too are necessarily bounded.)

If the proportions can attain exact zeros or exact ones, it is essential that a transformation be defined for those limits, which clearly rules out $\log x$, as $\log 0$ is indeterminate. Beyond that a particular shape ideally requires some substantive (scientific, practical) justification, but lacking that it follows from some simple analysis that $\log (x + c)$ is highly sensitive to the value of $c$, as you hint.

This is a little easier to see with logarithms to base $10$, so temporarily let's consider $c = 10^k$ so that $\log_{10} (x + 10^k)$ maps $x = 0$ to $k$.

Hence $k = 0, c = 1$ maps $x = 0$ to $0$ and $x = 1$ to about $0.301$, while $k = -3, c = 0.001$ maps $x = 0$ to $-3$ and $x = 1$ to only a smidgen more than $0$.

Similarly, $k = -6, -9,$ whatever means that $0$ is mapped to those same limits, whereas to a increasingly good approximation $x = 1$ is mapped to $0$.

So the lower bound is stretched outwards with smaller and smaller added constants $c$, while the upper limit remains about the same. Such transformations thus can stretch the lower part of the range exceedingly and even create outliers from very small values at or near $0$.

Simply, people suggesting this presumably imagine that $\log (x + c)$ (now to any base you like) should behave very similarly to $\log x$ for small $c$, which is clearly true for large $x$, but not at all true for small $x$. Otherwise put, the steeper and steeper slope of $\log x$ as a function of $x$ as $x \downarrow 0$ can bite here very hard.

It seems preferable to focus on transformations that vary more gradually near $x = 0$ and (for other, but related, reasons) also near $x = 1$.

Square roots and cube roots and other powers $x^p$ are perfectly well defined for $x = 0, 1$ and often help when there is a need to stretch values near $0$. But these transformations are well known and I focus here more on another possibility.

The family of folded powers popularised by J.W. Tukey (Exploratory Data Analysis, Reading, MA: Addison-Wesley, 1977) is one possibility, and is $x^p - (1 - x)^p$. Although there is no compulsion to choose powers that allow simple evocative names, the choices $p = 1/2$ (folded root) and $p = 1/3$ (folded cube root) seem the most useful members of this family.

The family resembles the familiar logit transformation $\text{logit}\ x = \log x - \log (1 - x)$ and indeed the logit is a limiting case as $p$ tends to $0$. A key difference is that folded powers are defined for $x = 0, 1$ and $p \ne 0$.

Folded powers, including now the logit, treat the extreme cases near $0$ and $1$ skew-symmetrically and plot as inverse sigmoid curves (some graphs below) mixing additive and multiplicative behaviour, echoing frequent qualitative (if not physical, biological, economic, whatever) facts for the underlying phenomenon that

• the difference from say $0.01$ to $0.02$ can be a "big deal" (sure, $x$ changes by only $0.01$, but it also doubles)

• the difference from say $0.98$ to $0.99$ can be a "big deal" too (sure, $x$ changes by only $0.01$, but the "fraction without" $1 - x$ also halves)

• the difference from say $0.50$ to $0.51$ can be a "lesser deal" (sure, $x$ changes by $0.01$ too, but the proportional change is much smaller)

This is perhaps easiest to think about when some underlying dynamics is imagined: the increasing fraction of say literate people needs a big push to get going, speeds up and then slows down as it approaches the asymptote of universal literacy. So the curve in time can resemble an increasing or decreasing logistic. The fact that $0$ and $1$ proportions are approached more or more slowly is naturally one of several motivations for logit and similar models for proportional responses; although we are here focusing on proportional covariates, sigmoids can be useful here too.

Folded powers such as the folded root or cube root are not as strongly sigmoid as the logit, but a valuable merit here is their being directly and easily defined without fudges, kludges or nudges for $x = 0, 1$.

Turning to your fake but seemingly realistic dataset (which I imported into my own favourite software, but analysis is simple in anything decent), it turns out that none of these transformations really helps at all. But graphing the data gives a clear warning that even $\log(x + 0.001)$ is a mighty strong transformation, as can be seen also by plotting it directly.

The two main points I wish to make are that

1. $\log (x + c)$ often suggested, and often seemingly regarded as innocuous, is a dangerous transformation unless understood and often inappropriate whenever it stretches out the distribution mightily for small $x$ (unless this really is the desired behaviour).

2. For your example data, no transformation I tried seems to help.

At the same time, other possibilities are far from exhausted. (Notably, I didn't try square root or cube root, and stress that in many other problems those could be obvious and serious candidates.)

The first set of graphs simply shows some candidate transformations for proportions that can attain both $0$ and $1$. (I used natural logarithms, but shapes don't depend on the base chosen). The second set of graphs shows no transformation helping much for the example data. (For comparison, a plain regression on the original data yields $R^2 = 3.7$%, RMSE $= 0.994$.) Tiny puzzle. Your $y$ is said to be a proportion, but its values are around $6$ to $10$.

EDIT: The original data could be plotted here because the OP briefly posted data, but then later removed them.

Other threads here using folded powers include

Transforming proportion data: when arcsin square root is not enough

Regression: Scatterplot with low R squared and high p-values

Plot a highly skewed dataset

• Excellent answer and very thorough. I think I should say my Y is a ratio rather than a proportion, which is probably a pretty substantial difference, so it was good of you to point out. Feb 12, 2016 at 20:16
• Proportions are bounded as I define them. Thanks for the clarification, which doesn't make any difference to my analysis (which is why I labelled it a tiny detail). Feb 12, 2016 at 20:17
• Further comment: In principle, you could check for curvature etc. using splines or smoothers, but with just 4 distinct levels of the predictor that's not easy. I'd consider quantile regression for your data. Feb 12, 2016 at 20:59
• I note further that $x^2$, $x^3$, and so forth are candidate transformations if you had occasion to stretch the right tail ($1\downarrow$) more than the left ($0\uparrow$). Clearly they are perfectly well defined for $x = 0,1$. Feb 14, 2016 at 19:09