Title: | A Collection of Full Defined Distribution Tails |
Version: | 0.1.2 |
Description: | A full definition for Weibull tails and Full-Tails Gamma and tools for fitting these distributions to empirical tails. This package build upon the paper by del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012) <doi:10.1017/asb.2017.9>. |
Depends: | R (≥ 3.6.0) |
URL: | https://github.com/SergiVilardell/distTails |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 6.1.1 |
Imports: | ercv, gsl, MASS |
NeedsCompilation: | no |
Packaged: | 2019-09-06 15:01:39 UTC; svilarde |
Author: | Sergi Vilardell [aut, cre], Àlvar Pineda [aut] |
Maintainer: | Sergi Vilardell <sergivilardell13@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2019-09-07 08:50:02 UTC |
FTG Density Function
Description
This function computes the density of the full-tail gamma with the input sample data. The expression for the density used is:
g(x; \alpha, \theta, \rho) = \frac{\rho^{\alpha}}{\sigma}\left(\rho + \frac{x}{\sigma}\right)^{\alpha - 1}\exp\left(-\left(\rho + \frac{x}{\sigma}\right)\right)/\Gamma(\alpha, \rho).
Usage
dFTG(x, threshold, scale, shape)
Arguments
x |
Sample data. |
threshold |
Minimum value of the tail. |
scale |
Scale parameter. |
shape |
Shape parameter. |
Value
Gives the density of the FTG. The length of the result is determined by the length of x.
References
del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012). The full-tails gamma distribution applied to model extreme values. ASTIN Bulletin. <doi:10.1017/asb.2017.9>.
Examples
a <- 0.3
t <- 0.3
r <- 0.8
n <- 1000
sample <- rFTG(n, a, t, r)
x <- seq(min(sample), max(sample), length.out = 200)
d <- dFTG(x, a, t, r)
hist(sample, breaks = "FD", probability = TRUE)
lines(x, d, col = "red")
TailW Density function
Description
This function computes the density of the tailW with the input sample data. The expression for the density used is:
f(x, \alpha, \beta, \nu) = \alpha \beta (x + \nu)^{\beta -1} \exp(-\alpha(x + \nu)^{\beta} + \alpha \nu^{\beta})
Usage
dtailw(x, threshold, scale, shape)
Arguments
x |
Sample data. |
threshold |
Minimum value of the tail. |
scale |
Scale parameter. |
shape |
Shape parameter. |
Value
Gives the density of the TailW. The length of the result is determined by the length of x.
Examples
# Generate random deviates from a weibull tail and plot the theoretical density.
scale <- 2
shape <- 1
threshold <- 1
x_seq <- seq(threshold, 5, length.out = 500)
theo_density <- dtailw(x_seq, threshold = threshold, scale = scale, shape = shape)
sample <- rtailw(500, threshold = threshold, scale = scale, shape = shape)
hist(sample, probability = TRUE)
lines(x = x_seq, y = theo_density, col = "red")
TailW Maximum Likelihood Estimation
Description
Maximum Likelihood Estimation of the tails by fitting a tailW or a FTG.
Usage
fittail(sample, dist = "TailW")
Arguments
sample |
Sample data. |
dist |
Name of the distribution to fit. |
Value
Gives a list of the estimated parameters fo the function fitted. For the TailW it returns, scale and shape. Fot the FTG it returns the parameters scale, shape, and threshold.
Examples
scale <- 2
shape <- 1
threshold <- 1
s <- rtailw(1000, threshold = threshold , scale = scale, shape = shape)
fits <- fittail(s, dist = "TailW")
x_seq <- seq(threshold, max(s), length.out = 500)
theo_density <- dtailw(x_seq, threshold = threshold, scale = fits$scale, shape = fits$shape)
hist(s, probability = TRUE, breaks = "FD")
lines(x = x_seq, y = theo_density, col = "red")
FTG Log-likelihood Function
Description
This function computes the loglikelihood of the full-tail gamma with the input sample data. The expression used is:
l(x; \alpha, \sigma, \rho) = -n\left(\log\Gamma(\alpha, \rho) + \log(\sigma) -\alpha \log(\rho) - \frac{\alpha - 1}{n}\sum_{i = 1}^{n}\log\left(1 + \frac{x_{i}}{\sigma}\right) + \frac{\rho}{n} \sum_{i = 1}^{n}\left(1 + \frac{x_{i}}{\sigma}\right)\right)
Usage
lFTG(x, threshold, scale, shape)
Arguments
x |
Sample data. |
threshold |
Minimum value of the tail. |
scale |
Scale parameter. |
shape |
Shape parameter. |
Value
Gives the log-likelihood of the FTG. The length of the result is determined by the length of x.
References
del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012). The full-tails gamma distribution applied to model extreme values. ASTIN Bulletin. <doi:10.1017/asb.2017.9>.
Examples
lFTG(1,1,1,1)
TailW Log-likelihood function
Description
This function computes the log-likelihood of the tailW with the input sample data.
l(x;\alpha,\beta) = n(\log(\alpha)+\log(\beta))+(\beta-1)\sum_{i=1}^{n}\log(x+\nu)-\alpha\sum_{i=1}^{n}((x+\nu)^\beta-\nu^\beta)
Usage
ltailw(x, threshold, scale, shape)
Arguments
x |
Sample data. |
threshold |
Minimum value of the tail. |
scale |
Scale parameter. |
shape |
Shape parameter. |
Value
Gives the log-likelihood of the TailW. The length of the result is determined by the length of x.
Examples
ltailw(1,1,1,1)
FTG Probability Function
Description
This function computes the probability of the full-tail gamma with the input sample data. The expression for the probability used is:
G(x; \alpha, \theta, \rho) = 1 - \Gamma\left(\alpha, \rho\left(1 + \frac{x}{\sigma}\right)\right)/\Gamma(\alpha, \rho).
Usage
pFTG(x, threshold, scale, shape)
Arguments
x |
Sample data. |
threshold |
Minimum value of the tail. |
scale |
Scale parameter. |
shape |
Shape parameter. |
Value
Gives the distribution function of the FTG. The length of the result is determined by the length of x.
References
del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012). The full-tails gamma distribution applied to model extreme values. ASTIN Bulletin. <doi:10.1017/asb.2017.9>.
Examples
pFTG(1,1,1,1)
TailW Probability Function
Description
This function computes the cumulative density function of the tailW with the input sample data.
F(x,\alpha,\beta,\nu)=1-\exp(-\alpha(x+\nu)^\beta+\alpha\nu^\beta).
Usage
ptailw(x, threshold, scale, shape)
Arguments
x |
Sample data. |
threshold |
Minimum value of the tail. |
scale |
Scale parameter. |
shape |
Shape parameter. |
Value
Gives the distribution function of the TailW. The length of the result is determined by the length of x.
Examples
# Using the probability function to show the fitting.
samp <- rtailw(1000, 1, 2, 3)
emp_cdf <- ecdf(samp)(samp)
pars <- fittail(samp, dist = "TailW")
x_seq <- seq(min(samp), max(samp), length.out = 250)
p <- ptailw(x_seq, threshold = 1, scale = pars$scale, shape = pars$shape)
plot(samp, 1-emp_cdf, log = "y")
lines(x_seq, 1-p, col = "red")
FTG Quantile function
Description
This function computes the quantiles of the full-tail gamma with the input sample data.
Usage
qFTG(p, threshold, scale, shape, interval)
Arguments
p |
Probability. |
threshold |
Minimum value of the tail. |
scale |
Scale parameter. |
shape |
Shape parameter. |
interval |
a vector containing the end-points of the interval to be searched for the minimum. |
Value
Gives the quantiles of the FTG. The length of the result is determined by the length of x.
References
del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012). The full-tails gamma distribution applied to model extreme values. ASTIN Bulletin. <doi:10.1017/asb.2017.9>.
Examples
qFTG(0.5,1,1,1, c(0,10))
Quantile function
Description
This function computes the quantile function of the tailW.
Q(p,\alpha, \beta, \nu) = \left(\frac{-\log(1 - p)}{\alpha} + \nu^\beta\right)^{1 / \beta}
Usage
qtailw(p, threshold, scale, shape)
Arguments
p |
Probability. |
threshold |
Minimum value of the tail. |
scale |
Scale parameter. |
shape |
Shape parameter. |
Value
Gives the quantiles of the TailW. The length of the result is determined by the length of x.
Examples
qtailw(0.5, 1, 1, 1)
FTG Random Sample Generation
Description
This function computes n random variates from full-tail gamma with a rejection method.
Usage
rFTG(n, threshold, scale, shape)
Arguments
n |
Sample size. |
threshold |
Minimum value of the tail. |
scale |
Scale parameter. |
shape |
Shape parameter. |
Value
Gives random deviates of the FTG. The length of the result is determined by n.
References
del Castillo, Joan & Daoudi, Jalila & Serra, Isabel. (2012). The full-tails gamma distribution applied to model extreme values. ASTIN Bulletin. <doi:10.1017/asb.2017.9>.
Examples
x <- rFTG(100, 1, 1, 1)
hist(x, breaks = "FD")
TailW Random Sample Generation
Description
This function generates random deviates for the tailW distribution.
Usage
rtailw(n, threshold, scale, shape)
Arguments
n |
Sample size. |
threshold |
Minimum value of the tail. |
scale |
Scale parameter. |
shape |
Shape parameter. |
Value
Gives random deviates of the TailW. The length of the result is determined by n.
Examples
x <- rtailw(1000, 1, 2, 3)
hist(x, breaks = "FD")