Description Usage Arguments Details Value Warning References See Also Examples
Computes constrained quantile curves using linear or quadratic splines. The median spline (L_1 loss) is a robust (constrained) smoother.
1 2 3 4 5 6 7 8 9 10 | cobsOld(x, y, constraint = c("none", "increase", "decrease",
"convex", "concave", "periodic"),
z, minz = knots[1], maxz = knots[nknots], nz = 100,
knots, nknots, method = "quantile",
degree = 2, tau = 0.5, lambda = 0, ic = "aic",
knots.add = FALSE, alpha = 0.1, pointwise,
print.warn = TRUE, print.mesg = TRUE, trace = print.mesg,
coef = rep(0,nvar), w = rep(1,n),
maxiter = 20*n, lstart = log(big)^2, toler = 1e-6,
factor = 1)
|
x |
vector of covariate. |
y |
vector of response variable. It must have the same length as x. |
constraint |
character (string) specifying the kind of constraint; must be one of "increase", "decrease", "convex", "concave", "periodic" or "none". |
z |
vector of grid points at which the fitted values are
evaluated; default to an equally spaced grid with |
minz |
numeric needed if |
maxz |
analogous to |
nz |
number of grid points in |
knots |
vector of locations of the knot mesh; if missing,
|
nknots |
maximum number of knots; defaults to 6 for regression B-spline, 10 for smoothing B-spline. |
method |
character specifying the method for generating
|
degree |
degree of the splines; 1 for linear spline and 2 for quadratic spline; defaults to 2. |
tau |
desired quantile level; defaults to 0.5 (median). |
lambda |
penalty parameter;
lambda = 0: no penalty (regression B-spline); |
ic |
information criterion used in knot deletion and addition for regression B-spline method when lambda=0; "aic" (Akaike-type) or "sic" (Schwarz-type); default to "aic". |
knots.add |
logical indicating if an additional step of stepwise knot addition should be performed for regression B-splines. |
alpha |
level of significance for the confidence band. |
pointwise |
an optional three-column matrix with each row specifies one of the following constraints:
|
print.warn |
logical flag for printing of interactive warning messages; default to T; probably needs to be set to F if performing monte carlo simulation. |
print.mesg |
logical flag for printing of intermediate messages; default to T; probably needs to be set to F if performing monte carlo simulation. |
trace |
integer >= 0 indicating how much the Fortran
routine |
coef |
initial guess of the B-spline coefficients; default to a vector of zeros. |
w |
vector of weights the same length as x (y) assigned to both x and y; default to uniform weights adding up to one; using normalized weights that add up to one will speed up computation. |
maxiter |
upper bound of the number of iteration; default to 20*n. |
lstart |
starting value for lambda when performing parametric
programming in lambda if |
toler |
numeric tolerance for ???? ; default 1e-6 used to be builtin. |
factor |
determines how big a step to the next smaller lambda should be while
performing parametric programming in lambda; the default |
cobsOld()
computes the constraint quantile smoothing B-spline with
penalty when lambda is not zero.
If lambda < 0, an optimal lambda will be chosen using Schwarz type
information criterion.
If lambda > 0, the supplied lambda will be used.
If lambda = 0, cobsOld computes the constraint quantile regression B-spline
with no penalty using the provided knots or those selected by Akaike or
Schwarz information criterion.
a list with components
coef |
B-spline coefficients. |
fit |
fitted value at z. |
resid |
vector of residuals from the fit. |
z |
as in input. |
knots |
the final set of knots used in the computation. |
ifl |
exit code:
|
icyc |
number of cycles taken to achieve convergence. |
k |
the effective dimensionality of the final fit. |
lambda |
the penalty parameter used in the final fit. |
pp.lambda |
vector of all unique lambda's obtained from parametric programming when lambda < 0 on input. |
sic |
vector of Schwarz information criteria evaluated at pp.lambda. |
cb.lo |
lower bound of the confidence band |
cb.up |
upper bound of the confidence band |
ci.lo |
lower bound of the pointwise confidence interval |
ci.up |
upper bound of the pointwise confidence interval |
This is still a beta version, and we do appreciate comments and
suggestions; library(help = cobs)
shows the authors.
He, X. and Ng, P. (1999) COBS: Qualitatively Constrained Smoothing via Linear Programming; Computational Statistics 14, 315–337.
Koenker, R. and Ng, P. (1996) A Remark on Bartels and Conn's Linearly Constrained L1 Algorithm, ACM Transaction on Mathematical Software 22, 493–495.
Ng, P. (1996) An Algorithm for Quantile Smoothing Splines, Computational Statistics & Data Analysis 22, 99–118.
Bartels, R. and Conn A. (1980) Linearly Constrained Discrete L_1 Problems, ACM Transaction on Mathematical Software 6, 594–608.
A postscript version of the paper that describes the details of COBS can be downloaded from http://www.cba.nau.edu/pin-ng/cobs.html
smooth.spline
for unconstrained smoothing
splines; bs
for unconstrained (regression)
B-splines.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | x <- seq(-1,1,,50)
y <- (f.true <- pnorm(2*x)) + rnorm(50)/10
## specify pointwise constraints (boundary conditions)
con <- rbind(c( 1,min(x),0), # f(min(x)) >= 0
c(-1,max(x),1), # f(max(x)) <= 1
c(0, 0, 0.5))# f(0) = 0.5
## obtain the median regression B-spline using automatically selected knots
cobsOld(x,y,constraint="increase",pointwise=con)->cobs.o
plot(x,y)
lines(cobs.o$z, cobs.o$fit, col = 2, lwd = 1.5)
lines(spline(x,f.true), col = "gray40")
lines(cobs.o$z, cobs.o$cb.lo,lty=2, col = 3)
lines(cobs.o$z, cobs.o$cb.up,lty=2, col = 3)
## compute the median smoothing B-spline using automatically chosen lambda
cobsOld(x,y,constraint="increase",pointwise=con,lambda=-1)->cobs.oo
plot(x,y, main = "COBS Median smoothing spline, automatical lambda")
lines(spline(x,f.true), col = "gray40")
lines(cobs.oo$z, cobs.oo$fit)
lines(cobs.oo$z, cobs.oo$cb.lo,lty=2)
lines(cobs.oo$z, cobs.oo$cb.up,lty=2)
plot(cobs.oo$pp.lambda[-1], cobs.oo$sic[-1], log = "x",
main = "SIC ~ lambda", xlab = expression(lambda), ylab = "SIC")
axis(1, at = cobs.oo$lambda, label = expression(hat(lambda)),
col.axis = 2, mgp = c(3, 0.5, 0))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.