Use QQplot to check if data fits exponential distribution

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.

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

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.)

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

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

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