0
$\begingroup$

What's the formula for a equation that can produce the continuum from the red to green lines in this graph below? I can easily get anywhere from the green line to the blue with $$y = B_0 + B_1x + B_2x^3$$ but getting anywhere from the blue line to the red line requires an inverse of the cube or x^(1/3) which doesn't work for negative numbers. Is there any continuous formula that can produce the red line? Alternatively, how do I use imaginary numbers in a linear regression?
enter image description here

Here's some data if anyone can fit a model to it.

  x, y 
-10,  2.154434525
 -9,  2.080083671
 -8,  1.999999861
 -7,  1.912931059
 -6,  1.817120484
 -5,  1.709975855
 -4,  1.587400979
 -3,  1.442249517
 -2,  1.259921021
 -1,  1
  0,  0
  1, -1
  2, -1.259921021
  3, -1.442249517
  4, -1.587400979
  5, -1.709975855
  6, -1.817120484
  7, -1.912931059
  8, -1.999999861
  9, -2.080083671
 10, -2.154434525
$\endgroup$
  • $\begingroup$ That's a much more specific and simpler question than the one in your earlier comment, which was about choosing a function from a smooth transition between those curves. I'll try to deal with both. $\endgroup$ – Glen_b May 9 '14 at 22:53
  • $\begingroup$ What's the distinction between $x_1$ and $x$? are they the same variables or different variables? $\endgroup$ – Glen_b May 9 '14 at 22:54
  • $\begingroup$ Sorry same variables. $\endgroup$ – Ricky May 9 '14 at 23:00
3
$\begingroup$

Firstly, $x^{1/3}$ does work for negative $x$. Any real number other than 0 has three cube roots, one real and two complex, and the real root for negative $x$ is negative.

You might have a problem with software refusing to compute cube roots of negative numbers, but that's easy to get around, and indeed, to generalize to cases where the root isn't an odd integer:

$$t(x) = \text{sign}(x)\cdot |x|^p$$

[An alternative form that avoids the use of the $\text{sign}$ function is $t(x) = x\cdot |x|^{p-1}$, but with that form you have to specifically set $t(0)=0$ separately. So for $p=\frac{1}{3}$, you have $t(x)=x\cdot |x|^{-\frac{2}{3}}$, except at 0, which has $t(0)=0$.]

As it is, your data is exactly $y = -x^{1/3}$. Here's how you can see it (this is in R)

> y
 [1]  2.154435  2.080084  2.000000  1.912931  1.817121  1.709976  1.587401  1.442250  1.259921  1.000000
[11]  0.000000 -1.000000 -1.259921 -1.442250 -1.587401 -1.709976 -1.817121 -1.912931 -2.000000 -2.080084
[21] -2.154435
> y^3
 [1]  10   9   8   7   6   5   4   3   2   1   0  -1  -2  -3  -4  -5  -6  -7  -8  -9 -10

... but most software won't compute cube roots for negative arguments (there's a reason why, which isn't probably worth pursuing here).

So we use my above suggestion:

f= -sign(x)*abs(x)^(1/3)
plot(x,y)
points(x,f,col="blue",pch=20,cex=.6)

enter image description here

The circles are the data, the dots are the fitted values (f).


A couple of side notes:

The red dashed line in the plot in your question there was actually generated by using $p=1/2$ in $t(x) = \text{sign}(x)\cdot |x|^p$, rather that $1/3$, but the situation in your earlier question was slightly different. The green dashed line was actually generated using $p=2$ in the same formula (though then divided by 1000 to have the same endpoints as for $p=1/2$).

Note that if you didn't know $p$, you could actually estimate it. If there are no other predictors yo might do it via transformation, but with other predictors present you can still fit $p$ as a parameter in a nonlinear regression.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ As @Glen_b indicates, this beast has a simple name, cube root. stata-journal.com/sjpdf.html?articlenum=st0223 has more on cube roots. Some but not all of the content is Stata-specific. $\endgroup$ – Nick Cox May 9 '14 at 23:38
  • $\begingroup$ Thanks I figured the sign(x) abs(x)^3 was the simplest way. I was hoping for some other continuous function without sign, but this gets the job done. Thanks for pointing me in the right direction through the chain of posts! $\endgroup$ – Ricky May 9 '14 at 23:42
  • $\begingroup$ You can avoid $\text{sign}$ easily enough, if you can bear a slight complication. I'll amend my answer. $\endgroup$ – Glen_b May 10 '14 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.