# Nonlinear Transformations of Data

## Key Questions

• You use the logarithm function.

With logarithms (log) you reduce a multiplication (a growth factor) to an addition. E.g. every time you multiply by 2, the log goes up approx. 0.3. So a formula like 2^t becomes 0.3t, and that's a straight line.
You can do this in several ways: In the old days we used log-graph-paper. Also programs like Excel can let you plot logarithmically.

I always use the following example: the smallest sound you can hear is one tree leaf moving in a very soft breeze. For a sound to hurt your ears you will need 10000000000000 times as much, with everything in between. What if we just write down the size of the number in stead of the number itself? So the one leaf (no zeroes) we write down as 0 and the greater number as 13 (zeroes). That's logarithms.

You could call it a "log-log transformation" (make a "log-log plot ")

#### Explanation:

If $y$ is a power function of $x$, then $y = a {x}^{n}$ for some constants $a$ and $n$. Taking the log of both sides (say, the common logarithm (base 10), but any log will do) gives

$\log \left(y\right) = \log \left(a {x}^{n}\right)$

Using properties of logarithms, this can be written as

$\log \left(y\right) = \log \left(a\right) + n \log \left(x\right)$

Letting $Y = \log \left(y\right)$, $X = \log \left(x\right)$, and $A = \log \left(a\right)$, this equation becomes

$Y = A + n X$, giving $Y = \log \left(y\right)$ as a linear function of $X = \log \left(x\right)$.

For example, suppose your data consisted of the points $\left(2 , 6.7\right)$, $\left(3 , 18.8\right)$, $\left(4 , 38.4\right)$, and $\left(5 , 66.9\right)$. Plotting these data gives a definite nonlinear trend in the graph shown below.

Suppose you suspect the relation between $x$ and $y$ is a power function. Take the log of both the $x$- and $y$-coordinates of your data, to get $X$- and $Y$-coordinates of data for a log-log plot: $\left(0.301 , 0.826\right) , \left(0.477 , 1.274\right) , \left(0.602 , 1.584\right) , \left(0.699 , 1.825\right)$. This plot has a definite linear trend.

In fact, if you find the least-squares linear regression line for this second graph, you'll get approximately $Y = 0.072499 + 2.5106 X$. This implies that $\log \left(y\right) = 0.072499 + 2.5106 \log \left(x\right)$ so that $y = {10}^{0.072499 + 2.5106 \log \left(x\right)} = {10}^{0.072499} \cdot {10}^{\log \left({x}^{2.5106}\right)} \setminus \approx 1.18168 {x}^{2.5106}$. The final graph shows that this is a good fit for the original $x y$-data.

(1) When your data is obviously non linear.

and/or

(2) When your model is obviously non-linear.

#### Explanation:

There seem to me to be two main reasons to try a non-linear transformation on your data:

(1) The data itself is obviously non-linear. e.g. When plotted on a linear scale, the points follow a non-linear curve.

(2) The data pertains to a non-linear system. e.g. population growth.

If you suspect an exponential relationship like $y = a \cdot {b}^{x}$ then try linear regression on $x$ vs $\log \left(y\right)$.

If you suspect a power relationship like $y = a {x}^{b}$ then try linear regression on $\log \left(x\right)$ vs $\log \left(y\right)$.

If you suspect a polynomial relationship like $y = a {x}^{2} + b x + c$ and you have data points at regular $x$ intervals (e.g. periodic samples), then you can use the differences between successive pairs of samples as a new sample to reduce the degree by $1$. Repeat as necessary until the resulting data looks linear.