[Rd] splinefun gives incorrect derivs when extrapolating to the left (PR#13132)
Greg.Snow at imail.org
Greg.Snow at imail.org
Mon Oct 6 19:50:13 CEST 2008
This is a low priority bug that has been around for a while, but I came acr=
oss it again while alpha testing 2.8.
The resulting function for splinefun gives incorrect deriv values when x is=
less than the smallest x-value used to create the function (at least in on=
e circumstance), but does the correct thing for x greater than the largest =
x-value.
Here is an example:
> x <- 1:10
> y <- sin(x)
>
> splfun <- splinefun(x,y, method=3D'natural')
>
> # these should be linear (and are)
> splfun( seq(0,1, 0.1) )
[1] 0.5682923 0.5956102 0.6229280 0.6502459 0.6775638 0.7048816 0.7321995
[8] 0.7595174 0.7868352 0.8141531 0.8414710
>
> # these should all be the same
> splfun( seq(0,1, 0.1), deriv=3D1 )
[1] -0.34287807 -0.22582729 -0.12109764 -0.02868912 0.05139826 0.1191645=
1
[7] 0.17460962 0.21773359 0.24853643 0.26701813 0.27317870
>
> # these should all be 0
> splfun( seq(0,1, 0.1), deriv=3D2 )
[1] 1.2321135 1.1089022 0.9856908 0.8624795 0.7392681 0.6160568 0.4928454
[8] 0.3696341 0.2464227 0.1232114 0.0000000
> splfun( seq(0,1, 0.1), deriv=3D3 )
[1] -1.232114 -1.232114 -1.232114 -1.232114 -1.232114 -1.232114 -1.232114
[8] -1.232114 -1.232114 -1.232114 -1.232114
>
>
> # everything works like it should on the right end
> splfun( seq(10,11, 0.1) )
[1] -0.5440211 -0.6444546 -0.7448881 -0.8453215 -0.9457550 -1.0461885
[7] -1.1466220 -1.2470554 -1.3474889 -1.4479224 -1.5483559
> splfun( seq(10,11, 0.1), deriv=3D1 )
[1] -1.004335 -1.004335 -1.004335 -1.004335 -1.004335 -1.004335 -1.004335
[8] -1.004335 -1.004335 -1.004335 -1.004335
> splfun( seq(10,11, 0.1), deriv=3D2 )
[1] 0 0 0 0 0 0 0 0 0 0 0
> splfun( seq(10,11, 0.1), deriv=3D3 )
[1] 0 0 0 0 0 0 0 0 0 0 0
>
--please do not edit the information below--
Version:
platform =3D i386-pc-mingw32
arch =3D i386
os =3D mingw32
system =3D i386, mingw32
status =3D alpha
major =3D 2
minor =3D 8.0
year =3D 2008
month =3D 10
day =3D 01
svn rev =3D 46589
language =3D R
version.string =3D R version 2.8.0 alpha (2008-10-01 r46589)
Windows XP (build 2600) Service Pack 3
Locale:
LC_COLLATE=3DEnglish_United States.1252;LC_CTYPE=3DEnglish_United States.12=
52;LC_MONETARY=3DEnglish_United States.1252;LC_NUMERIC=3DC;LC_TIME=3DEnglis=
h_United States.1252
Search Path:
.GlobalEnv, package:stats, package:graphics, package:grDevices, package:ut=
ils, package:datasets, package:methods, Autoloads, package:base
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
More information about the R-devel
mailing list