[R] smooth.spline
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Apr 17 17:20:40 CEST 2006
I believe this is covered by
The \code{x} vector should contain at least four distinct values.
\emph{Distinct} here means \dQuote{distinct after rounding to 6 significant
digits}, i.e., \code{x} will be transformed to
\code{unique(sort(signif(x, 6)))}, and \code{y} and \code{w} are
pooled accordingly.
but without a working example it is hard to tell.
On Fri, 17 Mar 2006, Rolf Turner wrote:
>
> I have noticed a slightly puzzling behaviour exhibited by
> smooth.spline(). If I do
>
> sss <- smooth.spline(x,y)
>
> for a certain pair of data vectors x and y, and then do
>
> length(sss$x)
>
> I get the result ``18''. However if I do
>
> length(unique(x))
>
> I get ``27''. Trying to force smooth.spline() to use more knots I
> tried
>
> sss <- smooth.spline(x,y,all.knots=TRUE)
>
> but again got output of length 18 again. I then tried
>
> sss <- smooth.spline(x,y,nknots=27)
>
> and got an error message. Finally I was inspired to re-scale the
> x-values. Doing
>
> x <- x - min(x)
> sss <- smooth.spline(x,y)
>
> gave me output of length 27 as expected. Apparently smooth.spline()
> is using a criterion for distinctness of x values which is based on a
> tolerance relative to the size of the x's. (I.e. a different
> criterion from unique().) While this is assuredly a Good Thing, it
> might be nice to have some sort of warning in the help file to keep
> young players from getting confused.
I think there is one, if this is the phenomenon I know about.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list