I have a dataset of users' check-ins of a social network. I'm verifying if these data are distributed according to a power-law distribution. To check this I used the function power.law.fit
(iGraph package). Although in the majority of the tests the function returned a p-value grater than 0.05, the KS statistic was smaller than 0.05, for example:
> power.law.fit(data)
$continuous
[1] FALSE
$alpha
[1] 2.865786
$xmin
[1] 44
$logLik
[1] -1358.596
$KS.stat
[1] 0.03006271
$KS.p
[1] 0.9557834
The first question is: the KS statistic is indicating that power-law is not the best fit? As I was in doubt I decided to keep verifying other distributions using compare_distributions
function presented in poweRlaw package.
To compare my data with other distribution, I proceeded as follows (assisted by the post in How to test whether a distribution follows a power law?):
> data_pl <- displ$new(data) #creating a power-law object from data
> est <- estimate_xmin(data_pl)
> data_pl$xmin <- est$xmin
> data_pl$pars <- est$pars
> est$KS #exactly the same KS statistic resulted of power.law.fit
[1] 0.03016107
>
> data_alt <- dislnorm$new(data) #creating a log-normal object
> data_alt$xmin <- est$xmin
> data_alt$pars <- estimate_pars(data_alt)
> comp <- compare_distributions(data_pl, data_alt) #comparing alternatives
> comp$test_statistic #as comp$test_statistic returned a negative value,
#data_alt is a better fit than data_pl
[1] -1.169538
Thus, I observed that according to the function compare_distributions
, my data is better fitted by a discrete log-normal distribution.
The second question is: how to explain that my data are fitted by a log-normal distribution if this distribution type is discrete and not continuous? I'm still confused about the existence of a "discrete" log-normal distribution because according to my basic knowledge in statistics, log-normal is continuous by definition.
Aiming at discovering the parameters of the log-normal distribution, I invoked the function fitdist
presented on fitdistrplus package as follows:
> fitdist(data,"lnorm")
Fitting of the distribution ' lnorm ' by maximum likelihood
Parameters:
estimate Std. Error
meanlog 0.8657701 0.00778204
sdlog 1.0336940 0.00550271
Thus, I decided to build a quantile-quantile plot aiming at verifying the similarity of my data and the fitted distribution (result in Figure (a)):
> qqplot(rlnorm(length(data),0.8657701,1.0336940),data)
> abline(0,1)
Now I'm really confused about the approximation using a log-normal of my data. Thus, the last questions emerge: which distribution really fits my data? Anyone suggest any other way to investigate it?
To help the understanding of my questions, follows the histogram (Figure (b)), the density distribution (Figure (c)) and the ECDF (Figure (d)).