if (FALSE) {
set.seed(123456)
n <- 500
ns <- 1000
xi <- runif(ns, min = -0.5, max = 0.5)
X <- matrix(nrow = n, ncol = ns)
for (i in 1:length(xi)) {
Xi <- rgpd(n, scale = 1, shape = xi[i])
X[ , i] <- Xi
res1 <- fGPD(Xi)
res2 <- try(fpot(Xi, threshold = 0.0))
if (inherits(res2, "try-error")) {
cat(res2, "\n")
break
}
logLik1 <- res1$loglik; logLik2 <- logLik(res2)
if (abs(logLik1 - logLik2) > 0.001) {
cat(sprintf("i = %d, xi = %7.4f\n", i, xi[i]))
mat <- rbind(c(res1$estimate[1:2], logLik = logLik1),
c(res2$estimate[1:2], logLik = logLik2))
rownames(mat) <- c("fGPD", "fpot")
print(mat)
}
}
}
Run the code above in your browser using DataLab