[R] Superpose two QQ-plots (gamma distribution) with, lattice function qqmath()
Duncan Mackay
mackay at northnet.com.au
Sat Jun 22 16:46:57 CEST 2013
Hi
I think the answer lies in the allocating the distribution argument
but I do not know how. Possibly with a prepanel function
Duncan
At 21:06 22/06/2013, you wrote:
>David, Duncan,
>>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))
>
>I don't think the problem is related to the rate argument, which can
>well be vectorized, as is the case for a number of arguments in
>distrib functions in R (note that you are redefining it as a vector above).
>
>>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, ...)
>> })
>
>This works! Thank you very much (I had spent some time on that).
>
>I now try to add a QQ-line but face a new problem. Only one line
>appears, away from the points:
>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, ...)
> panel.qqmathline(x,groups,...)
> })
>
>Any hint?
>
>Thanks a lot for your help,
>
>Yvonnick
>
More information about the R-help
mailing list