Skip to content
Prev 175343 / 398506 Next

Find inflection points using smooth.spline

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