1

我想使用 R 中 fitdistrplus 包中的 fitdist() 函数将 Weibull 分布拟合到我的数据中。我的数据分成箱,并且需要在每个箱中进行拟合。但是,我有一些只有一个数据值的 bin,而 fitdist() 函数不喜欢这样。我想知道是否有一种方法可以“告诉” fitdist() 不适合该垃圾箱 - 我正在考虑类似于为避免负值所做的事情,即 fitdist(x[x > 0], "weibull" )。

这是我的数据示例:

structure(list(X1 = c(1.55752015113831, 1.86181771755219, 1.3730936050415, 
1.47793698310852, 1.66031086444855, 1.31968522071838, 1.19886374473572, 
1.63071382045746, 1.79910719394684, 1.83555865287781, 2.51496362686157, 
2.77573442459106, 2.41649007797241, 2.16212272644043, 2.20722556114197, 
2.22031855583191, 2.56367325782776, 2.23889565467834, 2.06307983398438, 
2.04429388046265), X2 = c(5.96779193297146, 6.0423492582171, 
0.145518317755237, 0.156240204303897, 0.0690296680870719, 6.24221097591206, 
6.12635547901035, 6.17154346375459, 0.00877351789515712, 6.18053695875579, 
6.10040350681974, 6.04536502183551, 6.16195714909474, 6.13228633875795, 
6.10040350681974, 5.9043000420551, 6.05266261585455, 5.98250856115524, 
5.84601250054097, 5.85279344130853), X3 = c(35, 35, 1, 1, 1, 
36, 36, 36, 1, 36, 35, 35, 36, 36, 35, 34, 35, 35, 34, 34), X4 = c(2008, 
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008)), row.names = 31249:31268, class = "data.frame")

我拟合 Weibull 分布的方式如下:

MLE<- aggregate(data$X1, by = list(data$X3), FUN = function(x) fitdist(x[x > 0], "weibull")$estimate)
4

0 回答 0