2

私が持っているいくつかのデータ ポイントに対数ピアソン III フィットを実行したいと思います。ただし、それを試みるたびに、何をすべきか本当にわからないエラーメッセージが表示されます。数日前からRしか使っていないので、私はRの専門家ではありません。

重要なコード部分、インポートのない部分などは次のとおりです。

pIIIpars<-list(shape=1, location=1, scale=1) 

dPIII<-function(x, shape, location, scale) PearsonDS::dpearsonIII(x, shape=1, location=1, scale=1, params=pIIIpars, log=FALSE)

pPIII<-function(q, shape, location, scale) PearsonDS::ppearsonIII(q, shape=1, location=1, scale=1, params=pIIIpars, lower.tail = TRUE, log.p = FALSE)

qPIII<-function(p, shape, location, scale) PearsonDS::qpearsonIII(p, shape=1, location=1, scale=1, params=pIIIpars, lower.tail = TRUE, log.p = FALSE)

fitPIII<-fitdistrplus::fitdist(flowdata3$OEP, distr="PIII", method="mle", start=list("shape"=5000, "location"=5000, "scale"=5000))

summary(fitPIII)

plot(fitPIII)

Log Pearson III 分布の定義には PearsonDS パッケージを使用し、当てはめには fitdistrplus を使用しています。

私がいつも受け取るエラーメッセージはこれです:

[1] "Error in optim(par = vstart, fn = fnobj, fix.arg = fix.arg, obs = data,  : \n  function cannot be evaluated at initial parameters\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in optim(par = vstart, fn = fnobj, fix.arg = fix.arg, obs = data,     ddistnam = ddistname, hessian = TRUE, method = meth, lower = lower,     upper = upper, ...): function cannot be evaluated at initial parameters>
Error in fitdistrplus::fitdist(flowdata3$OEP, distr = "PIII", method = "mle",  : 
  the function mle failed to estimate the parameters, 
                with the error code 100

エラーメッセージは理解できます。それが初期値を渡す正しい方法でない場合、それは何ですか? 誰にもアイデアがありますか?

乾杯、ロバート

4

2 に答える 2

6

次のサンプルはKite(2004)に続き、彼の結果と一致しています。

# Annual maximum discharge data for the St Mary River at Stillwater Nova Scotia (Kite, 2004)
# PIII fit to the logs of the discharges

StMary <- c(565,294,303,569,232,405,228,232,394,238,524,368,464,411,368,487,394,
            337,385,351,518,365,515,280,289,255,334,456,479,334,394,348,428,337,
            311,453,328,564,527,510,371,824,292,345,442,360,371,544,552,651,190,
            202,405,583,725,232,974,456,289,348,564,479,303,603,514,377,318,342,
            593,378,255,292)

LStMary <- log(StMary)

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

# Correct the sample skew for bias using the recommendation of 
# Bobee, B. and R. Robitaille (1977). "The use of the Pearson Type 3 and Log Pearson Type 3 distributions revisited." 
# Water Resources Reseach 13(2): 427-443, as used by Kite

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

# We will use method of moment estimates as starting values for the MLE search

my.shape <- (2/g)^2
my.scale <- sqrt(v)/sqrt(my.shape)*sign(g) # modified as recommended by Carl Schwarz
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)

fitdistrplus::fitdist(LStMary, distr="PIII", method="mle", start=my.param)

また、MLE推定が常に適用できるとは限らないことにも注意してください。Kite(2004、p119)を参照してください。彼は、サンプルのスキューが小さければ解決策は不可能であると述べているMatalas and Wallis(1973)を引用しています。モーメント法では、gがゼロになると形状パラメーターが爆発するため、推定量がわかります。

Kite、GW(2004)水文学における頻度とリスクの分析。水資源の出版物

ノースカロライナ州マタラスとJRウォリス(1973)。「ユーレカ!ピアソンタイプ3ディストリビューションに適合します。」水資源研究9(2):281-289

于 2013-03-22T11:56:27.137 に答える