1## Demo for a Plot of Engel curve in sample space 2 3data(engel) 4 5plot(foodexp ~ income, data = engel, cex= .5, col = "blue", 6 xlab = "Household Income", ylab = "Food Expenditure") 7 8z <- rq(foodexp ~ income, tau= .50, data = engel)# "median line": L1 - regression 9abline(z, col = "dark blue") 10abline(lm(foodexp ~ income, data = engel), lty=2, col="red") #the dreaded ols line 11 12taus <- c(.05,.1,.25,.75,.90,.95) 13nt <- length(taus) 14 15for( i in 1:length(taus)) { 16 abline(rq(foodexp~income, tau=taus[i], data = engel), col="gray") 17} 18 19legend("bottomright", 20 c("L1 (tau = .50)", "OLS", paste("tau= ", formatC(rev(taus)))), 21 col = c("dark blue", "red", rep("gray", nt)), 22 lty = c(1,2, rep(1, nt)), 23 inset = 0.03) 24