[S] BUG REPORT: odd behaviour of approx() if method="constant" (6/98)

Jens Oehlschlaegel (oehl@Psyres-Stuttgart.DE)
Fri, 19 Jun 1998 17:37:58 +0200 (MET DST)

(Checked with
WinS+3.3 under Win3.11
WinS+4.0 under Win95
UnixS+ Version 3.2 Release 1 for Sun SPARC, SunOS 5.x : 1993 )

method="constant" means that instead of linear approximation a
fixed mixture of the nearest lower and the nearest higher value
is estimated, where f determines the relative weights for these two
neighbour values. E.g. f=0 means to take the lower value, but if xout
equals the lower x, not the corresponding y is returned but the
y corresponding to the lower neighbour of the lower x, in numbers:

x: 1 2 3 4
y: 1 2 3 4

indeed asking for
2 < xout < 3
correctly returns 2

asking for xout=2 returns yout=1
asking for xout=3 returns yout=2

which seems not to be a reasonable approximation at these borders

if you prefer graphics look at

x <- 1:4
y <- 1:4
x2 <- seq(1,4,0.25)
plot(x,y, pch=1, cex=1.5)
points(approx(x,y,x2, method="constant", f=0), pch=15, cex=1)
points(approx(x,y,x2, method="constant", f=0.5), pch=15, cex=0.5, col=2)

where you furthermore will discover that the questionable
"rule" used is not consequently applied at the leftmost value:

asking for xout=1 returns 1 (and not NA)

If there is no reasonable reason to keep this,
I recommend to MATHSOFT to fix this.
BTW, in R this is fixed already.

Best regards

Jens Oehlschlaegel-Akiyoshi

Jens Oehlschlaegel-Akiyoshi

CURRENT ADDRESS (until 12/98) | PERMANENT VIRTUAL ADDRESS ------------------------------------------------------------------------ | http://www.geocities.com/Tokyo/Bay/5663/ oehl@psyres-stuttgart.de | oehl@geocities.com +49 711 6781-408 (phone) | +49 711 6876902 (fax) |

Center for Psychotherapy Research | Christian-Belser-Strasse 79a | D-70597 Stuttgart Germany |

(general disclaimer)

----------------------------------------------------------------------- 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