[R] why won't rq draw lines?

Liaw, Andy andy_liaw at merck.com
Mon Jul 19 16:04:55 CEST 2004


This works for me:

data(engel)
plot(engel$x, engel$y, xlab="household income", ylab="food expenditure",
     cex=.5)
taus <- c(.05,.1,.25,.75,.9,.95)
lapply(taus, function(tau) abline(coef(rq(y~x, data=engel, tau=tau))))

HTH,
Andy

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of 
> david_foreman at doctors.org.uk
> Sent: Monday, July 19, 2004 9:53 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] why won't rq draw lines?
> 
> 
> I've been trying to draw quantile linear regression lines 
> across a scatterplot of my data using 
> 
> attach(forrq)
>      plot(PREGNANT,DAY8,xlab="pregnant EPDS",ylab="postnatal 
> EPDS",cex=.5)
>      taus <- c(.05,.1,.25,.75,.9,.95)
>      xx <- seq(min(PREGNANT),max(PREGNANT),100)
>      for(tau in taus){
>              f <- coef(rq(DAY8~PREGNANT,tau=tau))
>              yy <- (f[1]+f[2]*xx)
>              lines(xx,yy)
>              }
> which is simply the method from the help file with my dataset 
> attached, and the variable names substituted where 
> appropriate.  I get the scatterplot, but no lines.  Any ideas 
> about what's going on? or wrong?
> 
> 
> ______________________________________________________________
> _________
> Most doctors use http://www.Doctors.net.uk e-mail.
> Move to a free professional address with spam and virus protection.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list