Suggestion for qqplot() improvement

Prof Brian D Ripley ripley@stats.ox.ac.uk
Tue, 31 Aug 1999 16:12:39 +0100 (BST)


On 31 Aug 1999, Peter Dalgaard BSA wrote:

> Martin Maechler <maechler@stat.math.ethz.ch> writes:
> 
> > Maybe even
> >       qqplot(qt(ppoints(n), df=5), y, 
> > 	     xlab='quantiles of t(* ,df=5)', ylab='data')
> > 
> >     WSt> and this could be shortened to
> > 
> >     WSt>   qqplot(y, distribution='t', df=5)
> > 
> >     WSt> with an easy extension of the function.
> > 
> > I found:
> > 
> >    Trellis in S-plus has
> > 	    qqmath(formula, distribution = qnorm, f.value = ppoints, ...),
> >    for your example
> >         qqmath( ~ y, distribution = function(p) qt(p, df=5), ...)
> > 
> > which is slightly more general (also works with panels, banking to 45
> > deg,..) but quite a bit more complicated to use for non-sophisticated users.
> > 
> > What should we do / would we want for R?
> 
> Lets see. "qqplot(qt, y, df=5)" would be tempting save for the
> complexities of separating parts of ... intended for the quantile
> function from those intended for the plotting. 
> 
> 
> We could "easily" have qqplot(y, distrib=qt(p,df=5)), here's a
> simplified variant:
>                        
> f <- function(y,distrib){
>     p <- ppoints(length(y))
>     x <- eval(eval(substitute(substitute(distrib)),list(p=p)))
>     qqplot(x,y,
>         xlab=deparse(substitute(distrib)),
>         ylab=deparse(substitute(y)))
> }
> 
> f(rnorm(100), distrib=qt(p,df=2))
> 
> The form, e.g., qqplot(qt, y, df=5, lty=3) may not be *all* that hard
> to set up. It's just necessary to manipulate the argument list,
> somewhat along the lines of
> 
> g <- function(p,...){
>     l<-list(...)
>     m<-match(names(l), names(formals(qt)))
>     do.call("qt", c(list(p=p), l[!is.na(m)]))    
> }
> 
> which is just a long-winded version of qt, except that it strips off
> unused arguments. 

If it helps, surf.gls in my spatial library does almost precisely that in
the parent, that is matches up those arguments that apply to the (here)
distrib argument and packages a function to do the work. (It is a bit more
than is needed here, as that needs to return the function for future use or
(once) to pass to call_S.)  So I don't think it is hard (the second time).

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._