我的问题类似于在 R 中使用 `extRemes` 拟合广义极值 (GEV) 的错误?. 但是,我正在拟合非平稳广义极值 (GEV) 分布,即,当位置参数取决于协变量并且不再是常数时。我也在extRemes
R 中使用包。上述帖子中提出的解决方案不适用于我的情况,因为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')
这是带有警告的输出。通常,当您显示摘要或模型输出时,您会得到一个参数协方差矩阵,但在这种情况下我们没有。虽然我们得到了参数估计,但我需要参数协方差矩阵来进行推理,但我无法找出问题所在。使用的默认估计方法是 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