TLMoments (version 0.7.5.3)

PWMs: Probability weighted moments

Description

Calculates probability weighted moments up to a specific order. Note that PWMs start with order 0. Acceptable input types are numeric vectors, matrices, lists, and data.frames.

Usage

PWMs(x, ...)

# S3 method for numeric PWMs(x, max.order = 4L, na.rm = FALSE, ...)

# S3 method for matrix PWMs(x, max.order = 4L, na.rm = FALSE, ...)

# S3 method for list PWMs(x, max.order = 4L, na.rm = FALSE, ...)

# S3 method for data.frame PWMs(x, formula, max.order = 4L, na.rm = FALSE, ...)

# S3 method for TLMoments PWMs(x, ...)

Arguments

x

numeric vector or matrix, list, or data.frame of data OR an object of TLMoments.

...

additional arguments.

max.order

integer, maximal order of PWMs.

na.rm

logical, indicates if NAs should be removed.

formula

if x is of type data.frame a formula has to be submitted.

Value

numeric vector, matrix, list, or data.frame consisting of the PWMs and with class PWMs. The object contains the following attributes:

  • order: a integer vector with corresponding PWM orders

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

The attributes are hidden in the print-function for a clearer presentation.

References

Greenwood, J. A., Landwehr, J. M., Matalas, N. C., & Wallis, J. R. (1979). Probability weighted moments: definition and relation to parameters of several distributions expressable in inverse form. Water Resources Research, 15(5), 1049-1054.

Examples

Run this code
# NOT RUN {
# Generating data sets:
xmat <- matrix(rnorm(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)
)

# Calculating PWMs from data:
PWMs(xvec)
PWMs(xmat)
PWMs(xlist)
PWMs(xdat, formula = hq ~ station)
PWMs(xdat, formula = hq ~ season)
PWMs(xdat, formula = hq ~ .)
PWMs(xdat, formula = . ~ station + season)

# Calculating PWMs from L-moments:
PWMs(TLMoments(xvec))
PWMs(TLMoments(xmat))
PWMs(TLMoments(xlist))
PWMs(TLMoments(xdat, hq ~ station))
PWMs(TLMoments(xdat, hq ~ season))
PWMs(TLMoments(xdat, hq ~ .))
PWMs(TLMoments(xdat, . ~ station + season))

# In data.frame-mode invalid names are preceded by "."
xdat <- data.frame(
 beta0 = rep(letters[1:2], each = 50),
 beta1 = as.vector(xmat)
)
PWMs(xdat, formula = beta1 ~ beta0)

# }

Run the code above in your browser using DataLab