qsmspline.RdThis function is used to fit a quantile smoothing spline with L2 penalty.
qsmspline(x, y, p, lambda = 1, maxIter = 300, eps = 1e-2, gamma = 10,
aggressive = FALSE)vectors giving the coordinates of the points to be interpolated.
quantile to be estimated.
penalty parameter.
the maximum number of iterations.
the absolute convergence tolerance.
scaling for initial values.
aggressive step size in Bosch et al (1995) - not yet implemented.
This is an implementation of Bosch et al's (1995) algorithm to fit a quantile smoothing spline with L2 penalty. The penalty parameter must be set by the user.
a list containing the following components (see Bosch et al, 1995)
first set of constraints.
second set of constraints.
Lagrangian associated with a1.
Lagrangian associated with a2.
fitted values.
Bosch RJ, Ye Y, and Woodworth GG. A convergent algorithm for quantile regression with smoothing splines. Computational Statistics and Data Analysis. 1995;19(6):613-30.
# Generate data
set.seed(123)
n <- 100
x <- sort(runif(n, 0, 2*pi))
y <- sin(x) + (1 + x)*rnorm(n, 0, 0.1)
# Fit median - lambda set at an arbitrary value
fit <- qsmspline(x = x, y = y, p = 0.5, lambda = 0.1)
#> Error in solve.default(M, y): Lapack routine dgesv: system is exactly singular: U[307,307] = 0
# Plot
plot(x, y)
lines(x, fit[['fit']])
#> Error: object 'fit' not found