| Title: | One Zero Statistical Distributions |
|---|---|
| Description: | Implementation of new statistical distributions in (0, 1) interval. Each distribution includes the traditional functions as well as an additional function called the family function, which can be used to estimate parameters using Generalized Additive Models for Location, Scale and Shape, GAMLSS by Rigby & Stasinopoulos (2005) <doi:10.1111/j.1467-9876.2005.00510.x>. |
| Authors: | Freddy Hernandez-Barajas [aut, cre] (ORCID: <https://orcid.org/0000-0001-7459-3329>), Olga Usuga-Manco [aut] (ORCID: <https://orcid.org/0000-0003-3062-1820>) |
| Maintainer: | Freddy Hernandez-Barajas <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.1 |
| Built: | 2026-10-07 13:07:43 UTC |
| Source: | https://github.com/fhernanb/zeroonedists |
The Beta Rectangular family
BER(mu.link = "logit", sigma.link = "log", nu.link = "logit")BER(mu.link = "logit", sigma.link = "log", nu.link = "logit")
mu.link |
defines the mu.link, with "logit" link as the default for the mu parameter. |
sigma.link |
defines the sigma.link, with "log" link as the default for the sigma parameter. |
nu.link |
defines the nu.link, with "logit" link as the default for the nu parameter. |
The Beta Rectangular distribution with parameters mu,
sigma and nu has density given by
for , , and .
The function corresponds to the traditional beta distribution
that can be computed by dbeta(x, shape1=mu*sigma, shape2=(1-mu)*sigma).
Returns a gamlss.family object which can be used to fit a
BER distribution in the gamlss() function.
Karina Maria Garay, [email protected]
Bayes, C. L., Bazán, J. L., & García, C. (2012). A new robust regression model for proportions. Bayesian Analysis, 7(4), 841-866.
# Example 1 # Generating some random values with # known mu and sigma y <- rBER(n=500, mu=0.5, sigma=10, nu=0.5) # Fitting the model library(gamlss) mod1 <- gamlss(y~1, family=BER) # Extracting the fitted values for mu, sigma and nu # using the inverse link function inv_logit <- function(x) 1/(1 + exp(-x)) inv_logit(coef(mod1, what="mu")) exp(coef(mod1, what="sigma")) inv_logit(coef(mod1, what="nu")) # Example 2 # Generating random values under some model # A function to simulate a data set with Y ~ BER gendat <- function(n) { x1 <- runif(n, min=0.4, max=0.6) x2 <- runif(n, min=0.4, max=0.6) x3 <- runif(n, min=0.4, max=0.6) mu <- inv_logit(-0.5 + 1*x1) sigma <- exp(-1 + 4.8*x2) nu <- inv_logit(-1 + 0.5*x3) y <- rBER(n=n, mu=mu, sigma=sigma, nu=nu) data.frame(y=y, x1=x1, x2=x2, x3=x3) } set.seed(1234) datos <- gendat(n=500) mod2 <- gamlss(y~x1, sigma.fo=~x2, nu.fo=~x3, family=BER, data=datos, control=gamlss.control(n.cyc=500, trace=TRUE)) summary(mod2)# Example 1 # Generating some random values with # known mu and sigma y <- rBER(n=500, mu=0.5, sigma=10, nu=0.5) # Fitting the model library(gamlss) mod1 <- gamlss(y~1, family=BER) # Extracting the fitted values for mu, sigma and nu # using the inverse link function inv_logit <- function(x) 1/(1 + exp(-x)) inv_logit(coef(mod1, what="mu")) exp(coef(mod1, what="sigma")) inv_logit(coef(mod1, what="nu")) # Example 2 # Generating random values under some model # A function to simulate a data set with Y ~ BER gendat <- function(n) { x1 <- runif(n, min=0.4, max=0.6) x2 <- runif(n, min=0.4, max=0.6) x3 <- runif(n, min=0.4, max=0.6) mu <- inv_logit(-0.5 + 1*x1) sigma <- exp(-1 + 4.8*x2) nu <- inv_logit(-1 + 0.5*x3) y <- rBER(n=n, mu=mu, sigma=sigma, nu=nu) data.frame(y=y, x1=x1, x2=x2, x3=x3) } set.seed(1234) datos <- gendat(n=500) mod2 <- gamlss(y~x1, sigma.fo=~x2, nu.fo=~x3, family=BER, data=datos, control=gamlss.control(n.cyc=500, trace=TRUE)) summary(mod2)
The Beta Rectangular family
BER2(mu.link = "logit", sigma.link = "log", nu.link = "logit")BER2(mu.link = "logit", sigma.link = "log", nu.link = "logit")
mu.link |
defines the mu.link, with "logit" link as the default for the mu parameter. |
sigma.link |
defines the sigma.link, with "log" link as the default for the sigma parameter. |
nu.link |
defines the nu.link, with "logit" link as the default for the nu parameter. |
The Beta Rectangular distribution with parameters mu,
sigma and nu has density given by
for , , and .
The function corresponds to the traditional beta distribution
that can be computed by dbeta(x, shape1=mu*sigma, shape2=(1-mu)*sigma).
Returns a gamlss.family object which can be used to fit a
BER2 distribution in the gamlss() function.
Bayes, C. L., Bazán, J. L., & García, C. (2012). A new robust regression model for proportions. Bayesian Analysis, 7(4), 841-866.
# Example 1 # Generating some random values with # known mu and sigma y <- rBER2(n=500, mu=0.3, sigma=7, nu=0.4) # Fitting the model library(gamlss) mod1 <- gamlss(y~1, family=BER2, control=gamlss.control(n.cyc=500, trace=FALSE)) # Extracting the fitted values for mu, sigma and nu # using the inverse link function inv_logit <- function(x) 1/(1 + exp(-x)) inv_logit(coef(mod1, what="mu")) exp(coef(mod1, what="sigma")) inv_logit(coef(mod1, what="nu")) # Example 2 # Generating random values under some model # A function to simulate a data set with Y ~ BER2 gendat <- function(n) { x1 <- runif(n, min=0.4, max=0.6) x2 <- runif(n, min=0.4, max=0.6) x3 <- runif(n, min=0.4, max=0.6) mu <- inv_logit(-0.5 + 1*x1) sigma <- exp(-1 + 4.8*x2) nu <- inv_logit(-1 + 0.5*x3) y <- rBER2(n=n, mu=mu, sigma=sigma, nu=nu) data.frame(y=y, x1=x1, x2=x2, x3=x3) } set.seed(1234) datos <- gendat(n=500) mod2 <- gamlss(y~x1, sigma.fo=~x2, nu.fo=~x3, family=BER2, data=datos, control=gamlss.control(n.cyc=500, trace=TRUE)) summary(mod2)# Example 1 # Generating some random values with # known mu and sigma y <- rBER2(n=500, mu=0.3, sigma=7, nu=0.4) # Fitting the model library(gamlss) mod1 <- gamlss(y~1, family=BER2, control=gamlss.control(n.cyc=500, trace=FALSE)) # Extracting the fitted values for mu, sigma and nu # using the inverse link function inv_logit <- function(x) 1/(1 + exp(-x)) inv_logit(coef(mod1, what="mu")) exp(coef(mod1, what="sigma")) inv_logit(coef(mod1, what="nu")) # Example 2 # Generating random values under some model # A function to simulate a data set with Y ~ BER2 gendat <- function(n) { x1 <- runif(n, min=0.4, max=0.6) x2 <- runif(n, min=0.4, max=0.6) x3 <- runif(n, min=0.4, max=0.6) mu <- inv_logit(-0.5 + 1*x1) sigma <- exp(-1 + 4.8*x2) nu <- inv_logit(-1 + 0.5*x3) y <- rBER2(n=n, mu=mu, sigma=sigma, nu=nu) data.frame(y=y, x1=x1, x2=x2, x3=x3) } set.seed(1234) datos <- gendat(n=500) mod2 <- gamlss(y~x1, sigma.fo=~x2, nu.fo=~x3, family=BER2, data=datos, control=gamlss.control(n.cyc=500, trace=TRUE)) summary(mod2)
This function is used within the distribution family specification of a GAMLSS model to define the right link for each of the parameters of the distribution. This function should not be called by the user unless he/she specify a new distribution family or wishes to change existing link functions in the parameters.
checklink(which.link = NULL, which.dist = NULL, link = NULL, link.List = NULL)checklink(which.link = NULL, which.dist = NULL, link = NULL, link.List = NULL)
which.link |
which parameter link e.g. |
which.dist |
which distribution family e.g. |
link |
a repetition of |
link.List |
what link function are required e.g. |
This function is the same checklink fuction from gamlss.dist package.
Defines the right link for each parameter.
These functions define the density, distribution function, quantile
function and random generation for the Beta Rectangular distribution
with parameters , and .
dBER(x, mu, sigma, nu, log = FALSE) pBER(q, mu, sigma, nu, lower.tail = TRUE, log.p = FALSE) qBER(p, mu, sigma, nu, lower.tail = TRUE, log.p = FALSE) rBER(n, mu, sigma, nu)dBER(x, mu, sigma, nu, log = FALSE) pBER(q, mu, sigma, nu, lower.tail = TRUE, log.p = FALSE) qBER(p, mu, sigma, nu, lower.tail = TRUE, log.p = FALSE) rBER(n, mu, sigma, nu)
x, q
|
vector of (non-negative integer) quantiles. |
mu |
vector of the mu parameter. |
sigma |
vector of the sigma parameter. |
nu |
vector of the nu parameter. |
log, log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are
|
p |
vector of probabilities. |
n |
number of random values to return. |
The Beta Rectangular distribution with parameters , and
has a support in and density given by
for , , and .
The function corresponds to the traditional beta distribution
that can be computed by dbeta(x, shape1=mu*sigma, shape2=(1-mu)*sigma).
dBER gives the density, pBER gives the distribution
function, qBER gives the quantile function, rBER
generates random deviates.
Karina Maria Garay, [email protected]
Bayes, C. L., Bazán, J. L., & García, C. (2012). A new robust regression model for proportions. Bayesian Analysis, 7(4), 841-866.
BER.
# Example 1 # Plotting the density function for different parameter values curve(dBER(x, mu=0.5, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(dBER(x, mu=0.5, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(dBER(x, mu=0.5, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(dBER(x, mu=0.5, sigma=10, nu=0.6), add=TRUE, col="red") legend("topleft", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.5, sigma=10, nu=0", "mu=0.5, sigma=10, nu=0.2", "mu=0.5, sigma=10, nu=0.4", "mu=0.5, sigma=10, nu=0.6")) curve(dBER(x, mu=0.3, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(dBER(x, mu=0.3, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(dBER(x, mu=0.3, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(dBER(x, mu=0.3, sigma=10, nu=0.6), add=TRUE, col="red") legend("topright", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.5, sigma=10, nu=0", "mu=0.5, sigma=10, nu=0.2", "mu=0.5, sigma=10, nu=0.4", "mu=0.5, sigma=10, nu=0.6")) # Example 2 # Checking if the cumulative curves converge to 1 curve(pBER(x, mu=0.5, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(pBER(x, mu=0.5, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(pBER(x, mu=0.5, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(pBER(x, mu=0.5, sigma=10, nu=0.6), add=TRUE, col="red") legend("topleft", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.5, sigma=10, nu=0", "mu=0.5, sigma=10, nu=0.2", "mu=0.5, sigma=10, nu=0.4", "mu=0.5, sigma=10, nu=0.6")) # Example 3 # Checking the quantile function mu <- 0.5 sigma <- 10 nu <- 0.4 p <- seq(from=0.01, to=0.99, length.out=100) plot(x=qBER(p, mu=mu, sigma=sigma, nu=nu), y=p, xlab="Quantile", las=1, ylab="Probability") curve(pBER(x, mu=mu, sigma=sigma, nu=nu), add=TRUE, col="red") # Example 4 # Comparing the random generator output with # the theoretical density x <- rBER(n= 10000, mu=0.5, sigma=10, nu=0.1) hist(x, freq=FALSE) curve(dBER(x, mu=0.5, sigma=10, nu=0.1), col="tomato", add=TRUE)# Example 1 # Plotting the density function for different parameter values curve(dBER(x, mu=0.5, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(dBER(x, mu=0.5, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(dBER(x, mu=0.5, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(dBER(x, mu=0.5, sigma=10, nu=0.6), add=TRUE, col="red") legend("topleft", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.5, sigma=10, nu=0", "mu=0.5, sigma=10, nu=0.2", "mu=0.5, sigma=10, nu=0.4", "mu=0.5, sigma=10, nu=0.6")) curve(dBER(x, mu=0.3, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(dBER(x, mu=0.3, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(dBER(x, mu=0.3, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(dBER(x, mu=0.3, sigma=10, nu=0.6), add=TRUE, col="red") legend("topright", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.5, sigma=10, nu=0", "mu=0.5, sigma=10, nu=0.2", "mu=0.5, sigma=10, nu=0.4", "mu=0.5, sigma=10, nu=0.6")) # Example 2 # Checking if the cumulative curves converge to 1 curve(pBER(x, mu=0.5, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(pBER(x, mu=0.5, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(pBER(x, mu=0.5, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(pBER(x, mu=0.5, sigma=10, nu=0.6), add=TRUE, col="red") legend("topleft", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.5, sigma=10, nu=0", "mu=0.5, sigma=10, nu=0.2", "mu=0.5, sigma=10, nu=0.4", "mu=0.5, sigma=10, nu=0.6")) # Example 3 # Checking the quantile function mu <- 0.5 sigma <- 10 nu <- 0.4 p <- seq(from=0.01, to=0.99, length.out=100) plot(x=qBER(p, mu=mu, sigma=sigma, nu=nu), y=p, xlab="Quantile", las=1, ylab="Probability") curve(pBER(x, mu=mu, sigma=sigma, nu=nu), add=TRUE, col="red") # Example 4 # Comparing the random generator output with # the theoretical density x <- rBER(n= 10000, mu=0.5, sigma=10, nu=0.1) hist(x, freq=FALSE) curve(dBER(x, mu=0.5, sigma=10, nu=0.1), col="tomato", add=TRUE)
These functions define the density, distribution function, quantile
function and random generation for the Beta Rectangular distribution
with parameters , and
reparameterized to ensure .
dBER2(x, mu, sigma, nu, log = FALSE) pBER2(q, mu, sigma, nu, lower.tail = TRUE, log.p = FALSE) qBER2(p, mu, sigma, nu, lower.tail = TRUE, log.p = FALSE) rBER2(n, mu, sigma, nu)dBER2(x, mu, sigma, nu, log = FALSE) pBER2(q, mu, sigma, nu, lower.tail = TRUE, log.p = FALSE) qBER2(p, mu, sigma, nu, lower.tail = TRUE, log.p = FALSE) rBER2(n, mu, sigma, nu)
x, q
|
vector of (non-negative integer) quantiles. |
mu |
vector of the mu parameter. |
sigma |
vector of the sigma parameter. |
nu |
vector of the nu parameter. |
log, log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are
|
p |
vector of probabilities. |
n |
number of random values to return. |
The Beta Rectangular distribution with parameters , and
has a support in and density given by
for , , and .
The function corresponds to the traditional beta distribution
that can be computed by dbeta(x, shape1=mu*sigma, shape2=(1-mu)*sigma).
dBER2 gives the density, pBER2 gives the distribution
function, qBER2 gives the quantile function, rBER2
generates random deviates.
Bayes, C. L., Bazán, J. L., & García, C. (2012). A new robust regression model for proportions. Bayesian Analysis, 7(4), 841-866.
BER2.
# Example 1 # Plotting the density function for different parameter values curve(dBER2(x, mu=0.5, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(dBER2(x, mu=0.5, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(dBER2(x, mu=0.5, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(dBER2(x, mu=0.5, sigma=10, nu=0.6), add=TRUE, col="red") legend("topleft", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.5, sigma=10, nu=0", "mu=0.5, sigma=10, nu=0.2", "mu=0.5, sigma=10, nu=0.4", "mu=0.5, sigma=10, nu=0.6")) curve(dBER2(x, mu=0.3, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(dBER2(x, mu=0.3, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(dBER2(x, mu=0.3, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(dBER2(x, mu=0.3, sigma=10, nu=0.6), add=TRUE, col="red") legend("topright", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.3, sigma=10, nu=0", "mu=0.3, sigma=10, nu=0.2", "mu=0.3, sigma=10, nu=0.4", "mu=0.3, sigma=10, nu=0.6")) # Example 2 # Checking if the cumulative curves converge to 1 curve(pBER2(x, mu=0.5, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(pBER2(x, mu=0.5, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(pBER2(x, mu=0.5, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(pBER2(x, mu=0.5, sigma=10, nu=0.6), add=TRUE, col="red") legend("topleft", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.5, sigma=10, nu=0", "mu=0.5, sigma=10, nu=0.2", "mu=0.5, sigma=10, nu=0.4", "mu=0.5, sigma=10, nu=0.6")) # Example 3 # Checking the quantile function mu <- 0.5 sigma <- 10 nu <- 0.4 p <- seq(from=0.01, to=0.99, length.out=100) plot(x=qBER2(p, mu=mu, sigma=sigma, nu=nu), y=p, xlab="Quantile", las=1, ylab="Probability") curve(pBER2(x, mu=mu, sigma=sigma, nu=nu), add=TRUE, col="red") # Example 4 # Comparing the random generator output with # the theoretical density x <- rBER2(n= 10000, mu=0.3, sigma=10, nu=0.1) hist(x, freq=FALSE) curve(dBER2(x, mu=0.3, sigma=10, nu=0.1), col="tomato", add=TRUE)# Example 1 # Plotting the density function for different parameter values curve(dBER2(x, mu=0.5, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(dBER2(x, mu=0.5, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(dBER2(x, mu=0.5, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(dBER2(x, mu=0.5, sigma=10, nu=0.6), add=TRUE, col="red") legend("topleft", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.5, sigma=10, nu=0", "mu=0.5, sigma=10, nu=0.2", "mu=0.5, sigma=10, nu=0.4", "mu=0.5, sigma=10, nu=0.6")) curve(dBER2(x, mu=0.3, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(dBER2(x, mu=0.3, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(dBER2(x, mu=0.3, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(dBER2(x, mu=0.3, sigma=10, nu=0.6), add=TRUE, col="red") legend("topright", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.3, sigma=10, nu=0", "mu=0.3, sigma=10, nu=0.2", "mu=0.3, sigma=10, nu=0.4", "mu=0.3, sigma=10, nu=0.6")) # Example 2 # Checking if the cumulative curves converge to 1 curve(pBER2(x, mu=0.5, sigma=10, nu=0), from=0, to=1, col="green", las=1, ylab="f(x)") curve(pBER2(x, mu=0.5, sigma=10, nu=0.2), add=TRUE, col= "blue1") curve(pBER2(x, mu=0.5, sigma=10, nu=0.4), add=TRUE, col="yellow") curve(pBER2(x, mu=0.5, sigma=10, nu=0.6), add=TRUE, col="red") legend("topleft", col=c("green", "blue1", "yellow", "red"), lty=1, bty="n", legend=c("mu=0.5, sigma=10, nu=0", "mu=0.5, sigma=10, nu=0.2", "mu=0.5, sigma=10, nu=0.4", "mu=0.5, sigma=10, nu=0.6")) # Example 3 # Checking the quantile function mu <- 0.5 sigma <- 10 nu <- 0.4 p <- seq(from=0.01, to=0.99, length.out=100) plot(x=qBER2(p, mu=mu, sigma=sigma, nu=nu), y=p, xlab="Quantile", las=1, ylab="Probability") curve(pBER2(x, mu=mu, sigma=sigma, nu=nu), add=TRUE, col="red") # Example 4 # Comparing the random generator output with # the theoretical density x <- rBER2(n= 10000, mu=0.3, sigma=10, nu=0.1) hist(x, freq=FALSE) curve(dBER2(x, mu=0.3, sigma=10, nu=0.1), col="tomato", add=TRUE)
These functions define the density, distribution function, quantile
function and random generation for the Unit Half Logistic-Geometry distribution
with parameter .
dUHLG(x, mu, log = FALSE) pUHLG(q, mu, lower.tail = TRUE, log.p = FALSE) qUHLG(p, mu, lower.tail = TRUE, log.p = FALSE) rUHLG(n, mu)dUHLG(x, mu, log = FALSE) pUHLG(q, mu, lower.tail = TRUE, log.p = FALSE) qUHLG(p, mu, lower.tail = TRUE, log.p = FALSE) rUHLG(n, mu)
x, q
|
vector of (non-negative integer) quantiles. |
mu |
vector of the mu parameter. |
log, log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are
|
p |
vector of probabilities. |
n |
number of random values to return. |
The Unit Half Logistic-Geometry distribution with parameter
has a support in and density given by
for and .
dUHLG gives the density, pUHLG gives the distribution
function, qUHLG gives the quantile function, rUHLG
generates random deviates.
Juan Diego Suarez Hernandez, [email protected]
Ramadan, A. T., Tolba, A. H., & El-Desouky, B. S. (2022). A unit half-logistic geometric distribution and its application in insurance. Axioms, 11(12), 676.
UHLG.
# Example 1 # Plotting the density function for different parameter values curve(dUHLG(x, mu=0.4), from=0.01, to=0.99, ylim=c(0, 5), lwd=2, col="black", las=1, ylab="f(x)") curve(dUHLG(x, mu=1), lwd=2, add=TRUE, col="red") curve(dUHLG(x, mu=2), lwd=2, add=TRUE, col="green") curve(dUHLG(x, mu=7), lwd=2, add=TRUE, col="blue") legend("topright", col=c("black", "red", "green", "blue"), lty=1, bty="n", lwd=2, legend=c("mu=0.4", "mu=1", "mu=2", "mu=7")) # Example 2 # Checking if the cumulative curves converge to 1 curve(pUHLG(x, mu=0.25), lwd=2, from=0.001, to=0.999, col="black", las=1, ylab="F(x)") curve(pUHLG(x, mu=0.7), lwd=2, add=TRUE, col="red") curve(pUHLG(x, mu=1.8), lwd=2, add=TRUE, col="green") curve(pUHLG(x, mu=2.2), lwd=2, add=TRUE, col="blue") legend("bottomright", col=c("black", "red", "green", "blue"), lty=1, bty="n", lwd=2, legend=c("mu=0.25", "mu=0.7", "mu=1.8", "mu=2.2")) # Example 3 # Checking the quantile function mu <- 2 p <- seq(from=0.01, to=0.99, length.out=100) plot(x=qUHLG(p, mu=mu), y=p, xlab="Quantile", las=1, ylab="Probability") curve(pUHLG(x, mu=mu), add=TRUE, col="red") # Example 4 # Comparing the random generator output with # the theoretical density x <- rUHLG(n=10000, mu=0.5) hist(x, freq=FALSE) curve(dUHLG(x, mu=0.5), lwd=2, col="tomato", add=TRUE, from=0.01, to=0.99)# Example 1 # Plotting the density function for different parameter values curve(dUHLG(x, mu=0.4), from=0.01, to=0.99, ylim=c(0, 5), lwd=2, col="black", las=1, ylab="f(x)") curve(dUHLG(x, mu=1), lwd=2, add=TRUE, col="red") curve(dUHLG(x, mu=2), lwd=2, add=TRUE, col="green") curve(dUHLG(x, mu=7), lwd=2, add=TRUE, col="blue") legend("topright", col=c("black", "red", "green", "blue"), lty=1, bty="n", lwd=2, legend=c("mu=0.4", "mu=1", "mu=2", "mu=7")) # Example 2 # Checking if the cumulative curves converge to 1 curve(pUHLG(x, mu=0.25), lwd=2, from=0.001, to=0.999, col="black", las=1, ylab="F(x)") curve(pUHLG(x, mu=0.7), lwd=2, add=TRUE, col="red") curve(pUHLG(x, mu=1.8), lwd=2, add=TRUE, col="green") curve(pUHLG(x, mu=2.2), lwd=2, add=TRUE, col="blue") legend("bottomright", col=c("black", "red", "green", "blue"), lty=1, bty="n", lwd=2, legend=c("mu=0.25", "mu=0.7", "mu=1.8", "mu=2.2")) # Example 3 # Checking the quantile function mu <- 2 p <- seq(from=0.01, to=0.99, length.out=100) plot(x=qUHLG(p, mu=mu), y=p, xlab="Quantile", las=1, ylab="Probability") curve(pUHLG(x, mu=mu), add=TRUE, col="red") # Example 4 # Comparing the random generator output with # the theoretical density x <- rUHLG(n=10000, mu=0.5) hist(x, freq=FALSE) curve(dUHLG(x, mu=0.5), lwd=2, col="tomato", add=TRUE, from=0.01, to=0.99)
These functions define the density, distribution function, quantile
function and random generation for the Unit Maxwell-Boltzmann distribution
with parameter .
dUMB(x, mu = 1, log = FALSE) pUMB(q, mu = 1, lower.tail = TRUE, log.p = FALSE) qUMB(p, mu, lower.tail = TRUE, log.p = FALSE) rUMB(n = 1, mu = 1)dUMB(x, mu = 1, log = FALSE) pUMB(q, mu = 1, lower.tail = TRUE, log.p = FALSE) qUMB(p, mu, lower.tail = TRUE, log.p = FALSE) rUMB(n = 1, mu = 1)
x, q
|
vector of (non-negative integer) quantiles. |
mu |
vector of the mu parameter. |
log, log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are
|
p |
vector of probabilities. |
n |
number of random values to return. |
The Unit Maxwell-Boltzmann distribution with parameter
has a support in and density given by
for and .
dUMB gives the density, pUMB gives the distribution
function, qUMB gives the quantile function, rUMB
generates random deviates.
David Villegas Ceballos, [email protected]
Biçer, C., Bakouch, H. S., Biçer, H. D., Alomair, G., Hussain, T., y Almohisen, A. (2024). Unit Maxwell-Boltzmann Distribution and Its Application to Concentrations Pollutant Data. Axioms, 13(4), 226.
UMB.
# Example 1 # Plotting the density function for different parameter values curve(dUMB(x, mu=0.4), from=0, to=1, ylim=c(0, 12), col="green", las=1, ylab="f(x)") curve(dUMB(x, mu=1), add=TRUE, col="blue1") curve(dUMB(x, mu=2), add=TRUE, col="black") curve(dUMB(x, mu=7), add=TRUE, col="red") legend("topright", col=c("green", "blue1", "black", "red"), lty=1, bty="n", legend=c("mu=0.4", "mu=1", "mu=2", "mu=7")) # Example 2 # Checking if the cumulative curves converge to 1 curve(pUMB(x, mu=0.25), from=0, to=1, col="green", las=1, ylab="F(x)") curve(pUMB(x, mu=0.9), add=TRUE, col="blue1") curve(pUMB(x, mu=1.8), add=TRUE, col="black") curve(pUMB(x, mu=2.2), add=TRUE, col="red") legend("bottomright", col=c("green", "blue1", "black", "red"), lty=1, bty="n", legend=c("mu=0.25", "mu=0.9", "mu=1.8", "mu=2.2")) # Example 3 # Checking the quantile function mu <- 2 p <- seq(from=0, to=1, length.out=100) plot(x=qUMB(p, mu=mu), y=p, xlab="Quantile", las=1, ylab="Probability") curve(pUMB(x, mu=mu), add=TRUE, col="red") # Example 4 # Comparing the random generator output with # the theoretical density x <- rUMB(n=1000, mu=0.5) hist(x, freq=FALSE) curve(dUMB(x, mu=0.5), col="tomato", add=TRUE, from=0, to=1)# Example 1 # Plotting the density function for different parameter values curve(dUMB(x, mu=0.4), from=0, to=1, ylim=c(0, 12), col="green", las=1, ylab="f(x)") curve(dUMB(x, mu=1), add=TRUE, col="blue1") curve(dUMB(x, mu=2), add=TRUE, col="black") curve(dUMB(x, mu=7), add=TRUE, col="red") legend("topright", col=c("green", "blue1", "black", "red"), lty=1, bty="n", legend=c("mu=0.4", "mu=1", "mu=2", "mu=7")) # Example 2 # Checking if the cumulative curves converge to 1 curve(pUMB(x, mu=0.25), from=0, to=1, col="green", las=1, ylab="F(x)") curve(pUMB(x, mu=0.9), add=TRUE, col="blue1") curve(pUMB(x, mu=1.8), add=TRUE, col="black") curve(pUMB(x, mu=2.2), add=TRUE, col="red") legend("bottomright", col=c("green", "blue1", "black", "red"), lty=1, bty="n", legend=c("mu=0.25", "mu=0.9", "mu=1.8", "mu=2.2")) # Example 3 # Checking the quantile function mu <- 2 p <- seq(from=0, to=1, length.out=100) plot(x=qUMB(p, mu=mu), y=p, xlab="Quantile", las=1, ylab="Probability") curve(pUMB(x, mu=mu), add=TRUE, col="red") # Example 4 # Comparing the random generator output with # the theoretical density x <- rUMB(n=1000, mu=0.5) hist(x, freq=FALSE) curve(dUMB(x, mu=0.5), col="tomato", add=TRUE, from=0, to=1)
These functions define the density, distribution function, quantile
function and random generation for the Unit-Power Half-Normal distribution
with parameter and .
dUPHN(x, mu, sigma, log = FALSE) pUPHN(q, mu, sigma, lower.tail = TRUE, log.p = FALSE) qUPHN(p, mu, sigma, lower.tail = TRUE, log.p = FALSE) rUPHN(n, mu, sigma)dUPHN(x, mu, sigma, log = FALSE) pUPHN(q, mu, sigma, lower.tail = TRUE, log.p = FALSE) qUPHN(p, mu, sigma, lower.tail = TRUE, log.p = FALSE) rUPHN(n, mu, sigma)
x, q
|
vector of (non-negative integer) quantiles. |
mu |
vector of the mu parameter. |
sigma |
vector of the sigma parameter. |
log, log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are
|
p |
vector of probabilities. |
n |
number of random values to return. |
The Unit-Power Half-Normal distribution with parameters
and
has a support in and density given by
for , and .
dUPHN gives the density, pUPHN gives the distribution
function, qUPHN gives the quantile function, rUPHN
generates random deviates.
Juan Diego Suarez Hernandez, [email protected]
Santoro, K. I., Gómez, Y. M., Soto, D., & Barranco-Chamorro, I. (2024). Unit-Power Half-Normal Distribution Including Quantile Regression with Applications to Medical Data. Axioms, 13(9), 599.
# Example 1 # Plotting the density function for different parameter values curve(dUPHN(x, mu=1, sigma=1), ylim=c(0, 5), from=0.01, to=0.99, col="black", las=1, ylab="f(x)") curve(dUPHN(x, mu=2, sigma=1), add=TRUE, col= "red") curve(dUPHN(x, mu=3, sigma=1), add=TRUE, col="seagreen") curve(dUPHN(x, mu=4, sigma=1), add=TRUE, col="royalblue2") legend("topright", col=c("black", "red", "seagreen", "royalblue2"), lty=1, bty="n", legend=c("mu=1, sigma=1", "mu=2, sigma=1", "mu=3, sigma=1", "mu=4, sigma=1")) # Example 2 # Checking if the cumulative curves converge to 1 curve(pUPHN(x, mu=1, sigma=1), from=0.01, to=0.99, col="black", las=1, ylab="F(x)") curve(pUPHN(x, mu=2, sigma=1), add=TRUE, col= "red") curve(pUPHN(x, mu=3, sigma=1), add=TRUE, col="seagreen") curve(pUPHN(x, mu=4, sigma=1), add=TRUE, col="royalblue2") legend("topleft", col=c("black", "red", "seagreen", "royalblue2"), lty=1, bty="n", legend=c("mu=1, sigma=1", "mu=2, sigma=1", "mu=3, sigma=1", "mu=4, sigma=1")) # Example 3 # Checking the quantile function mu <- 2 sigma <- 3 p <- seq(from=0.01, to=0.99, length.out=100) plot(x=qUPHN(p, mu=mu, sigma=sigma), y=p, xlab="Quantile", las=1, ylab="Probability") curve(pUPHN(x, mu=mu, sigma=sigma), add=TRUE, col="red") # Example 4 # Comparing the random generator output with # the theoretical density x <- rUPHN(n= 10000, mu=4, sigma=1) hist(x, freq=FALSE) curve(dUPHN(x, mu=4, sigma=1), col="tomato", add=TRUE, from=0.01, to=0.99)# Example 1 # Plotting the density function for different parameter values curve(dUPHN(x, mu=1, sigma=1), ylim=c(0, 5), from=0.01, to=0.99, col="black", las=1, ylab="f(x)") curve(dUPHN(x, mu=2, sigma=1), add=TRUE, col= "red") curve(dUPHN(x, mu=3, sigma=1), add=TRUE, col="seagreen") curve(dUPHN(x, mu=4, sigma=1), add=TRUE, col="royalblue2") legend("topright", col=c("black", "red", "seagreen", "royalblue2"), lty=1, bty="n", legend=c("mu=1, sigma=1", "mu=2, sigma=1", "mu=3, sigma=1", "mu=4, sigma=1")) # Example 2 # Checking if the cumulative curves converge to 1 curve(pUPHN(x, mu=1, sigma=1), from=0.01, to=0.99, col="black", las=1, ylab="F(x)") curve(pUPHN(x, mu=2, sigma=1), add=TRUE, col= "red") curve(pUPHN(x, mu=3, sigma=1), add=TRUE, col="seagreen") curve(pUPHN(x, mu=4, sigma=1), add=TRUE, col="royalblue2") legend("topleft", col=c("black", "red", "seagreen", "royalblue2"), lty=1, bty="n", legend=c("mu=1, sigma=1", "mu=2, sigma=1", "mu=3, sigma=1", "mu=4, sigma=1")) # Example 3 # Checking the quantile function mu <- 2 sigma <- 3 p <- seq(from=0.01, to=0.99, length.out=100) plot(x=qUPHN(p, mu=mu, sigma=sigma), y=p, xlab="Quantile", las=1, ylab="Probability") curve(pUPHN(x, mu=mu, sigma=sigma), add=TRUE, col="red") # Example 4 # Comparing the random generator output with # the theoretical density x <- rUPHN(n= 10000, mu=4, sigma=1) hist(x, freq=FALSE) curve(dUPHN(x, mu=4, sigma=1), col="tomato", add=TRUE, from=0.01, to=0.99)
The function make.link.gamlss() is used with gamlss.family
distributions in package gamlss().Given a link, it returns a link
function, an inverse link function, the derivative dpar/deta where 'par'
is the appropriate distribution parameter and a function for checking
the domain. It differs from the usual make.link of glm() by
having extra links as the logshifto1, and the own.
For the use of the own link see the example bellow.
show.link provides a way in which the user can identify the link
functions available for each gamlss distribution. If your required link
function is not available for any of the gamlss distributions you can add it in.
make.link.gamlss(link)make.link.gamlss(link)
link |
character or numeric; one of |
The own link function is added to allow the user greater
flexibility. In order to used the own link function for any of the
parameters of the distribution the own link should appear in the
available links for this parameter. You can check this using the function
show.link. If the own do not appear in the list you can
create a new function for the distribution in which own is added
in the list. For example the first line of the code of the binomial
distribution, BI, has change from
"mstats <- checklink("mu.link", "Binomial", substitute(mu.link), c("logit", "probit", "cloglog", "log")), in version 1.0-0 of gamlss, to
"mstats <- checklink("mu.link", "Binomial", substitute(mu.link), c("logit", "probit", "cloglog", "log", "own"))
in version 1.0-1. Given that the parameter has own as an option the user needs also
to define the following four new functions in order to used an
own link.
i) own.linkfun
ii) own.linkinv
iii) own.mu.eta and
iv) own.valideta.
An example is given below.
Only one parameter of the distribution at a time is allowed to have
its own link, (unless the same four own functions above
are suitable for more that one parameter of the distribution).
Note that from gamlss version 1.9-0 the user can introduce its own link function by define an appropriate function, (see the example below).
For the make.link.gamlss a list with components
linkfun: Link function function(parameter)
linkinv: Inverse link function function(eta)
mu.eta: Derivative function(eta) dparameter/deta
valideta: function(eta) TRUE if all of eta is in the domain of linkinv.
For the show.link a list with components the available links for the distribution parameters
For the links involving parameters as in logshifted and
logitshifted the parameters can be passed in the definition of the
distribution by calling the checklink function, for example in the
definition of the tau parameter in BCPE distribution the following
call is made: tstats <- checklink("tau.link",
"Box Cox Power Exponential", substitute(tau.link),
c("logshifted", "log", "identity"), par.link = c(1))
This function is the same make.link.gamlss fuction from gamlss.dist package.
The Unit Half Logistic-Geometry family
UHLG(mu.link = "log")UHLG(mu.link = "log")
mu.link |
defines the mu.link, with "log" link as the default for the mu parameter. |
The Unit Half Logistic-Geometry distribution with parameter mu,
has density given by
for and .
Returns a gamlss.family object which can be used to fit a
UHLG distribution in the gamlss() function.
Juan Diego Suarez Hernandez, [email protected]
Ramadan, A. T., Tolba, A. H., & El-Desouky, B. S. (2022). A unit half-logistic geometric distribution and its application in insurance. Axioms, 11(12), 676.
# Example 1 # Generating some random values with # known mu y <- rUHLG(n=500, mu=7) # Fitting the model library(gamlss) mod1 <- gamlss(y~1, family=UHLG, control=gamlss.control(n.cyc=500, trace=FALSE)) # Extracting the fitted values for mu, sigma and nu # using the inverse link function exp(coef(mod1, what="mu")) # Example 2 # Generating random values under some model # A function to simulate a data set with Y ~ UHLG gendat <- function(n) { x1 <- runif(n, min=0.4, max=0.6) x2 <- runif(n, min=0.4, max=0.6) mu <- exp(-0.5 + 3*x1 - 2.5*x2) y <- rUHLG(n=n, mu=mu) data.frame(y=y, x1=x1, x2=x2) } datos <- gendat(n=5000) mod2 <- gamlss(y~x1+x2, family=UHLG, data=datos, control=gamlss.control(n.cyc=500, trace=TRUE)) summary(mod2)# Example 1 # Generating some random values with # known mu y <- rUHLG(n=500, mu=7) # Fitting the model library(gamlss) mod1 <- gamlss(y~1, family=UHLG, control=gamlss.control(n.cyc=500, trace=FALSE)) # Extracting the fitted values for mu, sigma and nu # using the inverse link function exp(coef(mod1, what="mu")) # Example 2 # Generating random values under some model # A function to simulate a data set with Y ~ UHLG gendat <- function(n) { x1 <- runif(n, min=0.4, max=0.6) x2 <- runif(n, min=0.4, max=0.6) mu <- exp(-0.5 + 3*x1 - 2.5*x2) y <- rUHLG(n=n, mu=mu) data.frame(y=y, x1=x1, x2=x2) } datos <- gendat(n=5000) mod2 <- gamlss(y~x1+x2, family=UHLG, data=datos, control=gamlss.control(n.cyc=500, trace=TRUE)) summary(mod2)
The function UMB() defines the Unit Maxwell-Boltzmann distribution, a one parameter
distribution, for a gamlss.family object to be used in GAMLSS fitting
using the function gamlss().
UMB(mu.link = "log")UMB(mu.link = "log")
mu.link |
defines the mu.link, with "log" link as the default for the mu. |
The Unit Maxwell-Boltzmann distribution with parameter
has a support in and density given by
for and .
Returns a gamlss.family object which can be used to fit a
UMB distribution in the gamlss() function.
David Villegas Ceballos, [email protected]
Biçer, C., Bakouch, H. S., Biçer, H. D., Alomair, G., Hussain, T., y Almohisen, A. (2024). Unit Maxwell-Boltzmann Distribution and Its Application to Concentrations Pollutant Data. Axioms, 13(4), 226.
# Example 1 # Generating some random values with # known mu y <- rUMB(n=300, mu=0.5) # Fitting the model library(gamlss) mod1 <- gamlss(y~1, family=UMB) # Extracting the fitted values for mu # using the inverse link function exp(coef(mod1, what="mu")) # Example 2 # Generating random values under some model # A function to simulate a data set with Y ~ UMB gendat <- function(n) { x1 <- runif(n) mu <- exp(-0.5 + 1 * x1) y <- rUMB(n=n, mu=mu) data.frame(y=y, x1=x1) } datos <- gendat(n=300) mod2 <- gamlss(y~x1, family=UMB, data=datos) summary(mod2) # Example 3 # The first dataset measured the concentration of air pollutant CO # in Alberta, Canada from the Edmonton Central (downtown) # Monitoring Unit (EDMU) station during 1995. # Measurements are listed for the period 1976-1995. # Taken from Bicer et al. (2024) page 12. data1 <- c(0.19, 0.20, 0.20, 0.27, 0.30, 0.37, 0.30, 0.25, 0.23, 0.23, 0.26, 0.23, 0.19, 0.21, 0.20, 0.22, 0.21, 0.25, 0.25, 0.19) mod3 <- gamlss(data1 ~ 1, family=UMB) # Extracting the fitted values for mu # using the inverse link function exp(coef(mod3, what="mu")) # Extraction of the log likelihood logLik(mod3) # Example 4 # The second data set measured air quality monitoring of the # annual average concentration of the pollutant benzo(a)pyrene (BaP). # The data were obtained from the Edmonton Central (downtown) # Monitoring Unit (EDMU) location in Alberta, Canada, in 1995. # Taken from Bicer et al. (2024) page 12. data2 <- c(0.22, 0.20, 0.25, 0.15, 0.38, 0.18, 0.52, 0.27, 0.27, 0.27, 0.13, 0.15, 0.24, 0.37, 0.20) mod4 <- gamlss(data2 ~ 1, family=UMB) # Extracting the fitted values for mu # using the inverse link function exp(coef(mod4, what="mu")) # Extraction of the log likelihood logLik(mod4) # Replicating figure 5 from Bicer et al. (2024) # Hist and estimated pdf of Data-I and Data-II mu1 <- 0.8452875 mu2 <- 0.8593051 # Data-I hist(data1, freq = FALSE, xlim = c(0, 1.0), ylim = c(0, 10), main = "Histogram of Data-I", xlab = "y", ylab = "f(y)", col = "burlywood1", border = "darkgoldenrod4") curve(dUMB(x, mu = mu1), add = TRUE, col = "blue", lwd = 2) legend("topright", legend = c("UMB"), col = c("blue"), lwd = 2, bty = "n") # Data-II hist(data2, freq = FALSE, xlim = c(0, 1.0), ylim = c(0, 6), main = "Histogram of Data-II", xlab = "y", ylab = "f(y)", col = "burlywood1", border = "darkgoldenrod4") curve(dUMB(x, mu = mu2), add = TRUE, col = "blue", lwd = 2) legend("topright", legend = c("UMB"), col = c("blue"), lwd = 2, bty = "n") # Example 5 # The third dataset measured the concentration of sulphate # in Calgary from 31 different periods during 1995. # Taken from Bicer et al. (2024) page 13. data3 <- c(0.048, 0.013, 0.040, 0.082, 0.073, 0.732, 0.302, 0.728, 0.305, 0.322, 0.045, 0.261, 0.192, 0.357, 0.022, 0.143, 0.208, 0.104, 0.330, 0.453, 0.135, 0.114, 0.049, 0.011, 0.008, 0.037, 0.034, 0.015, 0.028, 0.069, 0.029) mod5 <- gamlss(data3 ~ 1, family=UMB) # Extracting the fitted values for mu # using the inverse link function exp(coef(mod5, what="mu")) # Extraction of the log likelihood logLik(mod5) # Example 6 # The fourth dataset measured the concentration of pollutant CO in Alberta, Canada # from the Calgary northwest (residential) monitoring unit (CRMU) station during 1995. # Measurements are listed for the period 1976-95. # Taken from Bicer et al. (2024) page 13. data4 <- c(0.16, 0.19, 0.24, 0.25, 0.30, 0.41, 0.40, 0.33, 0.23, 0.27, 0.30, 0.32, 0.26, 0.25, 0.22, 0.22, 0.18, 0.18, 0.20, 0.23) mod6 <- gamlss(data4 ~ 1, family=UMB) # Extracting the fitted values for mu # using the inverse link function exp(coef(mod6, what="mu")) # Extraction of the log likelihood logLik(mod6) # Replicating figure 6 from Bicer et al. (2024) # Hist and estimated pdf of Data-III and Data-IV mu3 <- 1.582003 mu4 <- 0.8161202 # Data-III hist(data3, freq = FALSE, xlim = c(0, 1.0), ylim = c(0, 10), main = "Histogram of Data-III", xlab = "y", ylab = "f(y)", col = "burlywood1", border = "darkgoldenrod4") curve(dUMB(x, mu = mu3), add = TRUE, col = "blue", lwd = 2) legend("topright", legend = c("UMB"), col = c("blue"), lwd = 2, bty = "n") # Data-IV hist(data4, freq = FALSE, xlim = c(0, 1.0), ylim = c(0, 6), main = "Histogram of Data-IV", xlab = "y", ylab = "f(y)", col = "burlywood1", border = "darkgoldenrod4") curve(dUMB(x, mu = mu4), add = TRUE, col = "blue", lwd = 2) legend("topright", legend = c("UMB"), col = c("blue"), lwd = 2, bty = "n")# Example 1 # Generating some random values with # known mu y <- rUMB(n=300, mu=0.5) # Fitting the model library(gamlss) mod1 <- gamlss(y~1, family=UMB) # Extracting the fitted values for mu # using the inverse link function exp(coef(mod1, what="mu")) # Example 2 # Generating random values under some model # A function to simulate a data set with Y ~ UMB gendat <- function(n) { x1 <- runif(n) mu <- exp(-0.5 + 1 * x1) y <- rUMB(n=n, mu=mu) data.frame(y=y, x1=x1) } datos <- gendat(n=300) mod2 <- gamlss(y~x1, family=UMB, data=datos) summary(mod2) # Example 3 # The first dataset measured the concentration of air pollutant CO # in Alberta, Canada from the Edmonton Central (downtown) # Monitoring Unit (EDMU) station during 1995. # Measurements are listed for the period 1976-1995. # Taken from Bicer et al. (2024) page 12. data1 <- c(0.19, 0.20, 0.20, 0.27, 0.30, 0.37, 0.30, 0.25, 0.23, 0.23, 0.26, 0.23, 0.19, 0.21, 0.20, 0.22, 0.21, 0.25, 0.25, 0.19) mod3 <- gamlss(data1 ~ 1, family=UMB) # Extracting the fitted values for mu # using the inverse link function exp(coef(mod3, what="mu")) # Extraction of the log likelihood logLik(mod3) # Example 4 # The second data set measured air quality monitoring of the # annual average concentration of the pollutant benzo(a)pyrene (BaP). # The data were obtained from the Edmonton Central (downtown) # Monitoring Unit (EDMU) location in Alberta, Canada, in 1995. # Taken from Bicer et al. (2024) page 12. data2 <- c(0.22, 0.20, 0.25, 0.15, 0.38, 0.18, 0.52, 0.27, 0.27, 0.27, 0.13, 0.15, 0.24, 0.37, 0.20) mod4 <- gamlss(data2 ~ 1, family=UMB) # Extracting the fitted values for mu # using the inverse link function exp(coef(mod4, what="mu")) # Extraction of the log likelihood logLik(mod4) # Replicating figure 5 from Bicer et al. (2024) # Hist and estimated pdf of Data-I and Data-II mu1 <- 0.8452875 mu2 <- 0.8593051 # Data-I hist(data1, freq = FALSE, xlim = c(0, 1.0), ylim = c(0, 10), main = "Histogram of Data-I", xlab = "y", ylab = "f(y)", col = "burlywood1", border = "darkgoldenrod4") curve(dUMB(x, mu = mu1), add = TRUE, col = "blue", lwd = 2) legend("topright", legend = c("UMB"), col = c("blue"), lwd = 2, bty = "n") # Data-II hist(data2, freq = FALSE, xlim = c(0, 1.0), ylim = c(0, 6), main = "Histogram of Data-II", xlab = "y", ylab = "f(y)", col = "burlywood1", border = "darkgoldenrod4") curve(dUMB(x, mu = mu2), add = TRUE, col = "blue", lwd = 2) legend("topright", legend = c("UMB"), col = c("blue"), lwd = 2, bty = "n") # Example 5 # The third dataset measured the concentration of sulphate # in Calgary from 31 different periods during 1995. # Taken from Bicer et al. (2024) page 13. data3 <- c(0.048, 0.013, 0.040, 0.082, 0.073, 0.732, 0.302, 0.728, 0.305, 0.322, 0.045, 0.261, 0.192, 0.357, 0.022, 0.143, 0.208, 0.104, 0.330, 0.453, 0.135, 0.114, 0.049, 0.011, 0.008, 0.037, 0.034, 0.015, 0.028, 0.069, 0.029) mod5 <- gamlss(data3 ~ 1, family=UMB) # Extracting the fitted values for mu # using the inverse link function exp(coef(mod5, what="mu")) # Extraction of the log likelihood logLik(mod5) # Example 6 # The fourth dataset measured the concentration of pollutant CO in Alberta, Canada # from the Calgary northwest (residential) monitoring unit (CRMU) station during 1995. # Measurements are listed for the period 1976-95. # Taken from Bicer et al. (2024) page 13. data4 <- c(0.16, 0.19, 0.24, 0.25, 0.30, 0.41, 0.40, 0.33, 0.23, 0.27, 0.30, 0.32, 0.26, 0.25, 0.22, 0.22, 0.18, 0.18, 0.20, 0.23) mod6 <- gamlss(data4 ~ 1, family=UMB) # Extracting the fitted values for mu # using the inverse link function exp(coef(mod6, what="mu")) # Extraction of the log likelihood logLik(mod6) # Replicating figure 6 from Bicer et al. (2024) # Hist and estimated pdf of Data-III and Data-IV mu3 <- 1.582003 mu4 <- 0.8161202 # Data-III hist(data3, freq = FALSE, xlim = c(0, 1.0), ylim = c(0, 10), main = "Histogram of Data-III", xlab = "y", ylab = "f(y)", col = "burlywood1", border = "darkgoldenrod4") curve(dUMB(x, mu = mu3), add = TRUE, col = "blue", lwd = 2) legend("topright", legend = c("UMB"), col = c("blue"), lwd = 2, bty = "n") # Data-IV hist(data4, freq = FALSE, xlim = c(0, 1.0), ylim = c(0, 6), main = "Histogram of Data-IV", xlab = "y", ylab = "f(y)", col = "burlywood1", border = "darkgoldenrod4") curve(dUMB(x, mu = mu4), add = TRUE, col = "blue", lwd = 2) legend("topright", legend = c("UMB"), col = c("blue"), lwd = 2, bty = "n")
The function UPHN() defines the Unit-Power Half-Normal
distribution, a two parameter
distribution, for a gamlss.family object to be used in GAMLSS fitting
using the function gamlss().
UPHN(mu.link = "log", sigma.link = "log")UPHN(mu.link = "log", sigma.link = "log")
mu.link |
defines the mu.link, with "log" link as the default for the mu parameter. |
sigma.link |
defines the sigma.link, with "log" link as the default for the sigma. |
The UPHN distribution with parameters
and
has a support in and density given by
for , and .
Returns a gamlss.family object which can be used to fit a
UPHN distribution in the gamlss() function.
Juan Diego Suarez Hernandez, [email protected]
Santoro, K. I., Gomez, Y. M., Soto, D., & Barranco-Chamorro, I. (2024). Unit-Power Half-Normal Distribution Including Quantile Regression with Applications to Medical Data. Axioms, 13(9), 599.
# Example 1 # Generating random values with # known mu and sigma require(gamlss) mu <- 1.5 sigma <- 4.0 y <- rUPHN(1000, mu, sigma) mod1 <- gamlss(y~1, sigma.fo=~1, family=UPHN, control=gamlss.control(n.cyc=5000, trace=TRUE)) exp(coef(mod1, what="mu")) exp(coef(mod1, what="sigma")) # Example 2 # Generating random values under some model # A function to simulate a data set with Y ~ UPHN gendat <- function(n) { x1 <- runif(n) x2 <- runif(n) mu <- exp(0.75 - 0.69 * x1) # Approx 1.5 sigma <- exp(0.5 - 0.64 * x2) # Approx 1.20 y <- rUPHN(n, mu, sigma) data.frame(y=y, x1=x1, x2=x2) } dat <- gendat(n=2000) mod2 <- gamlss(y~x1, sigma.fo=~x2, family=UPHN, data=dat, control=gamlss.control(n.cyc=5000, trace=TRUE)) summary(mod2)# Example 1 # Generating random values with # known mu and sigma require(gamlss) mu <- 1.5 sigma <- 4.0 y <- rUPHN(1000, mu, sigma) mod1 <- gamlss(y~1, sigma.fo=~1, family=UPHN, control=gamlss.control(n.cyc=5000, trace=TRUE)) exp(coef(mod1, what="mu")) exp(coef(mod1, what="sigma")) # Example 2 # Generating random values under some model # A function to simulate a data set with Y ~ UPHN gendat <- function(n) { x1 <- runif(n) x2 <- runif(n) mu <- exp(0.75 - 0.69 * x1) # Approx 1.5 sigma <- exp(0.5 - 0.64 * x2) # Approx 1.20 y <- rUPHN(n, mu, sigma) data.frame(y=y, x1=x1, x2=x2) } dat <- gendat(n=2000) mod2 <- gamlss(y~x1, sigma.fo=~x2, family=UPHN, data=dat, control=gamlss.control(n.cyc=5000, trace=TRUE)) summary(mod2)