KAPPA                 package:nsRFA                 R Documentation

_F_o_u_r _p_a_r_a_m_e_t_e_r _k_a_p_p_a _d_i_s_t_r_i_b_u_t_i_o_n _a_n_d _L-_m_o_m_e_n_t_s

_D_e_s_c_r_i_p_t_i_o_n:

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

_U_s_a_g_e:

     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)

_A_r_g_u_m_e_n_t_s:

       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

_D_e_t_a_i_l_s:

     *Definition*

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

     Range of x: upper bound is xi + alpha/k if k>0, inf if k <= 0;
     lower bound is xi + alpha(1-h^(-k))/k if h>0, xi + alpha/k if h <=
     0 and k<0 and -inf if h <= 0 and k >= 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 + alpha/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.


                    lambda1 = xi + alpha(1 - g1)/k


                      lambda2 = alpha(g1 - g2)/k


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


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

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

     Here Gamma denote the gamma function

         Gamma(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.

_V_a_l_u_e:

     '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.

_N_o_t_e:

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

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_s:

     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)

