On 15/02/2012 15:00, Nicholas Reich wrote:> Hello.
>
> I'm getting an unexpected result when running smooth.spline(). Here
> is a simple example that replicates the error I'm getting:
>
>> aa<- c(1, 2, 3, 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 13, 14) bb<-
>> 1:length(aa) plot(aa, bb) smooth.spline(aa, bb)
> Error in smooth.spline(aa, bb) : need at least four unique 'x'
> values
>
>
>
> As you can see from the example, my 'x' clearly has more than 4
> values. The problem is the form of my 'x'. When I dig around in
the
> smooth.spline() code, it looks like it is relying on a call to IQR(x)
> which, with data such as the object aa above, returns 0 because more
> than half of the values are stacked on one value in the middle of the
> data. The call to smooth.spline() works if I add some random noise
> to the Xs, but I'd like to be able to avoid that type of workaround.
> Any other suggestions?
Read the help page (as the posting guide asked of you) ...
tol: A tolerance for same-ness of the ?x? values. The values are
binned into bin of size ?tol? and values which fall into the
same bin are regarded as the same.
Works with tol = 0.1, for example. IQR is only used in the default for
that argument.
> Thanks, Nick
--
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