Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pm

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 x of length n, partial moments are computed as follows:

upper partial moment = sum_{x > t}(x - t)^e / n

lower partial moment = sum_{x < t}(t - x)^e / n

The threshold is denoted t, the exponent xp is labelled e.

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 (2011), Section 13.3.

Value

numeric

Author(s)

Enrico Schumann

References

Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance. 2nd edition. Elsevier. https://www.elsevier.com/books/numerical-methods-and-optimization-in-finance/gilli/978-0-12-815065-8

Schumann, E. (2019) 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)

NMOF

Numerical Methods and Optimization in Finance

v2.4-1
GPL-3
Authors
Enrico Schumann [aut, cre] (<https://orcid.org/0000-0001-7601-6576>)
Initial release
2021-04-09

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.