I have some data on the duration of several activities (rounded to the nearest half hour). I'm trying to add up these random variables (one per activity) so that I can calculate the total duration of a project, as well as extract some summary statistics from it.
In order to do that, I'm trying to determine which distribution fits it reasonably well. This is for two reasons:
- if I can model these RVs by using a "named" distribution, it becomes simpler to combine them
- by fitting a "named" distibution, I assume I'll be able to infer the generator behind the data. For instance, if a lognormal is a good fit for the data, then it might be generated by some sort of random walk process.
I've selected five candidate distributions: lognorm
, exponweib
, norm
, t
and dweibull
. Three of them are unbounded; I've chosen them just to see if they fit my data reasonably well, even though time durations can't possibly be negative.
I've also selected two criteria with which to judge goodness-of-fit, K-S and AIC. I wanted something that would apply to all of the distributions I selected, in an automated manner. I also wanted a criterion that would penalize more parameters.
However, something apparently strange happened. Here are the distributions' CDFs and the duration data empirical CDF (dashed line):
Judging by this plot, the norm
, dweibull
and t
are all reasonably good fits, which is confimed by their K-S scores.
Now here are the same distributions in PDF form (as well as the data histogram):
Judging by this plot, the lognorm
and exponweib
are the clear winners, with dweibull
a distant third. This is also confirmed by their AIC scores.
Here is the code in Python that calculates the AIC:
def aic(dist, dados, second_order = True):
fit = dist.fit(dados)
k = len(fit)
lnL = dist(*fit).logpdf(dados).sum()
aic = 2 * k - 2 * lnL
if second_order:
n = len(dados)
aicc_p = 2 * ((k ** 2 + k) / (n - k - 1))
aic += aicc_p
return aic
In light of this, I have a few questions:
- Is this a good strategy (fitting a distribution to the data) for my problem (adding RVs up and extracting summary statistics)?
- Is it possible/surprising/normal that the K-S and AIC statistics give opposing results when used as goodness-of-fit criteria?
- Which distribution should I pick? Am I misusing these statistics? Is there some other consideration I should be making before choosing?