将 Weibull 累积分布拟合到 R 中的质量传递数据
Fit a Weibull cumulative distribution to mass passing data in R
我有一些碎石的粒径质量传递累积数据 material,我想用 R 拟合威布尔分布。我在 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))
我使用 Solver 在 Excel 中确定的 Weibull alpha 和 beta 的最佳值分别是 1.41 和 3.31
所以我的问题是如何在 R 中重现此分析(不一定是求解器部分)但将 Weibull 拟合到此数据集?
非线性最小二乘函数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")
我有一些碎石的粒径质量传递累积数据 material,我想用 R 拟合威布尔分布。我在 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))
我使用 Solver 在 Excel 中确定的 Weibull alpha 和 beta 的最佳值分别是 1.41 和 3.31 所以我的问题是如何在 R 中重现此分析(不一定是求解器部分)但将 Weibull 拟合到此数据集?
非线性最小二乘函数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")