# as.TLMoments: Convert to TLMoments-object In TLMoments: Calculate TL-Moments and Convert Them to Distribution Parameters

## Description

Convert vector, matrix, list, or data.frame of TL-moments or TL-moment ratios or a PWMs-object to a TLMoments-object in order to be used with TLMoments-functions. The first position of a vector or the first row of a matrix is always used as the L1-moment. The `ratios` argument determines if the following positions or rows are used as TL-moments oder TL-moments ratios. The trimming has to be given using the `leftrim` and `rightrim` arguments.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```as.TLMoments(x, ..., leftrim, rightrim, ratios) ## S3 method for class 'numeric' as.TLMoments(x, leftrim = 0L, rightrim = 0L, ratios = FALSE, ...) ## S3 method for class 'matrix' as.TLMoments(x, leftrim = 0L, rightrim = 0L, ratios = FALSE, ...) ## S3 method for class 'list' as.TLMoments(x, leftrim = 0L, rightrim = 0L, ratios = FALSE, ...) ## S3 method for class 'data.frame' as.TLMoments(x, formula, leftrim = 0L, rightrim = 0L, ratios = FALSE, ...) ```

## Arguments

 `x` vector or matrix of TL-moments (or TL-moment ratios if ratios is TRUE) or a PWMs-object. The first position or row is always used as the L1-moment, if vector or matrix are given. `...` additional arguments. `leftrim, rightrim` integer, order of trimmed L-moments. `ratios` boolean, if TRUE the non-first positions or rows of x give L-moment ratios, if FALSE (default) they give L-moments. If ratios are used and the first position or row is NA, L1 is assumed to be 1! `formula` if `x` is data.frame. See examples.

## Value

object of class TLMoments, see PWMs help page.

## Methods (by class)

• `numeric`: as.TLMoments for numeric data vectors

• `matrix`: as.TLMoments for numeric data matrices

• `list`: as.TLMoments for numeric data lists

• `data.frame`: as.TLMoments for numeric data.frames

`TLMoments`
 ``` 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``` ```### Vector or matrix as input xmat <- cbind(c(1, .2, .05), c(1, .2, NA), c(1.3, NA, .1)) xvec <- xmat[, 1] xlist <- lapply(1:ncol(xmat), function(i) xmat[, i]) xdat <- data.frame( station = rep(letters[1:3], each = 1), season = c("S", "W", "S"), L1 = c(1, 1, 1.3), L2 = c(.2, .2, .3), L3 = c(.05, .04, .1) ) as.TLMoments(xvec, rightrim = 1) as.TLMoments(xmat, rightrim = 1) as.TLMoments(xlist, rightrim = 1) as.TLMoments(xdat, cbind(L1, L2, L3) ~ station) as.TLMoments(xdat, .~station+season) as.TLMoments(xdat, cbind(L1, L2, L3) ~ .) parameters(as.TLMoments(xvec, rightrim = 0), "gev") #lmomco::lmom2par(lmomco::vec2lmom(c(1, .2, .25)), "gev")\$para xmat <- cbind(c(NA, .2, -.05), c(NA, .2, .2)) xvec <- xmat[, 1] as.TLMoments(xvec, ratios = TRUE) as.TLMoments(xmat, ratios = TRUE) parameters(as.TLMoments(xvec, ratios = TRUE), "gev") #lmomco::lmom2par(lmomco::vec2lmom(c(1, .2, -.05)), "gev")\$para xmat <- cbind(c(10, .2, -.05), c(10, .2, .2)) xvec <- xmat[, 1] as.TLMoments(xvec, ratios = TRUE) as.TLMoments(xmat, ratios = TRUE) parameters(as.TLMoments(xvec, ratios = TRUE), "gev") #lmomco::lmom2par(lmomco::vec2lmom(c(10, .2, -.05)), "gev")\$para ```