Skip to content

Find inflection points using smooth.spline

3 messages · T.D. Rudolph, David Winsemius, Ravi Varadhan

#
Is there any way to identify or infer the inflection points in a smooth
spline object?  I am doing a comparison of various methods of time-series
analysis (polynomial regression, spline smoothing, recursive partitioning)
and I am specifically interested in obtaining the julian dates associated
with the inflection points inferred by the various models.

Tyler

e.g.  http://www.nabble.com/file/p22752459/smooth.spline.pdf
smooth.spline.pdf
#
T.D.Rudolph <prairie.picker <at> gmail.com> writes:
You can get an analog of first and second derivatives via using first and 
second differences:

?diff

If your spline object is spl, try:

diff(diff(spl))

It's possible that you would find lag and rle functions useful as well.
#
Hi,

Here is another approach:

set.seed(123)
x <- sort(runif(200))
y <- sin(3*pi*x) + rnorm(200, sd=0.1)
smspl <- smooth.spline(x, y)

d2 <- function(x) predict(smspl, x , deriv=2)$y

x <- seq(0, 1, length=500)
plot(x, d2(x), type="l")
abline(h=0, lty=2)

uniroot(f=d2, interval=c(0.1, 0.5))  # first inflection point
uniroot(f=d2, interval=c(0.5, 0.9))  # second inflection point
 

Ravi.
____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


----- Original Message -----
From: David Winsemius <dwinsemius at comcast.net>
Date: Saturday, March 28, 2009 5:58 pm
Subject: Re: [R] Find inflection points using smooth.spline
To: r-help at stat.math.ethz.ch