[R] probability plot correlation coefficient
kjetil brinchmann halvorsen
kjetil at entelnet.bo
Sat Aug 9 16:36:48 CEST 2003
On 6 Aug 2003 at 19:58, anne wrote:
It is not very clear what you want. For fitting distributions like
you mentiones, the easiest way for you is maximum likelihood
via fitdistr() in package MASS:
library(MASS)
?fitdistr
x <- rweibull(100, shape=3, scale=2)
fitdistr(x, dweibull, start=list(shape=5, scale=0.5) )
shape scale
3.1391369 2.0803995
(0.2383695) (0.0700139)
I don't know about PPCC, but it looks like you want to estimate the
shape by selecting the shape to maximize the correlation coefficient
in a probability plot. While that makes intuitive sense, what I have
given above is probably better.
If you want to get the correlation coefficient corresponding to a
probability plot, it is easy:
qqplot( qweibull(ppoints(x), shape=3, scale=2), x )
cor( qweibull(ppoints(x), shape=3, scale=2), sort(x) )
[1] 0.9940447
and you can even easily write a function to do PPCC (If i have
understood it correctly): (But the example also show that if I have
understood correctly, it is'nt a very good or reliable method)
> PPCC <- function(shape, scale, x) { # only for weibull
+ x <- sort(x)
+ pp <- ppoints(x)
+ cor( qweibull(pp, shape=shape, scale=scale), x)}
> PPCC(3,2,x)
[1] 0.9940447
> optim(par=c(shape=5, scale=0.5), function(par) PPCC(par[1], par[2],x),
+ method="BFGS")
$par
shape scale
99.9199 0.5000
$value
[1] 0.9490552
$counts
function gradient
12 11
$convergence
[1] 0
$message
NULL
> optim(par=c(shape=5, scale=2), function(par) PPCC(par[1], par[2],x),
+ method="BFGS")
$par
shape scale
99.9199 2.0000
$value
[1] 0.9490552
$counts
function gradient
12 11
$convergence
[1] 0
$message
NULL
> optim(par=c(shape=3, scale=2), function(par) PPCC(par[1], par[2],x),
+ method="BFGS")
$par
shape scale
3.403016 2.000000
$value
[1] 0.992391
$counts
function gradient
100 100
$convergence
[1] 1
$message
NULL
As the example show, you need some very good starting value to get
something reasonable. Strick with fitdistr()!
Kjetil Halvorsen
> As a newbie to R, I'm still rather at a loss for finding information
> (the commands names can be rather arcane)so I'm just posting my question:
> I would like to estimate the shape coefficient of diverse
> distributions (Weibull, gamma and Tukey-Lambda specifically, but other
> could be of interest)
> - Does R have a PPCC utility to estimate such parameter?(maximum value
> of correlation coef)
> - If yes how does one retrieve the numerical value from the graph? (see
> graphical example below)
> - The retrieval of numerical values is also a problem for me from the
> probability plots....
>
>
>
>
> Thank for any help!
> Anne
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list