This simple form of a hyperbola is not well known. I find it useful for change point models: since the derivative is continuous it often behaves better in a maximizer.

h1 <- function(x, b, k=3)  .5 * b * (x + sqrt(x^2 + k^2))

Function h1() has asymptotes of y=0 to the left of 0 and y=x to the right of 0. The parameter k controls how tightly the curve bends at zero.

A generalization is
h2 <- function (x, b, k=3) {
    z <- x - b[4]
    b[1] + b[2]*z + .5*b[3]* (z + sqrt(z^2 + k^2))
}
b[1] and b[2] are the intercept and slope of the left portion of the curve, b[4] is the inflection point, and b[3] is the change in slope at the inflection point.

The main downside is that k is arbitrary. I simply choose it to "look right", though it too could be part of an optimization.

Terry Therneau

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to