"conreg" object representing a linear
produces the corresponding (cubic)
spline (via package splines'
by interpolating at the knots, thus “smoothing the kinks”.
determines if the spline fulfills the
same convexity / concavity constraints as the underlying
an R object as resulting from
optionally, the result of
optional further arguments passed to
interpSpline() interpolation spline object.
indicating if the convexity/concavity constraints are fulfilled (in
1 2 3 4 5 6 7 8 9 10 11 12 13
cc <- conreg(cars[,"speed"], cars[,"dist"], convex=TRUE) iS <- interpSplineCon(cc) (isC <- isIsplineCon(cc)) # FALSE: not strictly convex ## Passing the interpolation spline --- if you have it anyway --- ## is more efficient (faster) : stopifnot(identical(isC, isIsplineCon(cc, isp = iS))) ## the interpolation spline is not quite convex: plot(cc) with(cars, points(dist ~ speed, col = adjustcolor(1, 1/2))) lines(predict(iS, seq(1,28, by=1/4)), col = adjustcolor("forest green", 3/4), lwd=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.