Title: | Bimodal GEV Distribution with Location Parameter |
---|---|
Description: | Density, distribution function, quantile function random generation and estimation of bimodal GEV distribution given in Otiniano et al. (2023) <doi:10.1007/s10651-023-00566-7>. This new generalization of the well-known GEV (Generalized Extreme Value) distribution is useful for modeling heterogeneous bimodal data from different areas. |
Authors: | Cira Otiniano Author [aut], Yasmin Lirio Author [aut], Thiago Sousa Developer [cre] |
Maintainer: | Thiago Sousa Developer <[email protected]> |
License: | GPL-3 |
Version: | 0.1 |
Built: | 2024-11-11 03:59:02 UTC |
Source: | https://github.com/cran/bgev |
Density, distribution function, quantile function random generation and estimation of bimodal GEV distribution given in Otiniano et al. (2023) <doi:10.1007/s10651-023-00566-7>. This new generalization of the well-known GEV (Generalized Extreme Value) distribution is useful for modeling heterogeneous bimodal data from different areas.
dbgev(y, mu = 1, sigma = 1, xi = 0.3, delta = 2) pbgev(y, mu = 1, sigma = 1, xi = 0.3, delta = 2) qbgev(p, mu = 1, sigma = 1, xi = 0.3, delta = 2) rbgev(n, mu = 1, sigma = 1, xi = 0.3, delta = 2)
dbgev(y, mu = 1, sigma = 1, xi = 0.3, delta = 2) pbgev(y, mu = 1, sigma = 1, xi = 0.3, delta = 2) qbgev(p, mu = 1, sigma = 1, xi = 0.3, delta = 2) rbgev(n, mu = 1, sigma = 1, xi = 0.3, delta = 2)
y |
a unidimensional vector containing the points to compute the density (dbgev) or
the probability (pbgev) froma bimodal GEV distribution with parameters
|
p |
a unidimensional vector containing the probabilities used to compute the quantiles |
n |
an integer describing the number of observations to generate random bimodal GEV observations |
mu |
location parameter |
sigma |
shape parameter |
xi |
shape parameter |
delta |
bimodality parameter |
Density, distribution function, quantile function and random generation of bimodal GEV distribution with location parameter. In addition, maximum likelihood estimation based on real data is also provided.
dbgev
gives the density, pbgev
gives the distribution function,
qbgev
gives the quantile function, and rbgev
generates random
bimodal GEV observations.
The probability density of a GEV random variable; is given by:
where and
are the shape parameters and
is the location parameter.
The bimodal Generalized Extreme Value (GEV) model, denoted as BGEV, consists of composing the distribution of a random variable following the GEV distribution with a location parameter , i.e.,
, with the transformation
defined below. Thus, the cumulative distribution function (CDF) of a random variable BGEV, denoted as
, is given by:
where the function is defined as:
Moreover, the function is invertible, with the inverse given by:
Additionally, it is differentiable, and its derivative has the following form:
Its probability density function is given by
Cira Otiniano Author [aut], Yasmin Lirio Author [aut], Thiago Sousa Developer [cre]
Maintainer: Thiago Sousa Developer <[email protected]>
Otiniano, Cira EG, et al. (2023). A bimodal model for extremes data. Environmental and Ecological Statistics, 1-28. http://dx.doi.org/10.1007/s10651-023-00566-7
# generate 100 values distributed according to a bimodal GEV x = rbgev(50, mu = 0.2, sigma = 1, xi = 0.5, delta = 0.2) # estimate the bimodal GEV parameters using the generated data bgev.mle(x)
# generate 100 values distributed according to a bimodal GEV x = rbgev(50, mu = 0.2, sigma = 1, xi = 0.5, delta = 0.2) # estimate the bimodal GEV parameters using the generated data bgev.mle(x)
Finds the maximum likelihood estimators of the bimodal GEV distribution parameters by minimizing the log-likelihood function of the data.
bgev.mle(x, lower = c(-3, 0.1, -3, -0.9), upper = c(3, 3, 3,3), itermax = 50)
bgev.mle(x, lower = c(-3, 0.1, -3, -0.9), upper = c(3, 3, 3,3), itermax = 50)
x |
a unidimensional vector containing observations to estimate a bimodal GEV distribution |
lower |
a vector of dimension 4 containing the lower limit for each of the bimodal GEV parameters where the search is going to take place. |
upper |
a vector of dimension 4 containing the upper limit for each of the bimodal GEV parameters where the search is going to take place. |
itermax |
maximum number of interations when finding a good starting value for the optimization algorithm. |
A list with components returned by the optim R function for which the main values are
par |
best parameters of bimodal gev fitting the data |
value |
value of the log-likelihood corresponding to 'par' |
Cira Otiniano Author [aut], Yasmin Lirio Author [aut], Thiago Sousa Developer [cre]
OTINIANO, Cira EG, et al. (2023). A bimodal model for extremes data. Environmental and Ecological Statistics, 1-28. http://dx.doi.org/10.1007/s10651-023-00566-7
# generate 100 values distributed according to a bimodal GEV x = rbgev(50, mu = 0.2, sigma = 1, xi = 0.5, delta = 0.2) # estimate the bimodal GEV parameters using the generated data bgev.mle(x)
# generate 100 values distributed according to a bimodal GEV x = rbgev(50, mu = 0.2, sigma = 1, xi = 0.5, delta = 0.2) # estimate the bimodal GEV parameters using the generated data bgev.mle(x)
When the shape parameter xi
is different from zero, the support
is truncated either at the left or at the right side of the real.
Considering the support is particularly useful to estimating momoments and
to compute the likelihood function.
bgev.support(mu, sigma, xi, delta)
bgev.support(mu, sigma, xi, delta)
mu |
location parameter |
sigma |
shape parameter |
xi |
shape parameter |
delta |
bimodality parameter |
It returns a vector representing the interval for which the density function is not null.
The Support of the bimodal GEV distribution is given by the following equation:
Cira Otiniano Author [aut], Yasmin Lirio Author [aut], Thiago Sousa Developer [cre]
Otiniano, Cira EG, et al. (2023). A bimodal model for extremes data. Environmental and Ecological Statistics, 1-28. http://dx.doi.org/10.1007/s10651-023-00566-7
# Computes the support of a specific bimodal GEV distribution support = bgev.support(mu=1, sigma=10, xi=0.3, delta=2)
# Computes the support of a specific bimodal GEV distribution support = bgev.support(mu=1, sigma=10, xi=0.3, delta=2)
This is just a refactorization of
the original R function distCheck
to allow customization for heavy tailed distributions
and distribution with constrained support. Assumes one has implemented density,
probability, quantile and random generation for a new distribution.
Originally implemented to be used with the bimodal GEV distribution
distCheck(fun = "norm", n = 1000, robust = FALSE, subdivisions = 1500, support.lower = -Inf, support.upper = Inf, var.exists = TRUE, print.result = TRUE, ...)
distCheck(fun = "norm", n = 1000, robust = FALSE, subdivisions = 1500, support.lower = -Inf, support.upper = Inf, var.exists = TRUE, print.result = TRUE, ...)
fun |
Name of distribution. E.g, "bgev" for bimodal GEV, "gev" for GEV, "norm" for normal. |
n |
size of the sample when generating random values through "rfun" |
robust |
Boolean. Used for computing mean and variance in a robust way when evaluating mean and variance. |
subdivisions |
used for numerical integration when using "dfun" |
support.lower |
lower limit of the support of the distribution |
support.upper |
upper limit of the support of the distribution |
var.exists |
Boolean indicating if variance exists (useful for gev, bimodal gev, stable etc) |
print.result |
Boolean indicating weather to print results of the tests on screen. |
... |
parameters passed to the distribution, e.g., mu and sd for normal, mu, sigma, xi and delta for bimodal GEV. |
All tests results are organized into a list to make it easier to find where results went wrong and to make it scalable for testing distributions for several parameters.
A list of lists with test results
list( functionTested = fun,
functionParam = list(...),
test1.density = list(computed = NULL, expected = NULL, error.check = NULL),
test2.quantile.cdf = list(computed = NULL, expected = NULL, error.check = NULL),
test3.mean.var = list(computed = list(mean = NULL, var = NULL, log = NULL),
expected = list(mean = NULL, var = NULL, log = NULL),
error.check = NULL,
condition.is.var.finite = TRUE))
functionParam |
Additional parameters passed to the distribution with the ... argument |
test1.density |
results for the density function test. A list with the 'computed' value using the density function and numerical integration, the 'expected' value (which is 1) and the result of the 'error.check' comparing both values. |
test2.quantile.cdf |
results for the quantile function test. A list with the 'computed' value using the quantile function at chosen probabilites on [0,1], the 'expected' value (which is 1) and the result of the 'error.check' comparing both values. |
test3.mean.var |
results for the random generation and the density function. A list with the 'computed' values using the random quantities (computes mean(X), variance(X) and E(log(abs(X))) where X follows the distribution being tested. The 'expected' is a list containing the same quantities computed using numerical integration |
error.check |
check if expected variance and computed variance are close enough. |
condition.is.var.finite |
For some distributions there are known conditions for the variance to be finite. This quantity is expected to be evaluated outside the DistCheck function and passed through the argument 'var.exists'. |
Cira Otiniano Author [aut], Yasmin Lirio Author [aut], Thiago Sousa Developer [cre]
Otiniano, Cira EG, et al. (2023). A bimodal model for extremes data. Environmental and Ecological Statistics, 1-28. http://dx.doi.org/10.1007/s10651-023-00566-7
# generate random values for the parameters and test the # bimodal gev distribution implementation set.seed(1) mu = runif(1,-2,2) sigma = runif(1,0.1,2) xi = runif(1,0.3,0.9) * sign(runif(1,-1,1)) delta = 1#runif(1,-0.6,2) support = bgev.support(mu, sigma, xi, delta) var.exists = ( xi != 0) & (xi < (delta + 1)/2) ret = distCheck(fun="bgev", n = 2000, support.lower = support[1], support.upper = support[2], subdivisions = 5000, mu = mu, sigma = sigma, xi = xi, delta = delta, var.exists = var.exists, print.result = TRUE)
# generate random values for the parameters and test the # bimodal gev distribution implementation set.seed(1) mu = runif(1,-2,2) sigma = runif(1,0.1,2) xi = runif(1,0.3,0.9) * sign(runif(1,-1,1)) delta = 1#runif(1,-0.6,2) support = bgev.support(mu, sigma, xi, delta) var.exists = ( xi != 0) & (xi < (delta + 1)/2) ret = distCheck(fun="bgev", n = 2000, support.lower = support[1], support.upper = support[2], subdivisions = 5000, mu = mu, sigma = sigma, xi = xi, delta = delta, var.exists = var.exists, print.result = TRUE)
Uses the density function to evaluate the likelihood. This is useful for the 'bgev.mle' function.
likbgev(y, theta = c(1, 1, 0.3, 2))
likbgev(y, theta = c(1, 1, 0.3, 2))
y |
a unidimensional vector containing the points to compute the log likelihood |
theta |
bimodal GEV parameters as an ordered pair |
a unidimensional vector containing the computed log likelihood for y
.
Cira Otiniano Author [aut], Yasmin Lirio Author [aut], Thiago Sousa Developer [cre]
Otiniano, Cira EG, et al. (2023). A bimodal model for extremes data. Environmental and Ecological Statistics, 1-28. http://dx.doi.org/10.1007/s10651-023-00566-7
# get random points from bimodal GEV y = rbgev(100, mu = 1, sigma = 1, xi = 0.3, delta = 2) # compute log-likelihood likbgev (y, theta = c(1, 1, 0.3, 2))
# get random points from bimodal GEV y = rbgev(100, mu = 1, sigma = 1, xi = 0.3, delta = 2) # compute log-likelihood likbgev (y, theta = c(1, 1, 0.3, 2))