regionalize: Calculation of regionalized TL-moments

View source: R/regionalize.R

regionalizeR Documentation

Calculation of regionalized TL-moments

Description

regionalize takes the result of TLMoments and calculates a weighted mean of TL-moments and TL-moment ratios.

Usage

regionalize(x, ...)

## S3 method for class 'numeric'
regionalize(x, ...)

## S3 method for class 'matrix'
regionalize(x, w = attr(x, "source")$n, reg.lambdas = TRUE, ...)

## S3 method for class 'data.frame'
regionalize(x, w = attr(x, "source")$n, reg.lambdas = TRUE, ...)

## S3 method for class 'list'
regionalize(x, w = attr(x, "source")$n, reg.lambdas = TRUE, ...)

Arguments

x

object returned by TLMoments.

...

additional arguments, not used at the moment.

w

numeric vector giving the weights. Default: Sample lengths of corresponding data. Internally scaled so that it adds up to 1.

reg.lambdas

logical, if TRUE (default) regionalization is based upon TL-moments. If false it's based on TL-moment-ratios.

Value

list of two dimensions: lambdas/ratios are numeric vectors consisting of the regionalized TL-moments/TL-moment-ratios. The list has the class TLMoments. The object contains the following attributes:

  • leftrim: a numeric giving the used leftrim-argument

  • rightrim: a numeric giving the used rightrim-argument

  • order: a integer vector with corresponding TL-moment orders

  • source: a list with background information (used function, data, n, formula, computation.method; mainly for internal purposes)

Examples

xmat <- matrix(rgev(100), nc = 4)
xvec <- xmat[, 3]
xlist <- lapply(1L:ncol(xmat), function(i) xmat[, i])
xdat <- data.frame(
 station = rep(letters[1:2], each = 50),
 season = rep(c("S", "W"), 50),
 hq = as.vector(xmat)
)

regionalize(TLMoments(xmat))
regionalize(TLMoments(xlist))
regionalize(TLMoments(xdat, hq ~ station))
# For numeric vector TLMoments, nothing happens:
regionalize(TLMoments(xvec))

tlm <- TLMoments(xmat)
regionalize(tlm)
regionalize(tlm, reg.lambdas = FALSE)

parameters(regionalize(tlm), "gev")
parameters(regionalize(tlm, reg.lambdas = FALSE), "gev")

quantiles(parameters(regionalize(tlm), "gev"), c(.99, .999))
quantiles(parameters(regionalize(tlm, reg.lambdas = FALSE), "gev"), c(.99, .999))


# With magrittr
library(magrittr)
matrix(rgev(200, shape = .3), nc = 5) %>%
 TLMoments(rightrim = 1) %>%
 regionalize %>%
 parameters("gev") %>%
 quantiles(c(.99, .999))

TLMoments documentation built on March 27, 2022, 5:07 p.m.