gcmlcm.Rdgcmlcm computes the greatest convex minorant (GCM) or the
least concave majorant (LCM) of a piece-wise linear function.
gcmlcm(x, y, type=c("gcm", "lcm"))The GCM is obtained by isotonic regression of the raw slopes, whereas the LCM is obtained by antitonic regression. See Robertson et al. (1988).
A list with the following entries:
the x values belonging to the knots of the LCM/GCM curve
the corresponding y values
the slopes of the corresponding line segments
Robertson, T., F. T. Wright, and R. L. Dykstra. 1988. Order restricted statistical inference. John Wiley and Sons.
# load "fdrtool" library
library("fdrtool")
# generate some data
x = 1:20
y = rexp(20)
plot(x, y, type="l", lty=3, main="GCM (red) and LCM (blue)")
points(x, y)
# greatest convex minorant (red)
gg = gcmlcm(x,y)
lines(gg$x.knots, gg$y.knots, col=2, lwd=2)
# least concave majorant (blue)
ll = gcmlcm(x,y, type="lcm")
lines(ll$x.knots, ll$y.knots, col=4, lwd=2)