Learn R Programming

NMOF (version 2.2-2)

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

Value

numeric

Details

For a vector \(\emph{x}\) of length \(\emph{n}\), partial moments are computed as follows:

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

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

The threshold is denoted \(\emph{t}\), the exponent xp is labelled \(\emph{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.

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

Run this code
# NOT RUN {
pm(x <- rnorm(100), 2)
var(x)/2

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

Run the code above in your browser using DataLab