首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R中幂律分布的拟合优度检验

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

Stack Overflow用户
提问于 2014-02-04 01:20:09
回答 1查看 5.7K关注 0票数 3

我有一个网络,我加入了一个权力法律使用igraph软件:

代码语言:javascript
复制
plf = power.law.fit(degree_dist, impelementation = "plfit")

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

代码语言:javascript
复制
$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

图表手册解释了这些变量:

代码语言:javascript
复制
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是:

代码语言:javascript
复制
 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 %的节点具有21级)。

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

我不确定用degree_dist计算plf是否是一个错误。如果是的话,我还使用来自网络中100个节点的度数运行相同的函数:

代码语言:javascript
复制
plf = power.law.fit(pure_deg, impelementation = "plfit")

其中,pure_deg是:

代码语言:javascript
复制
  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

这导致了以下方面的产出:

代码语言:javascript
复制
$continuous
[1] FALSE
$alpha
[1] 2.362445
$xmin
[1] 1
$logLik
[1] -114.6303
$KS.stat
[1] 0.02293443
$KS.p
[1] 1
EN

回答 1

Stack Overflow用户

发布于 2014-02-14 10:44:30

在R中有一个名为powerRlaw的包,由Colin编写。这个包有很好的文档记录,并包含了许多使用每个函数的示例。非常直白。

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

例如,如文档所述,在R中,以下代码从文件full_path_of_file_name获取数据,并按照克劳塞特和艾尔。(2009)的建议估计xmin和alpha并获取p值

代码语言:javascript
复制
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)              
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21541240

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档