将Weibull累积分布拟合到R中的大量传递数据

时间:2019-04-16 12:23:38

标签: r weibull fitdistrplus

我有一些碎石料的粒度传递质量累积数据,我希望使用R将其拟合为Weibull分布。我已经在Excel中使用WEIBULL.DIST()函数通过累积开关集设法做到了这一点改为TRUE。
然后,我使用excel SOLVER使用RMSE来获得alpha和beta参数,以获得最佳拟合。我想在R中重现结果。

(请参阅附件电子表格here

粒子数据和累积质量通过百分比为以下向量

d.mm <- c(20.001,6.964,4.595,2.297,1.741,1.149,
          0.871,0.574,0.287,0.082,0.062,0.020)
m.pct <- c(1.00,0.97,0.78,0.49,0.27,0.20,0.14,
         0.11,0.07,0.03,0.025,0.00)

这是我想要拟合Weibull结果的情节:

plot(log10(d.mm),m.pct)

...根据电子表格计算直径值矢量的函数

   d.wei <- c(seq(0.01,0.1,0.01),seq(0.2,1,0.1),seq(2,30,1))

我使用规划求解确定的Excel中的Weibull alpha和beta最佳值分别为1.41和3.31 所以我的问题是如何在R(不一定是Solver部分)中重现此分析,但如何将Weibull拟合到该数据集?

1 个答案:

答案 0 :(得分:1)

非线性最小二乘函数nls是Execl求解器的R版本。

pweibull将计算威布尔分布的概率分布。代码中的注释应说明分步解决方案

d.mm <- c(20.001,6.964,4.595,2.297,1.741,1.149,
          0.871,0.574,0.287,0.082,0.062,0.020)
m.pct <- c(1.00,0.97,0.78,0.49,0.27,0.20,0.14,
           0.11,0.07,0.03,0.025,0.00)

#create data frame store data
df<-data.frame(m.pct, d.mm)

#data for prediction
d.wei <- c(seq(0.01,0.1,0.01),seq(0.2,1,0.1),seq(2,30,1))

#solver (provided starting value for solution)
# alpha is used for shape and beta is used for scale
fit<-nls(m.pct~pweibull(d.mm, shape=alpha, scale=beta), data=df, start=list(alpha=1, beta=2))
print(summary(fit))

#extract out shape and scale
print(summary(fit)$parameters[,1])

#predict new values base on model
y<-predict(fit, newdata=data.frame(d.mm=d.wei))

#Plot comparison
plot(log10(d.mm),m.pct)
lines(log10(d.wei),y, col="blue")

enter image description here