nsRFA (version 0.7-15)

KAPPA: 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

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 (\(\lambda_1\), \(\lambda_2\), \(\tau_3\), \(\tau_4\)), par.kappa gives the parameters (xi, alfa, k, h), and rand.kappa generates random deviates.

Details

Definition

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

Range of \(x\): upper bound is \(\xi + \alpha/k\) if \(k>0\), \(\infty\) if \(k \le 0\); lower bound is \(\xi + \alpha(1-h^{-k})/k\) if \(h>0\), \(\xi + \alpha/k\) if \(h \le 0\) and \(k<0\) and \(-\infty\) if \(h \le 0\) and \(k \ge 0\)

Probability density function: $$f(x)=\alpha^{-1} [1-k(x-\xi)/\alpha]^{1/k-1} [F(x)]^{1-h}$$

Cumulative distribution function: $$F(x)=\{1-h[1-k(x-\xi)/\alpha]^{1/k}\}^{1/h}$$

Quantile function: $$x(F)= \xi + \frac{\alpha}{k} \left[ 1-\left( \frac{1-F^h}{h} \right)^k \right]$$

\(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 \ge 0\) and \(k>-1\), or if \(h<0\) and \(-1<k<-1/h\).

$$\lambda_1 = \xi + \alpha(1-g_1)/k$$ $$\lambda_2 = \alpha(g_1 - g_2)/k$$ $$\tau_3 = (-g_1 + 3g_2 - 2g_3)/(g_1 - g_2)$$ $$\tau_4 = (-g_1 + 6g_2 - 10g_3 + 5g_4)/(g_1 - g_2)$$ where \(g_r = \frac{r\Gamma(1+k)\Gamma(r/h)}{h^{1+k}\Gamma(1+k+r/h)}\) if \(h>0\); \(g_r = \frac{r \Gamma(1+k)\Gamma(-k-r/h)}{(-h)^{1+k}\Gamma(1-r/h)}\) if \(h<0\);

Here \(\Gamma\) denote the gamma function $$\Gamma (x) = \int_0^{\infty} 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 \(\tau_3\) and \(\tau_4\) in terms of \(k\) and \(h\). Here we use the function optim to minimize \((t_3-\tau_3)^2 + (t_4-\tau_4)^2\) where \(t_3\) and \(t_4\) 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.

See Also

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

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab