Skip to content

smooth.spline() unique 'x' values error

2 messages · Nicholas Reich, Brian Ripley

#
Hello. 

I'm getting an unexpected result when running smooth.spline().  Here is a simple example that replicates the error I'm getting:
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?

Thanks,
Nick
#
On 15/02/2012 15:00, Nicholas Reich wrote:
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.