【问题标题】:Fitting of Pearson Type III in R using fitdist使用 fitdist 在 R 中拟合 Pearson Type III
【发布时间】:2021-01-19 10:45:55
【问题描述】:

我已经为我的数据拟合了许多分布,但我在将 Pearson III 型分布拟合到数据时遇到了困难。我还使用 plotdist 函数来查找起始值或初始值,以便使用迭代方法拟合分布。The plots obtained from plotdist shows that the plot is a good fit to data at the given starting values 但是 fitdist 函数不起作用并给出错误代码 100。我还研究了有关拟合的堆栈溢出问题和答案的日志 Pearson Type III 分布并应用了代码,但是我在运行 fitdist 函数并再次获得错误代码 100 时再次遇到问题。数据可从以下链接下载。

Lheadway <- pvr$headway+0.0000001

m <- mean(Lheadway)
v <- var(Lheadway)
s <- sd(Lheadway)
g <- e1071::skewness(Lheadway, type=1)

n <- length(Lheadway)
g <- g*(sqrt(n*(n-1))/(n-2))*(1+8.5/n)


my.shape <- (2/g)^2
#my.scale <- sqrt(v)/sqrt(my.shape)*sign(g) # modified as recommended by Carl Schwarz
my.scale <- sqrt(v)/sqrt(my.shape)*sign(g)
my.location <- m-sqrt(v * my.shape)

my.param <- list(shape=my.shape, scale=my.scale, location=my.location)


dPIII<-function(x, shape, location, scale) PearsonDS::dpearsonIII(x, shape, location, scale, log=FALSE)
pPIII<-function(q, shape, location, scale) PearsonDS::ppearsonIII(q, shape, location, scale, lower.tail = TRUE, log.p = FALSE)
qPIII<-function(p, shape, location, scale) PearsonDS::qpearsonIII(p, shape, location, scale, lower.tail = TRUE, log.p = FALSE)

fitPIII <- fitdistrplus::fitdist(Lheadway, distr="PIII", method="mle", start=my.param)

plot(fitPIII)

https://ptagovsa-my.sharepoint.com/:x:/g/personal/kkhan_tga_gov_sa/EfzCE5h0jexCkVw0Ak2S2_MBWf3WUywMd1izw41r0EsLeQ?e=EiqWDc

数据可在

【问题讨论】:

    标签: r fitdistrplus


    【解决方案1】:

    该函数只需将方法从 mle 更改为 mse 或 mge 并从代码中删除 param 参数即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-13
      • 2017-10-05
      • 2021-09-23
      • 1970-01-01
      • 2016-12-18
      • 2016-08-21
      • 2021-01-21
      • 2021-11-25
      相关资源
      最近更新 更多