全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3859 2
2012-10-13
如何用R中的KS检验法检验power-law或zipf-law??如何用R软件绘制zipf分布图形??请各位高手帮忙解答一下!谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-12-17 14:01:39
检验power law distribution的规范的方法,首先是用maximum log-likelihood estimate进行参数估计,然后进行bootstrap analysis,接下来进行K-S test,最后是test against real alternatives
  
以Bibliometrics or Informetrics.....这篇文献,在杂志上page-121的实证数据,为例说明:
  
Lotka's Law : y = c*x^(-beta)
Here
y = [709,92,24,13,6,10]
x = [1,2,3,4,5,6]
1.应用s-plus Nonlinear least-squares algorithm 估计c & beta
x <- c(1,2,3,4,5,6)
y <- c(709,92,24,13,6,10)
Table2.data <- data.frame(x,y)
fit<- nls(y~c*x^-(beta),data=Table2.data,start=list(c=500,beta=2))
fit
  

执行结果如下
Residual sum of squares : 56.14811
parameters:
c beta
709.0087 2.957453
formula: y ~ c * x^( - (beta))
6 observations
与作者实证之c & beta 值接近
  
2.利用c & beta 之估计值算出f'(Lokta)
f'(Lokta) = [709.04,90.89,27.33,11.65,6.01,8.04]
3.利用 f(x) 创建 empirical cumulative distribution S(x)
f'(Lokta) 创建 hypothesized cumulative distribution F*(x)
  
4.计算KS test statistic.
|F*(x)-S(x)| 绝对值的最大值,就是KS test statistic
本例六组数据中的最大值,是0.00265
所以page-121 Table2,作者列出的K-S 是0.0027.

详细的文献在这里:http://1044.cnc.pinggu.com/forum ... 007416811182163.pdf

画图我也给你个小例子,plot就好了。
  
这个例子是VGAM包里Zipf函数——

N = 10; s = 0.5; y = 1:N
proby = dzipf(y, N = N, s = s)
plot(proby ~ y, type = "h", col = "blue", ylab = "Probability",
     ylim = c(0, 0.2), main = paste("Zipf(N = ",N,", s = ",s,")", sep = ""),
     lwd = 2, las = 1)
sum(proby)  
max(abs(cumsum(proby) - pzipf(y, N = N, s = s)))



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2017-4-28 11:07:09
DM小菜鸟 发表于 2014-12-17 14:01
检验power law distribution的规范的方法,首先是用maximum log-likelihood estimate进行参数估计,然后进行 ...
你好,请问第4步中的ks检验

代码是ks.test(y,f'(Lokta) )吗?其中的两个参数全是原始观测值和估计的观测值么?

因为不清楚你具体指的哪篇文献,我无从考证,也得不出你说的检验结果
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群