拟合GEV分布:数据集和结果

huangapple go评论87阅读模式
英文:

Fitting a GEV Distribution: dataset and results

问题

我尝试调整一个GEV分布以适应数据集,使用"fitdistrplus"包中的"fitdistr"函数。
对于另一个数据集,我在解释p值结果方面也遇到了问题。"gofstat"函数中的"chisqpvalue"返回一个空向量。

非常感谢您的提前帮助。

我尝试了以下脚本:

library(fitdistrplus)
library(evd)

x <- c(11, 6, 3, 3, 4, 4, 5, 9, 4, 16, 8, 9, 7, 8, 16, 11, 5, 8, 9, 4, 17, 6, 7, 7, 6, 6) 
par <- list(loc = 0.0, scale = 1.0, shape = 0)

fitX <- fitdist(abs(x), "gev", start=par)
resultX <- gofstat(fitX)

它返回以下消息:函数mle无法估计参数,错误代码100

当我从数据集中删除一些值时,它可以运行而没有错误:

x <- c(11, 6, 3, 3, 5, 9, 4, 16, 8, 9, 7, 8, 16, 11, 5, 8, 9, 4, 17, 6, 7, 7, 6, 6) 
par <- list(loc = 0.0, scale = 1.0, shape = 0)

fitX <- fitdist(abs(x), "gev", start=par)
resultX <- gofstat(fitX)

我认为问题可能是我选择的起始参数。但是,有一种正确的方法来估计它吗?

我还有另一个问题是关于p值结果。在下面的示例中(另一个数据集),代码正在运行,拟合GEV分布,但p值(chisqpvalue)结果为空:

x <- c(10, 21, 7, 17, 18, 16, 17, 12, 22, 19, 12, 49, 11, 9) 
par <- list(loc = 0.0, scale = 1.0, shape = 0)

fitX <- fitdist(abs(x), "gev", start=par)
resultX <- gofstat(fitX)
英文:

I'm trying to adjust a GEV Distribution to a dataset, using the "fitdistr" function from "fitdistrplus" package.
I'm also having trouble in the interpretation of the p-value result for another dataset. The "chisqpvalue" from "gofstat" function is returning a null vector.

Thank you very much in advance.

I tried the following script:

library(fitdistrplus)
library(evd)

x &lt;- c(11, 6, 3, 3, 4, 4, 5, 9, 4, 16, 8, 9, 7, 8, 16, 11, 5, 8, 9, 4, 17, 6, 7, 7, 6, 6) 
par &lt;- list(loc = 0.0, scale = 1.0, shape = 0)

fitX &lt;- fitdist(abs(x), &quot;gev&quot;,start=par)
resultX &lt;- gofstat(fitX)

It's returning the following message: the function mle failed to estimate the parameters, with the error code 100

When i remove some values from the dataset, it runs withour error:

x &lt;- c(11, 6, 3, 3, 5, 9, 4, 16, 8, 9, 7, 8, 16, 11, 5, 8, 9, 4, 17, 6, 7, 7, 6, 6) 
par &lt;- list(loc = 0.0, scale = 1.0, shape = 0)

fitX &lt;- fitdist(abs(x), &quot;gev&quot;,start=par)
resultX &lt;- gofstat(fitX)

I think the problem could be the starting parameters that i've choose. But, there is a correct way to estimate it?

Another problem of mine is about the p-value resuits. In the example below (another dataset), the code is running, fitting the GEV distribution, but the p-value(chisqpvalue) result is Null

x &lt;- c(10, 21,  7, 17, 18, 16, 17, 12, 22, 19, 12, 49, 11,  9) 
par &lt;- list(loc = 0.0, scale = 1.0, shape = 0)

fitX &lt;- fitdist(abs(x), &quot;gev&quot;,start=par)
resultX &lt;- gofstat(fitX)

答案1

得分: 1

Using bbmle::mle2, which is a little more flexible and lets us fit the scale parameter on the log scale so we can stay out of trouble:

使用 `bbmle::mle2`,这个函数更加灵活,可以让我们在对数尺度上拟合尺度参数,以便避免问题:

```r
library(bbmle)
m1 <- mle2(x ~ dgev(loc, exp(logscale), shape), data = data.frame(x), 
    start = list(loc = 0, logscale = 0, shape = 0), method = "Nelder-Mead")

Using these starting values is good enough to let fitdist succeed:

使用这些初始值就足够让 fitdist 成功:

fitX <- fitdist(x, "gev", 
    start= with(as.list(coef(m1)), list(loc = loc, scale = exp(logscale), shape = shape)))
英文:

Using bbmle::mle2, which is a little more flexible and lets us fit the scale parameter on the log scale so we can stay out of trouble:

library(bbmle)
m1 &lt;- mle2(x ~ dgev(loc, exp(logscale), shape), data = data.frame(x), 
    start = list(loc = 0, logscale = 0, shape = 0), method = &quot;Nelder-Mead&quot;)

Using these starting values is good enough to let fitdist succeed:

fitX &lt;- fitdist(x, &quot;gev&quot;, 
    start= with(as.list(coef(m1)), list(loc = loc, scale = exp(logscale), shape = shape)))

huangapple
  • 本文由 发表于 2023年6月22日 10:45:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76528301.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定