# using simulated data
set.seed(1234); n <- 1000
x1 <- rexp(n)
x2 <- runif(n)
qy <- function(p,x){qnorm(p)*(1 + x)}
# true quantile function: Q(p | x) = beta0(p) + beta1(p)*x, with
# beta0(p) = beta1(p) = qnorm(p)
y <- qy(runif(n), x1) # to generate y, plug uniform p in qy(p,x)
# note that x2 does not enter
model <- iqr(y ~ x1 + x2, formula.p = ~ I(qnorm(p)) + p + I(p^2))
# beta(p) is modeled by linear combinations of b(p) = (1, qnorm(p),p,p^2)
summary(model)
# interpretation:
# beta0(p) = model$coef[1,]*b(p)
# beta1(p) = model$coef[2,]*b(p); etc.
# x2 and (p, p^2) are not significant
summary(model, p = c(0.25, 0.75)) # summary of beta(p) at selected quantiles
Run the code above in your browser using DataLab