Dear R-helpers, I compared various programs for cubic spline smoothing, and it appeared that smooth.spline ( stats version 3.0.1) seems to behave surprisingly. For enough long series and low values of lambda (or spar), the results of smooth.spline seem to be different from those of sreg ( package fields version 6.8), Octave (=MATLAB) or SAS. These three last softwares always gave the same results.
Here is a script which shows the problem: #generate a random series of 2000 values set.seed(1) MyData=data.frame(Time=1:2000,Val=runif(1000)) #calculate the sreg cubic smoothing spline with a given lambda parameter (0.006 here) library(fields) SplineFields=sreg(MyData$Time,MyData$Val,lambda=0.006) #keep the minimim fitted value (or any other from a long list of possible values) ValMin=min(SplineFields$fitted.values) TimeValMin=which.min(SplineFields$fitted.values) #calculations of all possible fitted values at the TimeValMin point with smooth.spline, #varying the spar parameter in the range of all its possible values SplineRValMin=sapply(seq(-0.5,2.5,0.1), function(Ispar) { SplineR=smooth.spline(MyData$Time,MyData$Val,spar=Ispar) SplineR$y[TimeValMin]}) #None of the smooth.spline fitted values reach the one calculated with sreg ! Lim=range(ValMin,SplineRValMin) #smooth.spline values plot(seq(-0.5,2.5,0.1),SplineRValMin,type="l",ylim=Lim) #sreg value abline(h=ValMin) I hope there is no real problem here, but only some misunderstanding from my side, because cubic splines are very often used. Best regards, Jean-Luc Dupouey -- INRA-Nancy University Forest Ecology and Ecophysiology Unit F-54280 Champenoux mail:dupo...@nancy.inra.fr [[alternative HTML version deleted]] ______________________________________________ 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.