https://github.com/cran/quantreg
Raw File
Tip revision: e821ee31706f5ae32f14507d2df5c39ddfadf110 authored by Roger Koenker on 28 September 2020, 07:20:11 UTC
version 5.70
Tip revision: e821ee3
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