kmoments: Moments Associated To Kiener Distribution Parameters

Description Usage Arguments Details Value See Also Examples

View source: R/l_moments.R

Description

Non-central moments, central moments, mean, standard deviation, variance, skewness, kurtosis, excess of kurtosis and cumulants associated to the parameters of Kiener distributions K1, K2, K3 and K4. All-in-one vectors kmoments (estimated from the parameters) and xmoments (estimated from the vector of quantiles) are provided.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
kmoments(coefk, model = "K2", lengthx = NA, dgts = NULL, dimnames = FALSE)

xmoments(x, dgts = NULL, dimnames = FALSE)

kmoment(n, coefk, model = "K2", dgts = NULL)

kcmoment(n, coefk, model = "K2", dgts = NULL)

kmean(coefk, model = "K2", dgts = NULL)

kstandev(coefk, model = "K2", dgts = NULL)

kvariance(coefk, model = "K2", dgts = NULL)

kskewness(coefk, model = "K2", dgts = NULL)

kkurtosis(coefk, model = "K2", dgts = NULL)

kekurtosis(coefk, model = "K2", dgts = NULL)

Arguments

coefk

vector. Parameters of the distribution of length 3 ("K1"), length 4 (model = K2, K3, K4) and length 7 ("K7").

model

character. Model type, either "K2", "K3" or "K4" if coefk is of length 4. Type "K1" and "K7" may be provided but are ignored.

lengthx

integer. The length of the vector x used to calculate the parameters. See the details for matrix and lists.

dgts

integer. The rounding applied to the output.

dimnames

boolean. Display dimnames.

x

numeric. Vector of quantiles.

n

integer. The moment order.

Details

The non-central moments m1,m2,m3,m4,..,mn, the central moments u1,u2,u3,u4,..,un (where u stands for mu in Greek) and the cumulants k1,k2,k3,k4,..,kn (where k stands for kappa in Greek; not to be confounded with tail parameter "k" and models "K1", "K2", "K3", "K4") of order n exist only if min(a, k, w) > n. The mean m1 exists only if min(a, k, w) > 1. The standard deviation sd and the variance u2 exist only if min(a, k, w) > 2. The skewness sk exists only if min(a, k, w) > 3. The kurtosis ku and the excess of kurtosis ke exist only if min(a, k, w) > 4.

coefk may take five different forms :

Forms of length 3 and 7 are automatically recognized and do not require model = "K1" or "K7" which are ignored. Forms of length 4 require model = "K2", "K3" or "K4". Visit pk2pk for details on the parameter conversion function used within kmoments.

xmoments and kmoments provide all-in-one vectors.

xmoments is the traditional mean of squares, cubic and power 4 functions of non-central and central values of x, from which NA values have been removed. Therefore, length of x ignores NA values and may be different from the true length.

kmoments calls every specialized functions from order 1 to order 4 and uses the estimated parameters as inputs, not the initial dataset x. As it does not know a priori the length of x, this latest can be provided separately via lengthx = length(x), lengthx = nrow(x) and lengthx = sapply(x, length) if x is a vector, a matrix or a list. See the examples.

Value

Vectors kmoments and xmoments have the following structure (with a third letter x added to xmoments):

ku

Kurtosis.

ke

Excess of kurtosis.

sk

Skewness.

sd

Standard deviation. Square root of the variance u2

m1

Mean.

m2

Non-central moment of second order.

m3

Non-central moment of third order.

m4

Non-central moment of fourth order.

u1

Central moment of first order. Should be 0.

u2

Central moment of second order. Variance

u3

Central moment of third order.

u4

Central moment of fourth order.

k1

Cumulant of first order. Should be 0.

k2

Cumulant of second order.

k3

Cumulant of third order.

k4

Cumulant of fourth order.

lh

Length of x, from which NA values were removed.

......

.

See Also

pk2pk, paramkienerX, regkienerLX.

Examples

 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
## Example 1
kcmoment(2, c(-1, 1, 6, 9), model = "K2")
kcmoment(2, c(-1, 1, 7.2, -0.2/7.2), model = "K3")
kcmoment(2, c(-1, 1, 7.2, -0.2), model = "K4")
kcmoment(2, c(-1, 1, 6, 7.2, 9, -0.2/7.2, -0.2))
kvariance(c(-1, 1, 6, 9))
kmoments(c(-1, 1, 6, 9), dgts = 3)

## Example 2: "K2" and "K7" are preferred input formats for kmoments
## Moments fall at expected parameter values (=> NA).
## apply and direct calculation (= transpose)
(mat4 <- matrix(c(rep(0,4), rep(1,4), c(1.9,2.1,3.9,4.1), rep(5,4)),
                nrow = 4, byrow = TRUE, 
                dimnames = list(c("m","g","a","w"), paste0("b",1:4))))
round(mat7 <- apply(mat4, 2, pk2pk), 2)
round(rbind(mat7, apply(mat7, 2, kmoments)[2:5,]), 2) 
round(cbind(t(mat7), kmoments(t(mat7), dgts = 2)[,2:5]), 2) 

## Example 3: Matrix, timeSeries, xts, zoo + apply 
matret    <- 100*diff(log((EuStockMarkets)))
(matcoefk <- apply(matret, 2, paramkienerX5, dgts = 2))
(matmomk  <- apply(matcoefk, 2, kmoments, lengthx = nrow(matret), dgts = 2))
(matmomx  <- apply(matret, 2, xmoments, dgts = 2))
rbind(matcoefk, matmomk[2:5,], matmomx[2:5,])

## Example 4: List + direct calculation = transpose
DS   <- getDSdata() ; dimdim(DS) ; class(DS)
(pDS <- paramkienerX5(DS, dimnames = FALSE))
(kDS <- kmoments(pDS, lengthx = sapply(DS, length), dgts = 3))
(xDS <- xmoments( DS, dgts = 3))
cbind(pDS, kDS[,2:5], xDS[,2:5])

FatTailsR documentation built on March 12, 2021, 9:06 a.m.