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

David Carlson dcarlson at tamu.edu
Fri Jun 21 17:39:13 CEST 2013


Your "rate" variable is not a single value, but a vector of 200!.
I'm surprised you get anything at all. You have to pick one rate
value to use to create the values for the x-axis. For example run

> rate <- 1/4

And then run the qqmath() function.

Or, change the rate variable in the ggamma() function to

qgamma(x,shape,1/4).

-------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Yvonnick Noel
Sent: Friday, June 21, 2013 9:55 AM
To: r-help at r-project.org
Cc: Deepayan.Sarkar at r-project.org
Subject: [R] Superpose two QQ-plots (gamma distribution) with
lattice function qqmath()

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