elevate | R Documentation |
A transformation to turn negative prices into positive prices and maintain at the same time the hierachy between all prices.
elevate(X, e = NULL)
X |
The prices. |
e |
numeric. The focal point of the hyperbola. |
Negative prices in financial markets, like interest rates in Europe, are a
nightmare as the rough calculation of the returns generates non-sense values.
elevate
uses an hyperbola and implements the following formula:
elevate(x, e) = (x + sqrt(x*x + e*e)) / 2
There is currently no rule of thumb to calculate e
.
When e = NULL
, there is no change and the output is identical to the input.
When e = 0
, all negative values are turned to 0.
require(graphics)
X <- (-50:100)/5
plot( X, elevate(X, e = 5), type = "l", ylim = c(0, 20) )
lines(X, elevate(X, e = 2), col = 2)
lines(X, elevate(X, e = 1), col = 3)
lines(X, elevate(X, e = 0.5), col = 4)
lines(X, elevate(X, e = 0), col = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.