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

c9qzyr3d  于 2023-06-27  发布在  其他
关注(0)|答案(1)|浏览(220)

我尝试使用“fitdistplus”包中的“fitdistr”函数将GEV分布调整到数据集。我在解释另一个数据集的p值结果时也遇到了麻烦。来自“gofstat”函数的“chisqpvalue”返回空向量。
先谢谢你了。
我尝试了以下脚本:

  1. library(fitdistrplus)
  2. library(evd)
  3. 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)
  4. par <- list(loc = 0.0, scale = 1.0, shape = 0)
  5. fitX <- fitdist(abs(x), "gev",start=par)
  6. resultX <- gofstat(fitX)

它返回以下消息:函数mle无法估计参数,错误代码为100
当我从数据集中删除一些值时,它会运行我们的错误:

  1. 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)
  2. par <- list(loc = 0.0, scale = 1.0, shape = 0)
  3. fitX <- fitdist(abs(x), "gev",start=par)
  4. resultX <- gofstat(fitX)

我认为问题可能是我选择的起始参数。但是,有没有一个正确的方法来估计它?
我的另一个问题是关于p值的结果。在下面的示例(另一个数据集)中,代码正在运行,拟合GEV分布,但p值(chisqpvalue)结果为Null

  1. x <- c(10, 21, 7, 17, 18, 16, 17, 12, 22, 19, 12, 49, 11, 9)
  2. par <- list(loc = 0.0, scale = 1.0, shape = 0)
  3. fitX <- fitdist(abs(x), "gev",start=par)
  4. resultX <- gofstat(fitX)
frebpwbc

frebpwbc1#

使用bbmle::mle2,它更灵活一点,可以让我们在对数尺度上拟合尺度参数,这样我们就可以避免麻烦:

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

使用这些起始值足以让fitdist成功:

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

相关问题