2
$\begingroup$

I have a dataset which contains about 10000 numbers(class numeric), I want to use QQ plot to see if the data fits the exponential distribution.

This is what I did

plot(qexp(ppoints(length(data))),data)

and by observation to determine if the exp distribution fits.

Am I right about this?

$\endgroup$
  • 1
    $\begingroup$ In general, they're not even going to be in the same order. $\endgroup$ – Glen_b Nov 17 '14 at 7:03
2
$\begingroup$

That won't work unless your data are sorted.

This works:

plot(qexp(ppoints(length(data)))[order(order(data))],data)

(that's essentially what stats:::qnorm.default does to get the two variables in the same order)

There's also an example (the third last one, relating to a chi-square with 3 df) in the help for stats::qqplot that you can easily adapt.

(Also, don't call your data data.)

$\endgroup$
1
$\begingroup$

qqplot will sort the points for you. So you can just call

qqplot(qexp(ppoints(length(data))), data)

$\endgroup$
  • $\begingroup$ I like the simplicity of this $\endgroup$ – CloudyGloudy Jun 3 '17 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.