https://github.com/cran/quantreg
Raw File
Tip revision: d55e8b38f04442926fbd3c06051c3552f82ea9c8 authored by Roger Koenker on 03 June 2019, 11:40:03 UTC
version 5.40
Tip revision: d55e8b3
arqss.R
# A toy example to illustrate univariate smoothing with automatic lambda selection
n <- 2000
x <- 1:n/n
noise <- rgamma(n,3,1)
g0 <- function(x) sin(10*x)
y <- g0(x)+noise
arqss <- function(x,y,tau,g0 = NULL){
    g <- function(lam,y,x,tau) AIC(rqss(y ~ qss(x, lambda = lam),tau = tau),k = -1)
    lamstar <- optimize(g, interval = c(0.01, .5), x = x, y = y, tau = tau)
    f <- rqss(y ~ qss(x, lambda = lamstar$min))
    plot(f)
    lines(x,g0(x)+qgamma(tau,3,1),col = "red")
    text(.7,2,paste("lambda = ", round(lamstar$min,3)))
}
arqss(x,y,.5,g0)

back to top