P3 {nsRFA}R Documentation

Three parameters Pearson type III distribution and L-moments

Description

P3 provides the link between L-moments of a sample and the three parameter Pearson type III distribution.

Usage

f.gamma (x, xi, beta, alfa)
F.gamma (x, xi, beta, alfa)
invF.gamma (F, xi, beta, alfa)
Lmom.gamma (xi, beta, alfa)
par.gamma (lambda1, lambda2, tau3)
rand.gamma (numerosita, xi, beta, alfa)
mom2par.gamma (mu, sigma, gamm)
par2mom.gamma (alfa, beta, xi)

Arguments

x vector of quantiles
mu vector of gamma mean
sigma vector of gamma standard deviation
gamm vector of gamma third moment
F vector of probabilities
lambda1 vector of sample means
lambda2 vector of L-variances
tau3 vector of L-CA (or L-skewness)
numerosita numeric value indicating the length of the vector to be generated
alfa vector of gamma shape parameters
beta vector of gamma scale parameters
xi vector of gamma location parameters

Details

See http://en.wikipedia.org/wiki/Pearson_distribution for an introduction to the Pearson distribution, and http://en.wikipedia.org/wiki/Gamma_distribution for an introduction to the Gamma distribution (the Pearson type III distribution is, essentially, a Gamma distribution with 3 parameters).

Definition

Parameters (3): μ (location), σ (scale), gamma (shape).

If gamma ne 0, let α=4/gamma^2, β=frac{1}{2}σ |gamma|, and xi= μ - 2 σ/gamma. If gamma > 0, then the range of x is xi <= x < infty and

f(x) = frac{(x - xi)^{α - 1} e^{-(x-xi)/β}}{β^{α} Γ(α)}

F(x) = G (α, frac{x-xi}{β})/ Γ(α)

If gamma=0, then the distribution is Normal, the range of x is -infty < x < infty and

f(x) = phi (frac{x-μ}{σ})

F(x) = Phi (frac{x-μ}{σ})

where phi(x)=(2π)^{-1/2}exp(-x^2/2) and Phi(x)=int_{-infty}^x phi(t)dt.

If gamma < 0, then the range of x is -infty < x <= xi and

f(x) = frac{(xi - x)^{α - 1} e^{-(xi-x)/β}}{β^{α} Γ(α)}

F(x) = G (α, frac{xi-x}{β})/ Γ(α)

In each case, x(F) has no explicit analytical form. Here Γ is the gamma function, defined as

Γ (x) = int_0^{infty} t^{x-1} e^{-t} dt

and

G(α, x) = int_0^x t^{α-1} e^{-t} dt

is the incomplete gamma function.

gamma=2 is the exponential distribution; gamma=0 is the Normal distribution; gamma=-2 is the reverse exponential distribution.

The parameters μ, σ and gamma are the conventional moments of the distribution.

L-moments

Assuming gamma>0, L-moments are defined for 0<α<infty.

λ_1 = xi + α β

λ_2 = π^{-1/2} β Γ(α + 1/2)/Γ(α)

tau_3 = 6 I_{1/3} (α, 2 α)-3

where I_x(p,q) is the incomplete beta function ratio

I_x(p,q) = frac{Γ(p+q)}{Γ(p)Γ(q)} int_0^x t^{p-1} (1-t)^{q-1} dt

There is no simple expression for tau_4. Here we use the rational-funcion approximation given by Hosking and Wallis (1997, pp. 201-202).

The corresponding results for gamma <0 are obtained by changing the signs of λ_1, tau_3 and xi wherever they occur above.

Parameters

alpha is obtained with an approximation. If 0<|tau_3|<1/3, let z=3 π tau_3^2 and use

α approx frac{1+0.2906 z}{z + 0.1882 z^2 + 0.0442 z^3}

if 1/3<|tau_3|<1, let z=1-|tau_3| and use

α approx frac{0.36067 z - 0.59567 z^2 + 0.25361 z^3}{1-2.78861 z + 2.56096 z^2 -0.77045 z^3}

Given α, then gamma=2 α^{-1/2} sign(tau_3), σ=λ_2 π^{1/2} α^{1/2} Γ(α)/Γ(α+1/2), μ=λ_1.

Lmom.gamma and par.gamma accept input as vectors of equal length. In f.gamma, F.gamma, invF.gamma and rand.gamma parameters (mu, sigma, gamm) must be atomic.

Value

f.gamma gives the density f, F.gamma gives the distribution function F, invFgamma gives the quantile function x, Lmom.gamma gives the L-moments (λ_1, λ_2, tau_3, tau_4), par.gamma gives the parameters (mu, sigma, gamm), and rand.gamma generates random deviates.
mom2par.gamma returns the parameters α, β and xi, given the parameters (moments) μ, σ, gamma.

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, KAPPA, LOGNORM; 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.gamma(ll[1],ll[2],ll[4])
f.gamma(1800,parameters$xi,parameters$beta,parameters$alfa)
F.gamma(1800,parameters$xi,parameters$beta,parameters$alfa)
invF.gamma(0.7511627,parameters$xi,parameters$beta,parameters$alfa)
Lmom.gamma(parameters$xi,parameters$beta,parameters$alfa)
rand.gamma(100,parameters$xi,parameters$beta,parameters$alfa)

Rll <- regionalLmoments(x,fac); Rll
parameters <- par.gamma(Rll[1],Rll[2],Rll[4])
Lmom.gamma(parameters$xi,parameters$beta,parameters$alfa)

moments <- par2mom.gamma(parameters$alfa,parameters$beta,parameters$xi); moments
mom2par.gamma(moments$mu,moments$sigma,moments$gamm)

[Package nsRFA version 0.6-7 Index]