library(quantreg) help(rq) data(engel) y = engel$foodexp x = engel$income fit1 <- rq(y ~ x, tau = 0.5) fit1 summary(fit1, se = "nid") # Uses the Normal approximation fit2 <- rq(y ~ x, tau = 0.95) fit2 summary(fit2, se = "nid") # Uses the Normal approximation # Several values of tau can be handled: plot(x, y, cex = 0.25, type = "n", xlab = "Household Income", ylab = "Food Expenditure") points(x, y, cex = 0.5, col = "black") #abline(rq(y ~ x, tau = 0.5), col = "blue") #abline(lm(y ~ x), lty = 2, col = "red") #taus <- c(0.05, 0.1, 0.25, 0.75, 0.9, 0.95) #for (i in 1:length(taus)) {abline(rq(y ~ x, tau = taus[i]), col = "gray")} abline(rq(y ~ x, tau = 0.05), col = "blue") abline(rq(y ~ x, tau = 0.95), col = "red")