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?

Thanks,
Nick

-- 
Nicholas G. Reich, Ph.D.
Research Assistant Professor
Division of Biostatistics and Epidemiology
School of Public Health and Health Sciences
University of Massachusetts, Amherst

413.545.4534
n...@schoolph.umass.edu
http://people.umass.edu/nick/
on twitter: @reichlab

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to