We propose a new model with three parameters called bimodal Gumbel (BG) as a generalization of the Gumbel distribution. The advantage of our model in comparison to other generalizations of the Gumbel distribution is the number of parameters and the fact that it can be used to model extreme data with one or two modes.
You can install the released version of bgumbel from CRAN with:
install.packages("bgumbel")
or using devtools
library(devtools)
install_github('pcbrom/bgumbel')
library(bgumbel)
dbgumbel(x = 0, mu = -2, sigma = 1, delta = -1)
curve(dbgumbel(x, mu = -2, sigma = 1, delta = -1), xlim = c(-5, 10))
integrate(dbgumbel, mu = -2, sigma = 1, delta = -1, lower = -5, upper = 0)
pbgumbel(0, mu = -2, sigma = 1, delta = -1)
integrate(dbgumbel, mu = -2, sigma = 1, delta = -1, lower = -Inf, upper = 0)
pbgumbel(0, mu = -2, sigma = 1, delta = -1, lower.tail = FALSE)
curve(pbgumbel(x, mu = -2, sigma = 1, delta = -1), xlim = c(-5, 10))
It is recommended to set up a pbgumbel graph to see the starting and ending range of the desired quantile.
curve(pbgumbel(x, mu = -2, sigma = 1, delta = -1), xlim = c(-5, 5))
<- qbgumbel(.25, mu = -2, sigma = 1, delta = -1, initial = -4, final = -2))
(value pbgumbel(value, mu = -2, sigma = 1, delta = -1)
<- rbgumbel(100000, mu = -2, sigma = 1, delta = -1)
x hist(x, probability = TRUE)
curve(dbgumbel(x, mu = -2, sigma = 1, delta = -1), add = TRUE, col = 'blue')
lines(density(x), col = 'red')
<- m1bgumbel(mu = -2, sigma = 1, delta = -1))
(EX <- rbgumbel(100000, mu = -2, sigma = 1, delta = -1)
x mean(x)
abs(EX - mean(x))/abs(EX) # relative error
# grid 1
<- seq(-5, 5, length.out = 100)
mu <- seq(-5, 5, length.out = 100)
delta <- outer(X <- mu, Y <- delta, FUN = function(x, y) m1bgumbel(mu = x, sigma = 1, delta = y))
z persp(x = mu, y = delta, z = z, theta = -60, ticktype = 'detailed')
# grid 2
<- seq(-5, 5, length.out = 100)
mu <- seq(-5, 5, length.out = 100)
delta <- seq(.1, 10, length.out = 20)
sigmas for (sigma in sigmas) {
<- outer(X <- mu, Y <- delta, FUN = function(x, y) m1bgumbel(mu = x, sigma = sigma, delta = y))
z persp(x = mu, y = delta, z = z, theta = -60, zlab = 'E(X)')
Sys.sleep(.5)
}
<- m2bgumbel(mu = -2, sigma = 1, delta = -1))
(EX2 <- rbgumbel(100000, mu = -2, sigma = 1, delta = -1)
x mean(x^2)
abs(EX2 - mean(x))/abs(EX2) # relative error
# Variance
<- m1bgumbel(mu = -2, sigma = 1, delta = -1)
EX - EX^2
EX2 var(x)
abs(EX2 - EX^2 - var(x))/abs(EX2 - EX^2) # relative error
# grid 1
<- seq(-5, 5, length.out = 100)
mu <- seq(-5, 5, length.out = 100)
delta <- outer(X <- mu, Y <- delta, FUN = function(x, y) m2bgumbel(mu = x, sigma = 1, delta = y))
z persp(x = mu, y = delta, z = z, theta = -30, ticktype = 'detailed')
# grid 2
<- seq(-5, 5, length.out = 100)
mu <- seq(-5, 5, length.out = 100)
delta <- seq(.1, 10, length.out = 20)
sigmas for (sigma in sigmas) {
<- outer(X <- mu, Y <- delta, FUN = function(x, y) m2bgumbel(mu = x, sigma = sigma, delta = y))
z persp(x = mu, y = delta, z = z, theta = -45, zlab = 'E(X^2)')
Sys.sleep(.5)
}
# Let's generate some values
set.seed(123)
<- rbgumbel(1000, mu = -2, sigma = 1, delta = -1)
x
# Look for these references in the figure:
hist(x, probability = TRUE)
lines(density(x), col = 'blue')
abline(v = c(-2.5, -.5), col = 'red')
text(x = c(c(-2.5, -.5)), y = c(.05, .05), c('mu\nnear here', 'delta\nnear here'))
# If argument auto = FALSE
<- mlebgumbel(
fit data = x,
# try some values near the region. Format: theta = c(mu, sigma, delta)
theta = c(-3, 2, -2),
auto = FALSE
)print(fit)
# If argument auto = TRUE
<- mlebgumbel(
fit data = x,
auto = TRUE
)print(fit)
# Kolmogorov-Smirnov Tests
<- fit$estimate$estimate
mu.sigma.delta ks.test(
x, y = 'pbgumbel',
mu = mu.sigma.delta[[1]],
sigma = mu.sigma.delta[[2]],
delta = mu.sigma.delta[[3]]
)
Please, send to: https://github.com/pcbrom/bgumbel/issues
citation("bgumbel")