From p.dalgaard@biostat.ku.dk  Tue Aug 31 15:56:48 1999
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 31 Aug 1999 16:56:48 +0200
Subject: Suggestion for  qqplot() improvement
In-Reply-To: Martin Maechler's message of "Tue, 31 Aug 1999 15:42:48 +0200"
References: <199908311257.OAA00978@erna-w.ethz.ch> <199908311342.PAA01425@sophie.ethz.ch>
Message-ID: <x2zoz880cv.fsf@blueberry.kubism.ku.dk>

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. 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


Suggestion for qqplot() improvement
Peter Dalgaard BSA