首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >适合列表的gofstat问题

适合列表的gofstat问题
EN

Stack Overflow用户
提问于 2020-03-24 17:41:30
回答 1查看 318关注 0票数 1

当我使用fitdist列表执行gofstat() R函数时,出现错误。我不知道这个错误的含义和导致它的原因。

代码语言:javascript
复制
> gofstat(list(fitw, fitg, fitln), fitnames=c("weibull", "gamma", "lnorm"))
Error in names(Chi2$chisqpvalue) <- names(Chi2$chisqdf) <- fitnames[1] : 
  attempt to set an attribute on NULL

我使用的整个代码如下所示。我认为它与prob向量有关,因为相同的脚本和其他数据集提供了结果。

代码语言:javascript
复制
prob <- c(0.004926108, 0.510983890, 0.306590334, 0.048409000, 0.032272667, 0.005378778, 0.005378778, 0.037651445, 0.005378778, 0.037651445, 0.005378778)

fitw <- fitdist(prob, distr = "weibull", method = "mle")
fitg<- fitdist(prob, distr = "gamma", method = "mle")
fitln <- fitdist(prob, distr = "lnorm", method = "mle")
gofstat(list(fitw, fitg, fitln), fitnames=c("weibull", "gamma", "lnorm"))

对于我来说,werid部分是gofstat单独工作的部分:

代码语言:javascript
复制
> gofstat(fitw)
Goodness-of-fit statistics
                             1-mle-weibull
Kolmogorov-Smirnov statistic     0.2354052
Cramer-von Mises statistic       0.1426774
Anderson-Darling statistic       0.8750089

Goodness-of-fit criteria
                               1-mle-weibull
Akaike's Information Criterion     -33.74893
Bayesian Information Criterion     -32.95314
> gofstat(fitg)
Goodness-of-fit statistics
                             1-mle-gamma
Kolmogorov-Smirnov statistic   0.2760907
Cramer-von Mises statistic     0.1983721
Anderson-Darling statistic     1.1044287

Goodness-of-fit criteria
                               1-mle-gamma
Akaike's Information Criterion   -32.26493
Bayesian Information Criterion   -31.46914
> gofstat(fitln)
Goodness-of-fit statistics
                             1-mle-lnorm
Kolmogorov-Smirnov statistic   0.2781579
Cramer-von Mises statistic     0.1279150
Anderson-Darling statistic     0.8426833

Goodness-of-fit criteria
                               1-mle-lnorm
Akaike's Information Criterion   -36.57233
Bayesian Information Criterion   -35.77654

顺便说一句,你认为哪个分布更适合?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-25 01:24:41

这个错误是因为它在定义chisq中断时有问题,如果你看一下你提供的例子,在0.005378778处有一个意外的峰值,这使得它非常有问题,特别是当n很小时:

代码语言:javascript
复制
table(prob)
prob
0.004926108 0.005378778 0.032272667 0.037651445    0.048409 0.306590334 
          1           4           1           2           1           1 
 0.51098389 
          1

你可以尝试下面这样的东西,但由于你最可能专注于mle,它应该是可以的:

代码语言:javascript
复制
library(fitdistrplus)

fits = lapply(fitnames,function(i){
fitdist(prob, distr = i, method = "mle")
})

 gofstat(fits,chisqbreaks=c(0,0.01,0.1,0.6))

Goodness-of-fit statistics
                             1-mle-weibull 2-mle-gamma 3-mle-lnorm
Kolmogorov-Smirnov statistic     0.2354052   0.2760907   0.2781579
Cramer-von Mises statistic       0.1426774   0.1983721   0.1279150
Anderson-Darling statistic       0.8750089   1.1044287   0.8426833

Goodness-of-fit criteria
                               1-mle-weibull 2-mle-gamma 3-mle-lnorm
Akaike's Information Criterion     -33.74893   -32.26493   -36.57233
Bayesian Information Criterion     -32.95314   -31.46914   -35.77654

再说一次,你的观察是有限的,所以chisq估计将是棘手的。你的第二个关于哪个分布更好的问题,很难分辨,因为n很小,有4个重复值。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60828400

复制
相关文章

相似问题

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