繁体   English   中英

R中幂律分布的拟合优度检验

[英]Goodness of fit test for power law distribution in R

我有一个网络,可以使用igraph软件将其纳入幂律规则:

plf = power.law.fit(degree_dist, impelementation = "plfit")

现在,plf变量包含以下变量:

$continuous
[1] TRUE
$alpha
[1] 1.63975
$xmin
[1] 0.03
$logLik
[1] 4.037563
$KS.stat
[1] 0.1721117
$KS.p
[1] 0.9984284

igraph手册解释了以下变量:

xmin = the lower bound for fitting the power-law
alpha =  the exponent of the fitted power-law distribution
logLik =  the log-likelihood of the fitted parameters
KS.stat =  the test statistic of a Kolmogorov-Smirnov test that compares the fitted  distribution with the input vector. Smaller scores denote better fit
KS.p = the p-value of the Kolmogorov-Smirnov test. Small p-values (less than 0.05) indicate that the test rejected the hypothesis that the original data could have been drawn from the fitted power-law distribution

我想对此幂律拟合进行“拟合优度”检验。 但是我不确定如何执行此操作,尽管我发现在线论坛中已经问过这个问题,但通常仍然没有答案。

我认为执行此操作的一种方法是执行chisq.test(x,y)。 一个输入参数(例如x)将是degree_dist变量(观察到的网络度分布)。 另一个输入参数(例如y)将是拟合的幂律方程,假定其形式为P(k)= mk ^ a。

我不确定这是否是一种合理的方法,如果是,我需要有关如何构造拟合幂律方程的建议。

如果有帮助,我的网络的degree_dist为:

 0.00 0.73 0.11 0.05 0.02 0.02 0.03 0.02 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00        0.01 0.00 0.00 0.00 0.01

(这些频率在网络中发生0-21度。(例如,73%的节点具有1级,1%的节点具有21级)。

** * ** * *** 编辑 ** * ** * ** * ****

我不确定使用degree_dist计算plf是否在上面。 如果是这样,我还使用网络中100个节点的度数运行了相同的函数:

plf = power.law.fit(pure_deg, impelementation = "plfit")

其中,pure_deg是:

  21  7  5  6 17  3  6  6  2  5  4  3  7  4  3  2  2  2  2  3  2  3  2  2  2  2  2  1  1  1  1  1  1 1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1 1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1 1

这导致输出:

$continuous
[1] FALSE
$alpha
[1] 2.362445
$xmin
[1] 1
$logLik
[1] -114.6303
$KS.stat
[1] 0.02293443
$KS.p
[1] 1

Colin Gillespie在R中有一个名为powerRlaw的软件包。 该软件包文档齐全,并包含许多使用每个函数的示例。 非常简单。

http://cran.r-project.org/web/packages/poweRlaw/

例如,在R作为文档所述,下面的代码获得从文件full_path_of_file_name和估计XMIN和α的数据和所提议得到p值Clauset和人。 (2009年)

library("poweRLaw")

words = read.table(<full_path_of_file_name>)
m_plwords = displ$new(words$V1)         # discrete power law fitting
est_plwords = estimate_xmin(m_plwords)  # get xmin and alpha

# here we have the goodness-of-fit test p-value
# as proposed by Clauset and al. (2009)
bs_p = bootstrap_p(m_plwords)              

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM