# NOT RUN {
data("dataOyster")
Velocity <- dataOyster$data[, 3]
time <- dataOyster$data[, 1]
plot(time, Velocity, type = "l", xlab = "time (hour)",
ylab = "Velocity (mm/s)")
Tgrid <- seq(0, 24, 0.05)
#Grid with positive velocity
new.Tgrid <- dataOyster$Tgrid
X <- Velocity + (-min(Velocity)) #We shift the data to be positive
# }
# NOT RUN {
#For computing time purpose
#We find the h by minimizing the cross validation function
hgrid <- bandwidth.grid(0.05, 0.5, 50, type = "geometric")
#H <- bandwidth.CV(X, time, new.Tgrid, hgrid,
# TruncGauss.kernel, kpar = c(sigma = 1),
# pcv = 0.99, CritVal = 3.4, plot = TRUE)
#hcv <- H$h.cv
hcv <- 0.2981812
#we use our method with the h found previously
TS.Oyster <- hill.ts(X, t = time, new.Tgrid, h = hcv,
TruncGauss.kernel, kpar = c(sigma = 1),
CritVal = 3.4)
plot(time, Velocity, type = "l", ylim = c(-0.6, 1),
main = "Extreme quantiles estimator",
xlab = "Time (hour)", ylab = "Velocity (mm/s)")
pgrid <- c(0.999)
pred.quant.Oyster <- predict(TS.Oyster, newdata = pgrid, type = "quantile")
quant0.999 <- rep(0, length(Tgrid))
quant0.999[match(new.Tgrid, Tgrid)] <-
as.numeric(pred.quant.Oyster$y)-
(-min(Velocity))
lines(Tgrid, quant0.999, col = "magenta")
# }
Run the code above in your browser using DataLab