KAPPA {nsRFA} | R Documentation

## Four parameter kappa distribution and L-moments

### Description

`KAPPA` provides the link between L-moments of a sample and the four parameter kappa distribution.

### Usage

    f.kappa (x, xi, alfa, k, h)
    F.kappa (x, xi, alfa, k, h)
    invF.kappa (F, xi, alfa, k, h)
    Lmom.kappa (xi, alfa, k, h)
    par.kappa (lambda1, lambda2, tau3, tau4)
    rand.kappa (numerosita, xi, alfa, k, h)

### Arguments

`x` | vector of quantiles
`xi` | vector of kappa location parameters
`alfa` | vector of kappa scale parameters
`k` | vector of kappa third parameters
`h` | vector of kappa fourth parameters
`F` | vector of probabilities
`lambda1` | vector of sample means
`lambda2` | vector of L-variances
`tau3` | vector of L-CA (or L-skewness)
`tau4` | vector of L-kurtosis
`numerosita` | numeric value indicating the length of the vector to be generated

### Details

Definition

Parameters (4): xi (location), α (scale), k, h.

Range of x: upper bound is xi + α/k if k>0, inf if k <= 0; lower bound is xi + α(1-h^(-k))/k if h>0, xi + α/k if h <= 0 and k<0 and -inf if h <= 0 and k >= 0

Probability density function:

f(x) = α^(-1) [1 - k (x - xi)/α]^(1/k-1) [F(x)]^(1-h)

Cumulative distribution function:

F(x) = {1 - h[1 - k(x - xi)/α]^(1/k)}^(1/h)

Quantile function:

x(F) = xi + α/k [1 - ((1-F^h)/h)^k]

h=-1 is the generalized logistic distribution; h=0 is the generalized eztreme value distribution; h=1 is the generalized Pareto distribution.

L-moments

L-moments are defined for h >= 0 and k>-1, or if h<0 and -1<k<-1/h.

λ1 = xi + α(1 - g1)/k

λ2 = α(g1 - g2)/k

tau3 = (-g1 + 3g2 - 2g3)/(g1 - g2)

tau4 = (-g1 + 6g2 - 10g3 + 5g4)/(g1 - g2)

where gr = (r Γ(1+k)Γ(r/h))/(h^(1+k) Γ(1+k+r/h)) if h>0; gr = (rΓ(1+k)Γ(-k-r/h))/((-h)^(1+k)Γ(1-r/h)) if h<0;

Here Γ denote the gamma function

Γ(x) = integral[from 0 to inf] t^(x-1) e^(-t) dt

Parameters

There are no simple expressions for the parameters in terms of the L-moments. However they can be obtained with a numerical algorithm considering the formulations of tau3 and tau4 in terms of k and h. Here we use the function `optim` to minimize (t3-tau3)^2 + (t4-tau4)^2 where t3 and t4 are the sample L-moment ratios.

`Lmom.kappa` and `par.kappa` accept input as vectors of equal length. In `f.kappa`, `F.kappa`, `invF.kappa` and `rand.kappa` parameters (`xi`, `alfa`, `k`, `h`) must be atomic.

### Value

`f.kappa` gives the density f, `F.kappa` gives the distribution function F, `invFkappa` gives the quantile function x, `Lmom.kappa` gives the L-moments (λ_1, λ_2, tau_3, tau_4), `par.kappa` gives the parameters (`xi`, `alfa`, `k`, `h`), and `rand.kappa` generates random deviates.

### Note

For information on the package and the Author, and for all the references, see `nsRFA`.

### See Also

`rnorm`, `runif`, `EXP`, `GENLOGIS`, `GENPAR`, `GEV`, `GUMBEL`, `LOGNORM`, `P3`; `optim`, `DISTPLOTS`, `GOFmontecarlo`, `Lmoments`.

### Examples

    data(hydroSIMN)
    annualflows
    summary(annualflows)
    x <- annualflows["dato"][,]
    fac <- factor(annualflows["cod"][,])
    split(x,fac)

    camp <- split(x,fac)$"45"
    ll <- Lmoments(camp)
    parameters <- par.kappa(ll[1],ll[2],ll[4],ll[5])
    f.kappa(1800,parameters$xi,parameters$alfa,parameters$k,parameters$h)
    F.kappa(1800,parameters$xi,parameters$alfa,parameters$k,parameters$h)
    invF.kappa(0.771088,parameters$xi,parameters$alfa,parameters$k,parameters$h)
    Lmom.kappa(parameters$xi,parameters$alfa,parameters$k,parameters$h)
    rand.kappa(100,parameters$xi,parameters$alfa,parameters$k,parameters$h)

    Rll <- regionalLmoments(x,fac); Rll
    parameters <- par.kappa(Rll[1],Rll[2],Rll[4],Rll[5])
    Lmom.kappa(parameters$xi,parameters$alfa,parameters$k,parameters$h)

[Package nsRFA version 0.6-9 Index]