我是 R 的新手,我很难弄清楚如何使用方法 = mme 将 Log Pearson Type III 拟合到数据中。
YearThai <- c(2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018)
FlowThai <- c(2009.6,2071.8,3534.5,1813.6,1674.17,1892,4020,2572.4,2303.2,2299.8,3242,3720,1939.9,2221.6,1127,706.8,2109.7,2571.4,880.8)
DataThai <- as.data.frame(cbind(YearThai,FlowThai))
LFlowThai <- log(FlowThai)
m <- mean(LFlowThai)
v <- var(LFlowThai)
s <- sd(LFlowThai)
g <- e1071::skewness(LFlowThai, type=1)
n <- length(LFlowThai)
g <- g*(sqrt(n*(n-1))/(n-2))*(1+8.5/n)
my.shape <- 4/(g)^2
my.scale <- abs(g)/(g*(s/sqrt(my.shape)))
my.location <- m-(my.shape*my.scale)
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)
fitdistrplus::fitdist(LFlowThai, distr = "PIII", method = "mme", order = c(1,2,3), start = my.param)
我得到的错误是这样的:
Error in mmedist(data, distname, start = arg_startfix$start.arg, fix.arg = arg_startfix$fix.arg, :
the empirical moment function must be defined
使用method = mle时没有问题,但我们的研究需要使用矩量法进行参数估计。
提前感谢那些可以提供帮助的人。