robustSmoothSpline | R Documentation |
Fits a smoothing spline robustly using the L_1
norm. Currently, the
algorithm is an iterative reweighted smooth spline algorithm which
calls smooth.spline(x,y,w,...)
at each iteration with the weights
w
equal to the inverse of the absolute value of the residuals for
the last iteration step.
## Default S3 method:
robustSmoothSpline(x, y=NULL, w=NULL, ..., minIter=3, maxIter=max(minIter, 50),
method=c("L1", "symmetric"), sdCriteria=2e-04, reps=1e-15, tol=1e-06 * IQR(x),
plotCurves=FALSE)
x |
a |
y |
responses. If |
w |
a |
... |
Other arguments passed to |
minIter |
the minimum number of iterations used to fit the smoothing spline robustly. Default value is 3. |
maxIter |
the maximum number of iterations used to fit the smoothing spline robustly. Default value is 25. |
method |
the method used to compute robustness weights at each
iteration. Default value is |
sdCriteria |
Convergence criteria, which the difference between the standard deviation of the residuals between two consecutive iteration steps. Default value is 2e-4. |
reps |
Small positive number added to residuals to avoid division by zero when calculating new weights for next iteration. |
tol |
Passed to |
plotCurves |
If |
Returns an object of class smooth.spline
.
Henrik Bengtsson
This implementation of this function was adopted from
smooth.spline
of the stats package.
Because of this, this function is also licensed under GPL v2.
data(cars)
attach(cars)
plot(speed, dist, main = "data(cars) & robust smoothing splines")
# Fit a smoothing spline using L_2 norm
cars.spl <- smooth.spline(speed, dist)
lines(cars.spl, col = "blue")
# Fit a smoothing spline using L_1 norm
cars.rspl <- robustSmoothSpline(speed, dist)
lines(cars.rspl, col = "red")
# Fit a smoothing spline using L_2 norm with 10 degrees of freedom
lines(smooth.spline(speed, dist, df=10), lty=2, col = "blue")
# Fit a smoothing spline using L_1 norm with 10 degrees of freedom
lines(robustSmoothSpline(speed, dist, df=10), lty=2, col = "red")
legend(5,120, c(
paste("smooth.spline [C.V.] => df =",round(cars.spl$df,1)),
paste("robustSmoothSpline [C.V.] => df =",round(cars.rspl$df,1)),
"standard with s( * , df = 10)", "robust with s( * , df = 10)"
), col = c("blue","red","blue","red"), lty = c(1,1,2,2), bg='bisque')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.