# NOT RUN {
z <- revd(100, loc=20, scale=0.5, shape=-0.2)
fit <- fevd(z)
fit
pextRemes(fit, q=quantile(z, probs=c(0.85, 0.95, 0.99)), lower.tail=FALSE)
z2 <- rextRemes(fit, n=1000)
qqplot(z, z2)
# }
# NOT RUN {
data(PORTw)
fit <- fevd(TMX1, PORTw, units="deg C")
fit
pextRemes(fit, q=c(17, 20, 25, 30), lower.tail=FALSE)
# Note that fit has a bounded upper tail at:
# location - scale/shape ~
# 15.1406132 + (2.9724952/0.2171486) = 28.82937
#
# which is why P[X > 30] = 0. Note also that 25
# is less than the upper bound, but larger than
# the maximum observed value.
z <- rextRemes(fit, n=50)
qqplot(z, PORTw$TMX1, xlab="Simulated Data Quantiles",
ylab="Data Quantiles (PORTw TMX1)")
# Not a great fit because data follow a non-stationary
# distribution.
fit <- fevd(TMX1, PORTw, location.fun=~AOindex, units="deg C")
fit
pextRemes(fit, q=c(17, 20, 25, 30), lower.tail=FALSE)
# Gives a warning because we did not give covariate values.
v <- make.qcov(fit, vals=list(mu1=c(1, -1, 1, -1)))
v
# find probabilities for high positive AOindex vs
# low negative AOindex. A column for the unnecessary
# threshold is added, but is not used.
pextRemes(fit, q=c(17, 17, 30, 30), qcov=v, lower.tail=FALSE)
z <- rextRemes(fit, n=50)
dim(z)
qqplot(z[,1], PORTw$TMX1, xlab="Simulated Data Quantiles",
ylab="Data Quantiles (PORTw TMX1)")
qqplot(z[,28], PORTw$TMX1, xlab="Simulated Data Quantiles",
ylab="Data Quantiles (PORTw TMX1)")
# etc.
##
## GP model with non-constant threshold.
##
fit <- fevd(-MinT ~1, Tphap, threshold=c(-70,-7),
threshold.fun=~I((Year - 48)/42), type="GP",
time.units="62/year", verbose=TRUE)
fit
summary(fit$threshold)
v <- make.qcov(fit, vals=c(rep(1,8), c(-77, -73.5, -71.67, -70)), nr=4)
v
# upper bounded df at: u - scale/shape =
c(-77, -73.5, -71.67, -70) + 2.9500992/0.1636367
# -58.97165 -55.47165 -53.64165 -51.97165
summary(-Tphap$MinT)
pextRemes(fit, q=rep(-58, 4), qcov=v, lower.tail=FALSE)
# }
Run the code above in your browser using DataLab