繁体   English   中英

在 R 中使用“extRemes”拟合广义极值 (GEV) model 时估计参数协方差矩阵

[英]Estimating parameter covariance matrix when fitting a Generalized Extreme Value (GEV) model using 'extRemes' in R

我的问题类似于在 R 中使用 `extRemes` 拟合广义极值 (GEV) 时出错? . 但是,我正在拟合非平稳广义极值 (GEV) 分布,即,当位置参数取决于协变量并且不再是常数时。 我还在 R 中使用extRemes package。 上述帖子中提出的解决方案不适用于我的情况,因为该解决方案中使用的 function ( EnvStats::egevd ) 不适用于非固定 GEV。

由于原始数据很大,这里是我的数据的一个子集,它给了我一个警告,因此它不会产生一个给出参数协方差的矩阵。

library(extRemes)
y <-  c(4.844187, 4.844187, 4.174387, 4.744932, 4.094345, 4.174387, 4.343805, 4.624973,
  4.094345, 4.094345, 4.343805, 4.174387, 4.499810, 4.094345, 4.499810, 4.343805,
  4.653960, 4.499810, 4.941642, 4.624973, 4.499810, 4.744932, 4.317488, 4.499810,
  4.605170, 4.844187, 4.744932, 4.499810, 4.094345, 4.442651, 4.653960, 4.317488,
  4.744932, 4.174387, 4.605170, 4.700480, 4.744932, 4.553877, 4.248495, 4.094345,
  4.442651, 4.553877, 4.317488, 4.382027, 4.248495, 4.382027, 4.499810, 4.382027,
  4.382027, 4.382027, 4.248495, 4.248495, 4.248495, 4.382027, 4.248495, 4.744932,
  4.094345, 4.700480, 4.744932, 4.499810, 4.317488, 4.382027, 4.382027, 4.499810,
  4.248495, 4.499810, 4.382027, 4.700480, 4.653960, 4.744932, 4.605170, 4.094345,
  4.700480, 4.700480, 4.499810, 4.700480, 4.605170, 4.700480, 4.653960, 4.382027,
  4.499810, 4.174387, 4.174387, 4.174387, 4.499810, 4.382027, 4.553877, 4.499810,
  4.094345, 4.174387, 4.442651, 4.094345, 4.382027, 4.317488, 4.317488, 4.382027,
  4.442651, 4.442651, 4.174387, 4.094345)

x <-  c(4.535284, 4.556505, 3.305054, 4.293878, 3.228826, 3.375880, 3.562466, 4.047428,
   3.719651, 2.957511, 3.228826, 3.375880, 3.896909, 3.719651, 4.011868, 3.442019,
  4.208417, 3.812203, 4.617593, 4.011868, 3.766997, 4.397531, 3.504055, 4.114964,
  4.081766, 4.535284, 4.237723, 3.936716, 3.812203, 3.896909, 4.147095, 3.789855,
  4.293878, 3.305054, 4.147095, 4.147095, 4.293878, 3.896909, 3.644144, 3.562466,
  3.617652, 3.974998, 3.562466, 3.719651, 3.617652, 3.896909, 3.974998, 3.896909,
  4.147095, 3.766997, 3.695110, 3.695110, 3.695110, 3.896909, 3.504055, 4.480174,
  3.504055, 4.433789, 4.587515, 4.147095, 3.695110, 3.766997, 3.766997, 3.974998,
  3.695110, 4.081766, 3.896909, 4.421848, 4.347047, 4.587515, 4.421848, 3.504055,
  4.421848, 4.421848, 4.064744, 4.293878, 4.293878, 4.421848, 4.293878, 3.896909,
  4.193435, 3.766997, 3.504055, 3.644144, 4.064744, 3.974998, 4.147095, 4.064744,
  3.504055, 3.834061, 4.147095, 3.695110, 4.081766, 3.974998, 4.147095, 4.147095,
  4.266195, 4.223177, 3.812203, 3.504055)

fac <- as.factor(c(rep("a", 45), rep("b", 55)))

# Data 
dat <- data.frame(y = y, x= x, fac = fac)

# Non-stationary GEV model:
gev_mod <- fevd(dat$y, data = dat, location.fun = ~x*fac + I(x^2)*fac, 
    scale.fun=~1, shape.fun =~1, type = 'GEV')

这是带有警告的 output。 通常,当您显示摘要或 model output 时,您会得到一个参数协方差矩阵,但在这种情况下我们没有。 虽然我们得到了参数估计值,但我需要参数协方差矩阵来进行推理,但我无法找出问题所在。 使用的默认估计方法是 MLE,但我也尝试了其他方法,如广义 MLE (GMLE),但仍然遇到同样的问题。 我刚刚开始涉足该领域,非常感谢有关如何解决此问题的任何帮助。


Warning messages:
1: In log(z) : NaNs produced
2: In log(z) : NaNs produced
3: In log(z) : NaNs produced
4: In log(z) : NaNs produced
5: In log(z) : NaNs produced
6: In log(z) : NaNs produced
7: In log(z) : NaNs produced
8: In log(z) : NaNs produced
> gev_mod

fevd(x = dat$y, data = dat, location.fun = ~x * fac + I(x^2) * 
    fac, scale.fun = ~1, shape.fun = ~1, type = "GEV")

[1] "Estimation Method used: MLE"


 Negative Log-Likelihood Value:  -114.3946 


 Estimated parameters:
       mu0        mu1        mu2        mu3        mu4        mu5      scale 
 5.5752723 -1.0508929 -2.3604995  0.1951670  1.0569155 -0.1229494  0.1034723 
     shape 
-0.7972565 

 AIC = -212.7893 

 BIC = -191.9479 
> summary(gev_mod$cov.theta)
Length  Class   Mode 
     0   NULL   NULL 

我能够找到解决问题的方法。 我查看了fevd package 中extRemes function 的源代码,并注意到log(z)出现在grlevd ZC1C425268E68385D1AB5074C17A94 估计所需的梯度的可能性中。 我在 R 中使用trace() function 将log(z)更改为log1p(z) ,这似乎有效。 现在我没有收到任何警告,也得到了估计的参数协方差矩阵。 顺便说一句,在过去几天与 EVD 合作后,看起来优化中的收敛可能很棘手,尤其是对于非平稳模型。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM