我已经为我的数据拟合了许多分布,但我在将 Pearson III 型分布拟合到数据时遇到了困难。我还使用 plotdist 函数来查找起始值或初始值,以便使用迭代方法拟合分布。从 plotdist 获得的图表明,该图非常适合给定起始值的数据但是 fitdist 函数不起作用并给出错误代码 100。我还研究了有关拟合 log Pearson 类型的堆栈溢出的问题和答案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)
数据可在