data(annMax)
q_gpd(annMax)
q_gpd(annMax, truncate=0.6)
q_gpd(annMax, truncate=0.85)
q_gpd(annMax, truncate=0.91)
q_gpd(annMax, package="evir")
q_gpd(annMax, package="evir", method="ml")
q_gpd(annMax, package="evd")
q_gpd(annMax, package="extRemes")
q_gpd(annMax, package="extRemes", method="GMLE")
#q_gpd(annMax, package="extRemes", method="Bayesian") # computes a while
q_gpd(annMax, package="extRemes", method="Lmoments")
q_gpd(annMax, package="extRemes", method="nonsense") # NAs
q_gpd(annMax, package="fExtremes") # log warnings
q_gpd(annMax, package="fExtremes", efquiet=TRUE) # silenced warnings
q_gpd(annMax, package="fExtremes", method= "mle")
q_gpd(annMax, package="ismev")
q_gpd(annMax, package="Renext")
q_gpd(annMax, package="Renext", method="f")
dummy <- try(q_gpd(annMax, package="nonsense"), silent=TRUE) # error
stopifnot(class(dummy)=="try-error")
q_gpd(annMax, truncate=0.85, package="evd") # Note about quantiles
q_gpd(annMax, truncate=0.85, package="evir")
q_gpd(annMax, truncate=0.85, package="evir", quiet=TRUE) # No note
q_gpd(annMax, truncate=0.85, package="evir", undertruncNA=FALSE)
q_gpd(annMax, truncate=0.85, package="evir", returnlist=TRUE)
str( q_gpd(annMax, truncate=0.85, probs=0.6, package="evir", returnlist=TRUE) )# NAs
str( q_gpd(annMax, package="evir", returnlist=TRUE) )
str( q_gpd(annMax, package="evd", returnlist=TRUE) )
str( q_gpd(annMax, package="extRemes", returnlist=TRUE) )
str( q_gpd(annMax, package="fExtremes", returnlist=TRUE) )
str( q_gpd(annMax, package="ismev", returnlist=TRUE) )
str( q_gpd(annMax, package="Renext", returnlist=TRUE) )
q_gpd(annMax, package="evir", truncate=0.9, method="ml") # NAs (MLE fails often)
## Not run:
# ## Not run in checks because simulation takes too long
# # truncation effect
# mytruncs <- seq(0, 0.9, len=150)
# oo <- options(show.error.messages=FALSE, warn=-1)
# myquants <- sapply(mytruncs, function(t) q_gpd(annMax, truncate=t, quiet=TRUE))
# options(oo)
# plot(1, type="n", ylim=range(myquants, na.rm=TRUE), xlim=c(0,0.9), las=1,
# xlab="truncated proportion", ylab="estimated quantiles")
# abline(h=quantileMean(annMax, probs=c(0.8,0.9,0.99)))
# for(i in 1:3) lines(mytruncs, myquants[i,], col=i)
# text(0.3, c(87,97,116), rownames(myquants), col=1:3)
#
#
# # Underestimation in small samples
# # create known population:
# dat <- extRemes::revd(1e5, scale=50, shape=-0.02, threshold=30, type="GP")
# op <- par(mfrow=c(1,2), mar=c(2,2,1,1))
# hist(dat, breaks=50, col="tan")
# berryFunctions::logHist(dat, breaks=50, col="tan")
# par(op)
#
# # function to estimate empirical and GPD quantiles from subsamples
# samsizeeffect <- function(n, nrep=30, probs=0.999, trunc=0.5, Q=c(0.4,0.5,0.6))
# {
# res <- replicate(nrep, {
# subsample <- sample(dat, n)
# qGPD <- q_gpd(subsample, probs=probs, truncate=trunc)
# qEMP <- berryFunctions::quantileMean(subsample, probs=probs, truncate=trunc)
# c(qGPD=qGPD, qEMP=qEMP)})
# apply(res, MARGIN=1, berryFunctions::quantileMean, probs=Q)
# }
#
# # Run and plot simulations
# samplesize <- c(seq(20, 150, 10), seq(200,800, 100))
# results <- pbapply::pblapply(samplesize, samsizeeffect)
# res <- function(row, col) sapply(results, function(x) x[row,col])
# berryFunctions::ciBand(yu=res(3,1),yl=res(1,1),ym=res(2,1),x=samplesize,
# main="99.9% Quantile underestimation", xlab="subsample size", ylim=c(200,400), colm=4)
# berryFunctions::ciBand(yu=res(3,2),yl=res(1,2),ym=res(2,2),x=samplesize, add=TRUE)
# abline(h=berryFunctions::quantileMean(dat, probs=0.999))
# text(300, 360, "empirical quantile of full sample")
# text(300, 340, "GPD parametric estimate", col=4)
# text(300, 300, "empirical quantile estimate", col="green3")
#
# ## End(Not run) # end of dontrun
Run the code above in your browser using DataLab