# [S] Re: spline (was: no subject)

Jan Schelling (schelling@ivuk.mavt.ethz.ch)
Thu, 05 Mar 1998 18:00:29 +0100

x<-c(-3.9,-2,-0.22,0.1,4,7,9) # x and y must have the same length
y<-c(-15,-7,-1,-0.22,2,8,13)

you could use:

sp <- spline(x,y, n=100) # interpolating spline with a 'large' number of pairs
approx(sp\$y, sp\$x, 0)\$y # reverse linear interpolation

In case you have enough data I would recommend you use smooth.spline()
instead of spline() which schould give you a more robust estimate of the
zero crossing.

Jan

-----------------------------------------------------------------
Jan Schelling
Institute of Process Engineering
ETH Zurich, 8092 Switzerland
phone: ++41-1-633 62 63
fax: ++41-1-633 11 19
email: schelling@ivuk.mavt.ethz.ch
internet: http://www.ivuk.ethz.ch
-----------------------------------------------------------------

At 00:37 06.03.98 +0800, DR. L.Y. HIN wrote:
>I have a relationship between two vectors x and y where
>
>x<-c(-3.9,-2,-1.98,-0.22,0.1,4,7,9)
>
>and
>
>y<-c(-15,-7,-1,-0.22,2,8,13)
>
>Naturally, if I want to fit a line through it, I should use
>
>spline(x,y) and it will do the job.
>
>
>My real problem is that:
>
>I want to find the value of x, given that the value of y=o, along the
>relationship defined by spline(x,y).
>
>
>I will be most graful if someone would kindly advise me.
>
>
>
>Hin
>---------------------------------------------------------------------
>L.Y. Hin
>Department of Obstetrics and Gynaecology
>Prince of Wales Hospital
>Hong Kong.
>Fax: (852) 26360008
>Tel: (852) 26322807
>---------------------------------------------------------------------
>
>-----------------------------------------------------------------------
>This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
>send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
>message: unsubscribe s-news
>
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news