[R] stinterp/spline - uniroot problem

merhardt marc.erhardt at gmail.com
Fri May 27 11:28:54 CEST 2011


Dear all,

I would like to fit growth data to a smooth curve (preferably using a
Stineman interpolation).
Then I would like to find the intersection of the curve with a horizontal
line (e.g. 0). See below for a coding example.

The root finding using 'uniroot' works fine if I fit the data with
'smooth.spline', but not if I fit the data with 'stinterp' (stinepack) or
'spline'.

The error message is: 
## using "predict" results in error message: no applicable method for
'predict' applied to an object of class "list" 

What does this mean?

I would greatly appreciate any help in this. Obviously, I'm missing
something basic here, but I just recently started learning [R].

Thank you very much for your help!
Best,
Marc

--------------------

# growth data
x <- c(-0.60206, -0.30103, 0, 0.30103, 0.60206, 0.90309, 1.2041, 1.5051,
1.8062, 2.1072)
y <- c(1, 1.1203, 1.0689, 1.1433, 1.0283, 0.4604, 0.0752, -0.05, -0.1, -0.2)

require(stinepack)
xo <- seq(-0.7,2*pi,by=pi/250) 

a.smspl <- stinterp(x,y,xo)
## 'stinterp' does not work. 'smooth.spline' works
# a.smspl <- smooth.spline(x, y, df=6)

## using "predict" together with 'stinterp' or 'spline' results in the
following error message: 
## no applicable method for 'predict' applied to an object of class "list"
-> what does this mean?

# root finding
p.smspl <- function(x) predict(a.smspl, x)$y
root1 = uniroot(f=p.smspl, interval=c(0.4, 2))$root

[1] 1.388058

--
View this message in context: http://r.789695.n4.nabble.com/stinterp-spline-uniroot-problem-tp3554786p3554786.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list