[R] Superpose two QQ-plots (gamma distribution) with lattice function qqmath()

Duncan Mackay mackay at northnet.com.au
Sat Jun 22 06:23:49 CEST 2013


Hi

Following on David's rate argument

try (with modifications of pch and grid)

rate <- 1/4
shape = 8
rate = c(rep(1/4,100),rep(1/3,100))
x = rgamma(200,shape,rate)
groups = gl(2,100,200,labels=LETTERS[1:2])
dat = data.frame(x=x, gp=groups)

qqmath(~ x,  data = dat,
        groups = gp,
        pch = 20,
        type = c("p","g"),
        distribution = function(x) qgamma(x,shape,rate),
        panel = function(x,groups,...) {
                  panel.qqmath(x,groups, ...)
        })

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au


At 00:55 22/06/2013, you wrote:
>Hello,
>
>I am trying to superpose on a single panel two QQ plots with the 
>lattice qqmath function.
>
>Here is a reproducible example of the problem I am facing:
>
># Generate data
>shape = 8
>rate = c(rep(1/4,100),rep(1/3,100))
>x = rgamma(200,shape,rate)
>groups = gl(2,100,200,labels=LETTERS[1:2])
>
># Plot
>qqmath(~x,groups=groups,panel = "panel.superpose",
>distribution = function(x) qgamma(x,shape,rate),
>panel.groups = function(x,subscripts,...) {
>         panel.qqmath(x,shape=shape,rate=rate[subscripts],...)
>         panel.qqmathline(x,shape=shape,rate=rate[subscripts],...)
>})
>
>Both data series seem to be reproduced twice, somewhat rescaled.
>
>I don't understand what this mean.
>
>What am I doing wrong?
>
>Thanks a lot for your help,
>
>Yvonnick Noel
>University of Brittany, Rennes
>Dpt. of Psychology
>France
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list