Description Usage Arguments Details Value Arguments of cumulative distribution functions and quantile functions Warning Note Author(s) References See Also Examples
Computes the Lmoments or trimmed Lmoments
of a probability distribution
given its cumulative distribution function (for function lmrp
)
or quantile function (for function lmrq
).
1 2 3 4 5 
pfunc 
Cumulative distribution function. 
qfunc 
Quantile function. 
... 
Arguments to 
bounds 
Either a vector of length 2, containing the lower and upper bounds of the distribution, or a function that calculates these bounds given the distribution parameters as inputs. 
symm 
For For If the distribution is symmetric, oddorder Lmoments are exactly zero and the symmetry is used to slightly speed up the computation of evenorder Lmoments. 
order 
Orders of the Lmoments and Lmoment ratios to be computed. 
ratios 
Logical. If 
trim 
Degree of trimming. If a single value, symmetric trimming of the specified degree will be used. If a vector of length 2, the two values indicate the degrees of trimming at the lower and upper ends of the “conceptual sample” (Elamir and Seheult, 2003) of order statistics that is used to define the trimmed Lmoments. 
acc 
Requested accuracy. The function will try to achieve this level of accuracy, as relative error for Lmoments and absolute error for Lmoment ratios. 
subdiv 
Maximum number of subintervals used in numerical integration. 
verbose 
Logical. If 
Computations use expressions in Hosking (2007):
eq. (7) for lmrp
, eq. (5) for lmrq
.
Integrals in those expressions are computed by numerical integration.
If verbose=FALSE
and ratios=FALSE
,
a numeric vector containing the Lmoments.
If verbose=FALSE
and ratios=TRUE
,
a numeric vector containing the Lmoments (of orders 1 and 2)
and Lmoment ratios (of orders 3 and higher).
If verbose=TRUE
, a data frame with columns as follows:
value 
Lmoments (if 
abs.error 
Estimate of the absolute error in the computed value. 
message 

pfunc
and qfunc
can be either the standard R form of
cumulative distribution function or quantile function
(i.e. for a distribution with r parameters, the first argument is the
variate x or the probability p and the next r arguments
are the parameters of the distribution) or the cdf...
or
qua...
forms used throughout the lmom package
(i.e. the first argument is the variate x or probability p
and the second argument is a vector containing the parameter values).
Even for the R form, however, starting values for the parameters
are supplied as a vector start
.
If bounds
is a function, its arguments must match
the distribution parameter arguments of pfunc
:
either a single vector, or a separate argument for each parameter.
Arguments bounds
, symm
, order
,
ratios
, trim
, acc
, subdiv
, and verbose
cannot be abbreviated and must be specified by their full names
(if abbreviated, the names would be matched to the arguments of
pfunc
or qfunc
).
In package lmom versions 1.6 and earlier, the “Details” section stated that
“Integrals in those expressions are computed by numerical integration,
using the R function integrate
”.
As of version 2.0, numerical integration uses an internal function that directly calls
(slightly modified versions of) Fortran routines in QUADPACK (Piessens et al. 1983).
R's own integrate
function uses C code “based on” the QUADPACK routines,
but in R versions 2.12.0 through 3.0.1 did not in every case reproduce the results
that would have been obtained with the Fortran code (this is R bug PR#15219).
J. R. M. Hosking [email protected]
Elamir, E. A. H., and Seheult, A. H. (2003). Trimmed Lmoments. Computational Statistics and Data Analysis, 43, 299314.
Hosking, J. R. M. (2007). Some theory and practical uses of trimmed Lmoments. Journal of Statistical Planning and Inference, 137, 30243039.
Piessens, R., deDonckerKapenga, E., Uberhuber, C., and Kahaner, D. (1983). Quadpack: a Subroutine Package for Automatic Integration. Springer Verlag.
lmrexp
to compute (untrimmed) Lmoments of specific distributions.
samlmu
to compute (trimmed or untrimmed) Lmoments of a data sample.
pelp
and pelexp
,
to compute the parameters of a distribution given its (trimmed or untrimmed) Lmoments.
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57  ## Generalized extremevalue (GEV) distribution
##  three ways to get its Lmoments
lmrp(cdfgev, c(2,3,0.2))
lmrq(quagev, c(2,3,0.2))
lmrgev(c(2,3,0.2), nmom=4)
## GEV bounds specified as a vector
lmrp(cdfgev, c(2,3,0.2), bounds=c(13,Inf))
## GEV bounds specified as a function  single vector of parameters
gevbounds < function(para) {
k < para[3]
b < para[1]+para[2]/k
c(ifelse(k<0, b, Inf), ifelse(k>0, b, Inf))
}
lmrp(cdfgev, c(2,3,0.2), bounds=gevbounds)
## GEV bounds specified as a function  separate parameters
pgev < function(x, xi, alpha, k)
pmin(1, pmax(0, exp(((1k*(xxi)/alpha)^(1/k)))))
pgevbounds < function(xi,alpha,k) {
b < xi+alpha/k
c(ifelse(k<0, b, Inf), ifelse(k>0, b, Inf))
}
lmrp(pgev, xi=2, alpha=3, k=0.2, bounds=pgevbounds)
## Normal distribution
lmrp(pnorm)
lmrp(pnorm, symm=0)
lmrp(pnorm, mean=2, sd=3, symm=2)
# For comparison, the exact values
lmrnor(c(2,3), nmom=4)
# Many Lmoment ratios of the exponential distribution
# This may warn that "the integral is probably divergent"
lmrq(qexp, order=3:20)
# ... nonetheless the computed values seem accurate:
# compare with the exact values, tau_r = 2/(r*(r1)):
cbind(exact=2/(3:20)/(2:19), lmrq(qexp, order=3:20, verbose=TRUE))
# Of course, sometimes the integral really is divergent
## Not run:
lmrq(function(p) (1p)^(1.5))
## End(Not run)
# And sometimes the integral is divergent but that's not what
# the warning says (at least on the author's system)
lmrp(pcauchy)
# Trimmed Lmoments for Cauchy distribution are finite
lmrp(pcauchy, symm=0, trim=1)
# Works for discrete distributions too, but often requires
# a largerthandefault value of 'subdiv'
lmrp(ppois, lambda=5, subdiv=1000)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.