pm {NMOF}R Documentation

Partial Moments

Description

Compute partial moments.

Usage

  pm(x, xp = 2, threshold = 0, lower = TRUE,
     normalise = FALSE, na.rm = FALSE)

Arguments

x

a numeric vector or a matrix

xp

exponent

threshold

a numeric vector of length one

lower

logical

normalise

logical

na.rm

logical

Details

For a vector xx of length nn, partial moments are computed as follows:

upper partial moment=1nx>t(xt)e\mathrm{upper\ partial\ moment} = \frac{1}{n} \sum_{x > t}\left(x - t \right)^e

lower partial moment=1nx<t(tx)e\mathrm{lower\ partial\ moment} = \frac{1}{n} \sum_{x < t}\left(t - x \right)^e

The threshold is denoted tt, the exponent xp is labelled ee.

If normalise is TRUE, the result is raised to 1/xp. If x is a matrix, the function will compute the partial moments column-wise.

See Gilli, Maringer and Schumann (2019), chapter 14.

Value

numeric

Author(s)

Enrico Schumann

References

Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance. 2nd edition. Elsevier. doi:10.1016/C2017-0-01621-X

Schumann, E. (2023) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual

Examples

pm(x <- rnorm(100), 2)
var(x)/2

pm(x, 2, normalise = TRUE)
sqrt(var(x)/2)

[Package NMOF version 2.8-0 Index]