declusterExtremes: Decluster maxima in a time series

Description Usage Arguments Details Value Author(s) Examples

View source: R/declusterExtremes.R

Description

Recursively declusters the maxima in a time series based on a minimal temporal distance. This can be useful to define independent events for an extreme value analysis.

Usage

1
declusterExtremes(x, L = 11)

Arguments

x

numeric vector. A (strictly regular) series; NAs are allowed and will be treated as -∞.

L

integer. Minimum distance in number of time units.

Details

Plateaus are strictly handled as non-maxima. The first and last time step are ignored as it is not known whether they represent local maxima. To decluster minima, use -1*x.

Value

Integer vector containing the indices of the maxima within x with respect to L.

Author(s)

Simon S

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## use case for an extreme value analysis on a daily basis
r <- as.Date(c('2006-01-01','2010-12-31'))
d <- seq.Date(r[1],r[2],by='day')
x <- rnorm(length(d))

i <- declusterExtremes(x)
g <- format(d[i],'%Y')
plot(x=d,y=x,type='l')
points(x=d[i],y=x[i],col=3)

## yearly blockmaxima
f <- function(x){
    i <- rep(FALSE,length(x))
    i[which.max(x)] <- TRUE
    return(i)
}
j <- unlist(tapply(x[i],g,f),use.names=FALSE)
i.block <- i[j]

plot(x=d,y=x,type='l')
points(x=d[i],y=x[i],col=3)
points(x=d[i.block],y=x[i.block],col=2,cex=1.5)
abline(v=seq.Date(min(d),max(d)+1,by='year'),lty=3)

## points over threshold
thr <- quantile(x,probs=0.95)
i.pot <- i[x[i]>thr]

plot(x=d,y=x,type='l')
points(x=d[i],y=x[i],col=3)
points(x=d[i.pot],y=x[i.pot],col=2,cex=1.5)
abline(h=thr,lty=3)

## Not run: 
library(ismev)
m1 <- gev.fit(x[i.block])
m2 <- gpd.fit(x[i],threshold=thr,npy=mean(table(g)))
## End(Not run)

hydro-giub/hydroBE documentation built on Sept. 20, 2019, 9:27 a.m.