nsRFA (version 0.7-14)

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

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 (\(\lambda_1\), \(\lambda_2\), \(\tau_3\), \(\tau_4\)), par.gamma gives the parameters (mu, sigma, gamm), and rand.gamma generates random deviates.

mom2par.gamma returns the parameters \(\alpha\), \(\beta\) and \(\xi\), given the parameters (moments) \(\mu\), \(\sigma\), \(\gamma\).

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): \(\xi\) (location), \(\beta\) (scale), \(\alpha\) (shape). Moments (3): \(\mu\) (mean), \(\sigma\) (standard deviation), \(\gamma\) (skewness).

If \(\gamma \ne 0\), let \(\alpha=4/\gamma^2\), \(\beta=\frac{1}{2}\sigma |\gamma|\), and \(\xi= \mu - 2 \sigma/\gamma\). If \(\gamma > 0\), then the range of \(x\) is \(\xi \le x < \infty\) and $$f(x) = \frac{(x - \xi)^{\alpha - 1} e^{-(x-\xi)/\beta}}{\beta^{\alpha} \Gamma(\alpha)}$$ $$F(x) = G \left(\alpha, \frac{x-\xi}{\beta}\right)/ \Gamma(\alpha)$$

If \(\gamma=0\), then the distribution is Normal, the range of \(x\) is \(-\infty < x < \infty\) and $$f(x) = \phi \left(\frac{x-\mu}{\sigma}\right)$$ $$F(x) = \Phi \left(\frac{x-\mu}{\sigma}\right)$$ where \(\phi(x)=(2\pi)^{-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 \le \xi\) and $$f(x) = \frac{(\xi - x)^{\alpha - 1} e^{-(\xi-x)/\beta}}{\beta^{\alpha} \Gamma(\alpha)}$$ $$F(x) = G \left(\alpha, \frac{\xi-x}{\beta}\right)/ \Gamma(\alpha)$$

In each case, \(x(F)\) has no explicit analytical form. Here \(\Gamma\) is the gamma function, defined as $$\Gamma (x) = \int_0^{\infty} t^{x-1} e^{-t} dt$$ and $$G(\alpha, x) = \int_0^x t^{\alpha-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 \(\mu\), \(\sigma\) and \(\gamma\) are the conventional moments of the distribution.

L-moments

Assuming \(\gamma>0\), L-moments are defined for \(0<\alpha<\infty\).

$$\lambda_1 = \xi + \alpha \beta$$ $$\lambda_2 = \pi^{-1/2} \beta \Gamma(\alpha + 1/2)/\Gamma(\alpha)$$ $$\tau_3 = 6 I_{1/3} (\alpha, 2 \alpha)-3$$ where \(I_x(p,q)\) is the incomplete beta function ratio $$I_x(p,q) = \frac{\Gamma(p+q)}{\Gamma(p)\Gamma(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 \(\lambda_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 \pi \tau_3^2\) and use $$\alpha \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 $$\alpha \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 \(\alpha\), then \(\gamma=2 \alpha^{-1/2} sign(\tau_3)\), \(\sigma=\lambda_2 \pi^{1/2} \alpha^{1/2} \Gamma(\alpha)/\Gamma(\alpha+1/2)\), \(\mu=\lambda_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.

See Also

rnorm, runif, EXP, GENLOGIS, GENPAR, GEV, GUMBEL, KAPPA, LOGNORM; 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.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)
# }

Run the code above in your browser using DataCamp Workspace