首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >fitdist函数中的误差:函数mle无法估计参数,错误代码1(瑞利分布)

fitdist函数中的误差:函数mle无法估计参数,错误代码1(瑞利分布)
EN

Stack Overflow用户
提问于 2021-01-27 11:53:05
回答 1查看 485关注 0票数 0

我试图通过使用来自fitdist包的fitdistrplus函数将我的数据与瑞利分布相匹配。

代码语言:javascript
复制
x <- c(19.000000,23.000000,26.000000,45.000000,8.050000,46.900000,1.268333,30.000000,
       1.466667,3.733333,1.683333,4.000000,3.950000,1.850000,42.000000,1.333333,
       1.550000,1.000000,2.066667,1.566667,1.216667,1.850000,1.400000,8.366667,
       19.000000,29.000000,17.000000,42.000000,19.000000,10.000000,53.000000,2.550000,
       15.483333,1.533333,1.216667,1.550000,32.000000,6.583333,6.516667,5.750000,
       9.283333,46.000000,2.016667,2.133333,4.516667,46.950000,1.600000,1.433333,
       3.166667,4.416667,17.016667,2.433333,2.713333,8.633333,3.150000,1.183333,
       14.000000,10.706667,7.026944,31.000000,35.000000,21.000000,14.000000,2.200000,
       26.000000,3.316667,51.000000,13.000000,34.000000,11.650000,49.000000,12.000000,
       26.000000,20.000000,22.000000,6.483333,24.000000,5.333333,4.833333,8.750000,
       6.216667,17.000000,1.083333,19.000000,48.000000,15.000000,1.266667,54.000000,
       32.000000,3.616667,6.666667,1.600000,2.083333,6.933333,33.033333,1.883333,
       1.000000,3.072222,49.000000,1.400000)
dat <- data.frame(x)

# Generate gamma rvs
den <- density(x)
orig <- data.frame(x = den$x, y = den$y)

fit.params.2 <- fitdistrplus::fitdist(dat$x, "rayleigh", start = list(sigma = 1))

然后出现一个错误:

代码语言:javascript
复制
Error in fitdistrplus::fitdist(dat$x, "rayleigh", start = list(sigma = 1)) : 
   the function mle failed to estimate the parameters, 
                with the error code 1

这个问题有什么解决办法吗?谢谢你的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-27 12:13:12

有两个问题。(1)瑞利分布似乎不适合数据(见下面的图输出),(2)您需要一个更好的起始值。由于sigma与瑞利分布的平均值成正比(请参阅维基百科),请尝试:

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

fit <- fitdist(dat$x, "rayleigh", start = list(sigma = mean(dat$x)))
fit
## Fitting of the distribution ' rayleigh ' by maximum likelihood 
## Parameters:
##       estimate Std. Error
## sigma 15.00063   0.749935

plot(fit)

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

https://stackoverflow.com/questions/65918603

复制
相关文章

相似问题

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