From: halldor bjornsson <halldor.bjornsson_at_gmail.com>

Date: Mon 02 Oct 2006 - 02:25:29 GMT

points(ysp,cex=1/5,col=5)

Date: Mon 02 Oct 2006 - 02:25:29 GMT

The package STINEPACK is now available on CRAN.

This package implements the stineman interpolation method, and is coded
entirely in R

(no Fortan or C libraries). The interpolation method is very robust, and

does not yield

spurious oscillations near spikes or steps. The original article (Stineman
1980) describes

this method as "consistently well behaved".

The interpolation is done in the stinterp routine, and depending on
arguments passed to it, this routine

may call other routines to estimate the slope of the interpolating function.
If the slope is known it can be

explicitly included in stinterp.

The interpolation method is described in an article by Russell W. Stineman
in the July 1980 issue of

Creative Computing with a note from the editor stating that while they were
"not an academic journal

but once in a while something serious and original comes in" adding that
this was "apparently a

real solution" to a well known problem.

According to Stineman, the interpolation procedure has "the following properties:

- If values of the ordinates of the specified points change monotonically, and the slopes of the line segments joining the points change monotonically, then the interpolating curve and its slope will change monotonically.
- If the slopes of the line segments joining the specified points change monotonically, then the slopes of the interpolating curve will change monotonically.
- Suppose that the conditions in (1) or (2) are satisfied by a set of
points, but a small change
in the ordinate or slope at one of the points will result conditions (1) or

(2) being not longer

satisfied. Then making this small change in the ordinate or slope at a point will cause no more than a small change in the interpolating curve."

The method is based on rational interpolation with specially chosen rational
functions to satisfy the

above three conditions.

Slopes computed at the given points with the methods provided by the
'stinterp' function satisfy

Stineman's requirements. The original method suggested by Stineman

(method="scaledstineman",

the default, and "stineman") result in lower slopes near abrupt steps or
spikes in the point sequence,

and therefore a smaller tendency for overshooting. The method based on a
second degree polynomial

(method="parabola") provides better approximation to smooth functions, but

it results in

in higher slopes near abrupt steps or spikes and can lead to some
overshooting where Stineman's

method does not. Both methods lead to much less tendency for 'spurious'
oscillations than traditional

interplation methods based on polynomials, such as splines (see the example
below).

Stineman states that "The complete assurance that the procedure will never
generate 'wild' points

makes it attractive as a general purpose procedure".

This interpolation method has been implemented in Matlab and Python in addition to R

An example follows:

library("stinepack")

# make a function with a sharp spike

x <- seq(0,2*pi,by=pi/6)

y <- sin(x)

y[3] <- -1.5

# interpolate to a finer axis, try all three methods for estimating the slope.

xo <- seq(0,2*pi,by=pi/150) y1 <- stinterp(x,y,xo,method="sc")$y y2 <- stinterp(x,y,xo,method="st")$y y3 <- stinterp(x,y,xo,method="pa")$y

# compare with standard spline

ysp=spline(x,y,n=length(xo))

# plot the results

plot(x,y,ylim=c(-1.5,1.5)) points(xo,y1,cex=1/5,col=2) points(xo,y2,cex=1/5,col=3) points(xo,y3,cex=1/5,col=4)

points(ysp,cex=1/5,col=5)

legend(3, 1, c("Scaled Stineman", "Stineman", "Parabolic", "Spline"), col = c(2,3,4,5),lty=1)

Sincerely,

Halldor

-- Halldór Björnsson Deildarstj. Ranns. & Þróun Veðursvið Veðurstofu Íslands Halldór Bjornsson Weatherservice R & D Icelandic Met. Office [[alternative HTML version deleted]]Received on Mon Oct 02 17:12:30 2006_______________________________________________ R-packages mailing list R-packages@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-packages

______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Mon 02 Oct 2006 - 07:30:07 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*