s-news
[Top] [All Lists]

[S] Bug in smooth.spline

To: s-news@wubios.wustl.edu
Subject: [S] Bug in smooth.spline
From: Ole Christian Lingjaerde <o.c.lingjarde@bio.uio.no>
Date: Tue, 16 Feb 1999 15:29:20 +0100
Sender: owner-s-news@wubios.wustl.edu

We recently discovered a small bug in the function smooth.spline;
the bug may be innocent when smooth.spline is used interactively,
but not when (as in our case) the output of smooth.spline is used
directly as input for other computations.

According to the documentation for smooth.spline, there may be ties 
in the x argument, as long as there are at least ten distinct 
x values.  However, we found that near-ties among the smallest x 
values can cause trouble, as in this case (here we use Version 3.4 
Release 1 for Sun SPARC, SunOS 5.3; however the same bug occured
on a PC with Splus 4.5):

> x
 [1] -1.40461 -1.40460 -1.40459 -1.27158 -1.23411
 [6] -1.12842 -1.12448 -1.12033 -0.91474 -0.87535
[11] -0.84843 -0.65776 -0.63444 -0.46434 -0.28305
[16] -0.25552 -0.24259 -0.22592 -0.14116 -0.05622
> y
 [1]  0.69315  0.40547  2.00000  0.24816  1.47703
 [6]  1.94555  0.68579 -0.02887  1.31648  0.75097
[11]  1.04324  0.59080  0.42554  0.37129  0.03544
[16] -1.41142 -0.86375 -1.42216  0.56644 -0.93516
> smooth.spline(x, y, df=4)$df
[1] 14.62833

Plotting the fitted spline confirms that the result
is anything but smooth.  Note that if we round the
x values to four decimals, thus making the three
first x values identical, the problem disappears:

> smooth.spline(round(x,4), round(y,4), df=4)$df
[1] 4.004533

Using s() in gam can lead to similar problems.


Ole Christian Lingjarde          Anja Braathen

--------------------
Division of Zoology
University of Oslo
PO Box 1050, Blindern
N-0316 Oslo
NORWAY




-----------------------------------
Ole Christian Lingjaerde
Division of Zoology
University of Oslo
PO Box 1050, Blindern
N-0316 Oslo
NORWAY

E-mail  : o.c.lingjarde@bio.uio.no, ole@ifi.uio.no
Phone : + 47 22 85 83 70
Fax   : + 47 22 85 46 05
-----------------------------------
-----------------------------------------------------------------------
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

<Prev in Thread] Current Thread [Next in Thread>
  • [S] Bug in smooth.spline, Ole Christian Lingjaerde <=