3
$\begingroup$

I am trying to familiarize myself with the Cullen and Frey plot. So, I generated 1000 exponentially distributed numbers using the command:

x <- rexp(1000, 2)

Then, with the fitdistrplus package, I created the Cullen and Frey plot.

install.packages("fitdistrplus")
library(fitdistrplus)
descdist(x, discrete = FALSE, boot = 200)

The problem is that it does not recognize the numbers in the x vector as exponentially distributed.

enter image description here

Why does this happen?

$\endgroup$
6
  • 2
    $\begingroup$ What is being shown on the graph? One sample gives one sample skewness and one sample kurtosis, so why are there many points on the graph? $\endgroup$
    – Nick Cox
    Commented Jul 25, 2023 at 8:29
  • 1
    $\begingroup$ The blue point is the sample, the yellow points are by bootstrapping. Note the argument in OPs code boot=200 . The exponential distribution lies on the extreme margins of the bootstrapped cloud. $\endgroup$ Commented Jul 25, 2023 at 21:08
  • 2
    $\begingroup$ Your result is irreproducible because it's random and you didn't specify a seed. Do it again and look at the difference. You just happened to get unlucky with this particular sample. (That's an indication that the Cullen-Frey method isn't terribly reliable.) $\endgroup$
    – whuber
    Commented Jul 25, 2023 at 22:00
  • $\begingroup$ @whuber , I get the same results if I set set.seed(50). I suspect that what jbowman said is happening. $\endgroup$ Commented Jul 26, 2023 at 5:44
  • $\begingroup$ Yes -- that's exactly what I said. When you repeat your study with different seeds (or a random seed), sometimes the results fall where expected on the graph and other times they don't. The problem is that you have only looked at a single dataset, whereas to understand what's going on you need to look at many datasets. $\endgroup$
    – whuber
    Commented Jul 26, 2023 at 14:28

1 Answer 1

3
$\begingroup$

It so happens that skewness and kurtosis are not very accurately estimated for an exponential distribution, even with 1000 observations:

sk <- rep(10,10000)
for (i in seq_along(sk)) {
  x <- rexp(1000,2)
  sk[i] <- skewness(x)
}
quantile(sk^2, c(0.1,0.25,0.5,0.75,0.9))

10%      25%      50%      75%      90% 
2.893270 3.270011 3.786337 4.452599 5.262877 

We expect to see skewnesses less than 3.27 roughly 25% of the time.

Kurtosis is, as one might expect, no better; the code revision is straightforward so I don't present it here.

> quantile(ku, c(0.1,0.25,0.5,0.75,0.9))
      10%       25%       50%       75%       90% 
 6.426070  7.162297  8.187794  9.640750 11.569109 

Let's put this together and show, in a heuristic way, how unusual your results were for a sample size of 1000:

dt <- data.table(sk2 = rep(0, 1000), ku = rep(0, 1000))
for (i in 1:1000) {
  x <- rexp(1000,2)
  dt$sk2[i] <- skewness(x)^2
  dt$ku[i] <- kurtosis(x)
}
x <- densCols(dt$sk2, dt$ku, colramp=colorRampPalette(c("black", "white")))
dt$dens <- col2rgb(x)[1,] + 1L

## Map densities to colors
cols <-  colorRampPalette(c("#FF3100", "#FF9400", "#FCFF00", 
                            "#45FE4F", "#00FEFF", "#000099"))(6)
dt$col <- ifelse(dt$dens >= 250, cols[1], 
                 ifelse(dt$dens >= 200, cols[2], 
                        ifelse(dt$dens >= 150, cols[3], 
                               ifelse(dt$dens >= 100, cols[4], 
                                      ifelse(dt$dens >= 50, cols[5], cols[6])))))

## Plot it, reordering rows so that densest points are plotted on top
plot(ku~sk2, data=dt[order(dt$dens),], pch=20, col=col, cex=1, ylim=c(5,15), xlim=c(2,7))

biv_kde <- MASS::kde2d(x1, x2)
contour(biv_kde, add = T)

points(3, 6.8, pch=17, col=1)

enter image description here ... so your data, which is marked by the black triangle just below and to the left of the highest density region, doesn't appear to be too extreme.

$\endgroup$
3
  • 1
    $\begingroup$ Thank you very much! From what I understand, the Cullen and Frey graph is not suitable on its own to recognize an exponential distribution. $\endgroup$ Commented Jul 26, 2023 at 5:39
  • 1
    $\begingroup$ Yes, that would be correct, unfortunately. $\endgroup$
    – jbowman
    Commented Jul 26, 2023 at 13:56
  • $\begingroup$ Thank you very much for the time you dedicated to me! $\endgroup$ Commented Jul 29, 2023 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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