qsmspline: Quantile Regression with Smoothing Splines

View source: R/Qtools.R

qsmsplineR Documentation

Quantile Regression with Smoothing Splines

Description

This function is used to fit a quantile smoothing spline with L2 penalty.

Usage

qsmspline(x, y, p, lambda = 1, maxIter = 300, eps = 1e-2, gamma = 10,
	aggressive = FALSE)

Arguments

x, y

vectors giving the coordinates of the points to be interpolated.

p

quantile to be estimated.

lambda

penalty parameter.

maxIter

the maximum number of iterations.

eps

the absolute convergence tolerance.

gamma

scaling for initial values.

aggressive

aggressive step size in Bosch et al (1995) - not yet implemented.

Details

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.

Value

a list containing the following components (see Bosch et al, 1995)

a1

first set of constraints.

a2

second set of constraints.

b1

Lagrangian associated with a1.

b2

Lagrangian associated with a2.

fit

fitted values.

Author(s)

Marco Geraci

References

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.

Examples

# 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)

# Plot
plot(x, y)
lines(x, fit[['fit']])

Qtools documentation built on Aug. 8, 2025, 7:19 p.m.