Using lattice
you should just use y
and x
within the panel function.
xyplot(foodexp~income , data =engel,
type = c("g"),
auto.key=list(x=.8,y=.35,cex=.8,cex.title=.8, title="", points=TRUE),
scales=list(tck=-1),ylab=list("Food Expenditure",font=3),
xlab=list("Household Income",font=3),
panel=function(x,y,...){
panel.xyplot(x,y)
panel.grid()
panel.abline(rq(y ~ x, tau = 0.5))
panel.points(x, y, cex = 0.5, col = "blue")
panel.abline(rq(y ~ x, tau = 0.5), col = "blue")
panel.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)) {
panel.abline(rq(y ~ x, tau = taus[i]),
col = "gray")
}
}
)