Learn R Programming

homtest (version 1.0-5)

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 ($\lambda1$, $\lambda2$, $\tau3$, $\tau4$), 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$, $inf$ 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="" $-inf$="" if="" $h="" \le="" 0$="" $k="" \ge="" 0$<="" p="">

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

$$\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 $gr = (r \Gamma(1+k)\Gamma(r/h))/(h^(1+k) \Gamma(1+k+r/h))$ if $h>0$; $gr = (r\Gamma(1+k)\Gamma(-k-r/h))/((-h)^(1+k)\Gamma(1-r/h))$ if $h<0$;< p="">

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 $\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.

References

Hosking, J.R.M. and Wallis, J.R. (1997) Regional Frequency Analysis: an approach based on L-moments, Cambridge University Press, Cambridge, UK.

See Also

HOMTESTS, rnorm, runif.

Examples

Run this code
data(annualflows)
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