| Title: | Generalized Kumaraswamy Distribution Family |
|---|---|
| Description: | Implements the five-parameter Generalized Kumaraswamy ('gkw') distribution proposed by 'Carrasco, Ferrari and Cordeiro (2010)' <doi:10.48550/arXiv.1004.0911> and its seven nested sub-families for modeling bounded continuous data on the unit interval (0,1). The 'gkw' distribution extends the Kumaraswamy distribution described by Jones (2009) <doi:10.1016/j.stamet.2008.04.001>. Provides density, distribution, quantile, and random generation functions, along with analytical log-likelihood, gradient, and Hessian functions implemented in 'C++' via 'RcppArmadillo' for maximum computational efficiency. Suitable for modeling proportions, rates, percentages, and indices exhibiting complex features such as asymmetry, or heavy tails and other shapes not adequately captured by standard distributions like simple Beta or Kumaraswamy. |
| Authors: | José Evandeilton Lopes [aut, cre] (ORCID: <https://orcid.org/0009-0007-5887-4084>) |
| Maintainer: | José Evandeilton Lopes <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.7 |
| Built: | 2026-09-27 08:27:33 UTC |
| Source: | https://github.com/evandeilton/gkwdist |
The gkwdist package provides a comprehensive, high-performance
implementation of the five-parameter Generalized Kumaraswamy (GKw)
distribution and its seven nested sub-families for modeling bounded
continuous data on the unit interval . All distribution and
likelihood functions are implemented in C++ via
RcppArmadillo for maximum computational efficiency.
The Generalized Kumaraswamy distribution, proposed by Carrasco, Ferrari and Cordeiro (2010), extends the Kumaraswamy distribution (Jones, 2009) by incorporating three additional shape parameters. This generalization provides remarkable flexibility in accommodating various density shapes including unimodality, asymmetry, J-shapes, inverted J-shapes, U-shapes, bathtub shapes, and heavy or light tails.
That flexibility stops short of bimodality. Across roughly 330,000 parameter
vectors spanning in each of the five parameters, no
density with two interior modes was found: every shape was monotone,
unimodal, or U-shaped. A second peak arises only as a divergence at
or — see the boundary limits documented in
dgkw — never as a second interior hump. Data with two
separated interior modes calls for a mixture, not a larger member of this
family.
The probability density function (PDF) of the GKw distribution with
parameters
(all positive) is:
for , where
is the beta function.
The cumulative distribution function (CDF) is:
where denotes the regularized incomplete beta function ratio.
The GKw distribution nests seven important sub-models:
4 parameters:
. Set in GKw.
4 parameters:
. Set in GKw.
3 parameters:
. Set in GKw.
Has closed-form quantile function.
3 parameters:
. Set in GKw.
Also known as Beta-Power distribution.
2 parameters: .
Set , and in GKw.
Has closed-form CDF and quantile function.
2 parameters: .
Set in GKw. Classical beta
distribution with shape1 = gamma, shape2 = delta + 1.
0 parameters. Set and in GKw. Note that , not
, is the neutral value: enters the density
through and .
The package provides the standard R distribution function API for all
seven distributions. Each distribution has four core functions with
prefix d, p, q, r:
Generalized Kumaraswamy (GKw):
dgkw: Density function
pgkw: Distribution function (CDF)
qgkw: Quantile function (inverse CDF)
rgkw: Random generation
Beta-Kumaraswamy (BKw):
dbkw, pbkw, qbkw, rbkw
Kumaraswamy-Kumaraswamy (KKw):
dkkw, pkkw, qkkw, rkkw
Exponentiated Kumaraswamy (EKw):
dekw, pekw, qekw, rekw
McDonald (Mc):
dmc, pmc, qmc, rmc
Kumaraswamy (Kw):
dkw, pkw, qkw, rkw
Beta:
dbeta_, pbeta_, qbeta_, rbeta_
All distribution functions are implemented in C++ for optimal performance.
High-performance analytical log-likelihood, gradient, and Hessian functions
are provided for maximum likelihood estimation. These functions return
negative values to facilitate direct use with optimization routines
like optim, which perform minimization by default.
Function signature: function(par, data) where par is a numeric
vector of parameters and data is the observed sample.
ll*Negative log-likelihood:
gr*Negative gradient (negative score vector):
hs*Negative Hessian matrix:
Available for all distributions:
These analytical derivatives are exact (up to floating-point precision) and provide substantial performance gains over numerical approximations.
gkwgetstartvalues: Compute starting values for
optimization using method of moments or quantile matching
The GKw distribution family is particularly suitable for modeling:
Proportions and rates: Bounded continuous data in
Percentages: Economic indices, market shares, conversion rates
Fractions: Parts of a whole, concentration measures
Scores and indices: Normalized measurements, standardized tests
Reliability data: Component lifetimes on bounded domains
Hydrological phenomena: Reservoir levels, soil moisture content
Financial ratios: Debt-to-equity, current ratio, profit margins
Quality metrics: Defect rates, efficiency scores, purity levels
Biostatistics: Survival probabilities, dose-response curves
Compared to the classical Beta distribution, the GKw family offers:
Greater flexibility in density shapes (U-shaped, bathtub, J and reverse J)
Better accommodation of asymmetry and tail behavior
Closed-form CDF and quantile for some sub-models (Kw, EKw, KKw)
Computational efficiency via C++ implementation
Easy parameter interpretation through nested structure
Superior performance for extreme parameter values
All functions are implemented in C++ using RcppArmadillo, providing:
10-100× speedup over pure R implementations
Linear scaling with sample size
Optimized memory allocation
Numerical stability for extreme parameter values
Efficient vectorized operations
Typical benchmarks on modern hardware:
Density evaluation: evaluations per second
Log-likelihood: observations in ms
Gradient computation: × slower than log-likelihood
Recommended strategy for choosing among distributions:
Exploratory Analysis: Examine histograms, kernel density estimates, and summary statistics of your data.
Start Simple: Fit Beta and Kumaraswamy distributions
(2 parameters). Use optim with method = "BFGS"
and analytical gradients.
Diagnostic Checking: Assess fit quality using Q-Q plots, probability plots, and goodness-of-fit tests (e.g., Kolmogorov-Smirnov).
Progressive Complexity: If simple models inadequate, try 3-parameter models (EKw or Mc), then 4-parameter models (BKw or KKw).
Information Criteria: Use AIC, BIC, or AICc to balance goodness-of-fit and model parsimony. Lower values indicate better models.
Nested Testing: Perform likelihood ratio tests when comparing nested models (e.g., Kw vs. EKw).
Cross-Validation: Validate final model on held-out data or via bootstrap procedures.
Residual Analysis: Examine probability integral transform residuals for uniformity and independence.
Maximum likelihood estimation is performed using numerical optimization:
Obtain starting values via gkwgetstartvalues or
manual specification based on sample moments
Minimize negative log-likelihood using optim
with method = "BFGS" or "L-BFGS-B"
Provide analytical gradient via gr argument for faster
convergence and improved accuracy
Set hessian = TRUE to obtain observed information matrix
Compute standard errors as sqrt(diag(solve(hessian)))
Construct confidence intervals using normal approximation or profile likelihood
Perform hypothesis tests using Wald, score, or likelihood ratio statistics
For large samples (), consider using method = "L-BFGS-B"
with box constraints to prevent parameter estimates from drifting to
boundary values or becoming numerically unstable.
Lopes, J. E. [email protected] ORCID: 0009-0007-5887-4084
LEG - Laboratory of Statistics and Geoinformation
PPGMNE - Graduate Program in Numerical Methods in Engineering
Federal University of Paraná (UFPR), Brazil
Carrasco, J. M. F., Ferrari, S. L. P., and Cordeiro, G. M. (2010). A new generalized Kumaraswamy distribution. arXiv preprint arXiv:1004.0911. doi:10.48550/arXiv.1004.0911
Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with some tractability advantages. Statistical Methodology, 6(1), 70-81. doi:10.1016/j.stamet.2008.04.001
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Cordeiro, G. M., and de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
McDonald, J. B. (1984). Some generalized functions for the size distribution of income. Econometrica, 52(3), 647-663. doi:10.2307/1913469
Eddelbuettel, D., and Francois, R. (2011). Rcpp: Seamless R and C++ Integration. Journal of Statistical Software, 40(8), 1-18. doi:10.18637/jss.v040.i08
Eddelbuettel, D., and Sanderson, C. (2014). RcppArmadillo: Accelerating R with high-performance C++ linear algebra. Computational Statistics & Data Analysis, 71, 1054-1063. doi:10.1016/j.csda.2013.02.005
Beta for the standard beta distribution,
optim for numerical optimization,
dbeta for beta distribution functions
x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) ## Every sub-family is GKw with some parameters fixed all.equal(dkw(x, alpha = 2, beta = 3), dgkw(x, alpha = 2, beta = 3)) all.equal(dekw(x, 2, 3, 1.2), dgkw(x, 2, 3, gamma = 1, delta = 0, lambda = 1.2)) ## Maximum likelihood with the analytic gradient set.seed(123) y <- rkw(300, alpha = 2, beta = 3) optim(c(alpha = 1, beta = 1), llkw, grkw, data = y, method = "L-BFGS-B", lower = 1e-04)$parx <- c(0.1, 0.3, 0.5, 0.7, 0.9) dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) ## Every sub-family is GKw with some parameters fixed all.equal(dkw(x, alpha = 2, beta = 3), dgkw(x, alpha = 2, beta = 3)) all.equal(dekw(x, 2, 3, 1.2), dgkw(x, 2, 3, gamma = 1, delta = 0, lambda = 1.2)) ## Maximum likelihood with the analytic gradient set.seed(123) y <- rkw(300, alpha = 2, beta = 3) optim(c(alpha = 1, beta = 1), llkw, grkw, data = y, method = "L-BFGS-B", lower = 1e-04)$par
Computes the probability density function (PDF) for the standard Beta
distribution, using a parameterization common in generalized distribution
families. The distribution is parameterized by gamma () and
delta (), corresponding to the standard Beta distribution
with shape parameters shape1 = gamma and shape2 = delta + 1.
The distribution is defined on the interval (0, 1).
dbeta_(x, gamma = 1, delta = 0, log = FALSE)dbeta_(x, gamma = 1, delta = 0, log = FALSE)
x |
Vector of quantiles (values between 0 and 1). |
gamma |
First shape parameter ( |
delta |
Second shape parameter is |
log |
Logical; if |
The probability density function (PDF) calculated by this function corresponds
to a standard Beta distribution :
for , where is the Beta function
(beta).
This specific parameterization arises as a special case of the five-parameter
Generalized Kumaraswamy (GKw) distribution (dgkw) obtained
by setting the parameters , , and .
It is therefore equivalent to the McDonald (Mc)/Beta Power distribution
(dmc) with .
Note the difference in the second parameter compared to dbeta,
where dbeta(x, shape1, shape2) uses shape2 directly. Here,
shape1 = gamma and shape2 = delta + 1.
A vector of density values () or log-density values
(). The length of the result is determined by the recycling
rule applied to the arguments (x, gamma, delta).
Returns 0 (or -Inf if log = TRUE) for x
strictly outside the interval [0, 1]. At the closed boundaries
x = 0 and x = 1 the limiting density is returned rather than
0, matching dbeta with
shape1 = gamma and shape2 = delta + 1; depending on the
parameters that limit is 0, a finite positive value, or Inf.
An out-of-bound or missing parameter is an error, not a return value: the
wrapper stops with a message naming the parameter. An infinite parameter is
not currently intercepted there and reaches the C++ layer, which treats it
as invalid.
Lopes, J. E.
Johnson, N. L., Kotz, S., & Balakrishnan, N. (1995). Continuous Univariate Distributions, Volume 2 (2nd ed.). Wiley.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
dbeta (standard R implementation),
dgkw (parent distribution density),
dmc (McDonald/Beta Power density),
pbeta_, qbeta_, rbeta_.
Other density functions:
dbkw(),
dekw(),
dgkw(),
dkkw(),
dkw(),
dmc()
x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dbeta_(x, gamma = 2, delta = 3) dbeta_(x, gamma = 2, delta = 3, log = TRUE) ## The package's Beta(gamma, delta) is stats::dbeta with shapes gamma, delta + 1 all.equal(dbeta_(x, 2, 3), stats::dbeta(x, 2, 4)) ## The density integrates to one integrate(dbeta_, 0, 1, gamma = 2, delta = 3, rel.tol = 1e-10) curve(dbeta_(x, gamma = 2, delta = 3), from = 0, to = 1, ylab = "density")x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dbeta_(x, gamma = 2, delta = 3) dbeta_(x, gamma = 2, delta = 3, log = TRUE) ## The package's Beta(gamma, delta) is stats::dbeta with shapes gamma, delta + 1 all.equal(dbeta_(x, 2, 3), stats::dbeta(x, 2, 4)) ## The density integrates to one integrate(dbeta_, 0, 1, gamma = 2, delta = 3, rel.tol = 1e-10) curve(dbeta_(x, gamma = 2, delta = 3), from = 0, to = 1, ylab = "density")
Computes the probability density function (PDF) for the Beta-Kumaraswamy
(BKw) distribution with parameters alpha (), beta
(), gamma (), and delta ().
This distribution is defined on the interval (0, 1).
dbkw(x, alpha = 1, beta = 1, gamma = 1, delta = 0, log = FALSE)dbkw(x, alpha = 1, beta = 1, gamma = 1, delta = 0, log = FALSE)
x |
Vector of quantiles (values between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
gamma |
Shape parameter |
delta |
Shape parameter |
log |
Logical; if |
The probability density function (PDF) of the Beta-Kumaraswamy (BKw) distribution is given by:
for , where is the Beta function
(beta).
The BKw distribution is a special case of the five-parameter
Generalized Kumaraswamy (GKw) distribution (dgkw) obtained
by setting the parameter .
Numerical evaluation is performed using algorithms similar to those for dgkw,
ensuring stability.
A vector of density values () or log-density values
(). The length of the result is determined by the recycling
rule applied to the arguments (x, alpha, beta,
gamma, delta). Returns 0 (or -Inf if
log = TRUE) for x strictly outside the interval [0, 1]. At the
closed boundaries x = 0 and x = 1 the limiting density is
returned rather than 0, following the convention of base R's density
functions (compare dbeta); depending on the parameters
that limit is 0, a finite positive value, or Inf.
An out-of-bound or missing parameter is an error, not a return value: the
wrapper stops with a message naming the parameter. An infinite parameter is
not currently intercepted there and reaches the C++ layer, which treats it
as invalid.
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
dgkw (parent distribution density),
pbkw, qbkw, rbkw (other BKw functions),
Other density functions:
dbeta_(),
dekw(),
dgkw(),
dkkw(),
dkw(),
dmc()
x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dbkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) dbkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, log = TRUE) ## BKw is GKw with lambda = 1 all.equal(dbkw(x, 2, 3, 1.5, 0.5), dgkw(x, 2, 3, 1.5, 0.5, lambda = 1)) ## The density integrates to one integrate(dbkw, 0, 1, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, rel.tol = 1e-10) curve(dbkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5), from = 0, to = 1, ylab = "density")x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dbkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) dbkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, log = TRUE) ## BKw is GKw with lambda = 1 all.equal(dbkw(x, 2, 3, 1.5, 0.5), dgkw(x, 2, 3, 1.5, 0.5, lambda = 1)) ## The density integrates to one integrate(dbkw, 0, 1, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, rel.tol = 1e-10) curve(dbkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5), from = 0, to = 1, ylab = "density")
Computes the probability density function (PDF) for the Exponentiated
Kumaraswamy (EKw) distribution with parameters alpha (),
beta (), and lambda ().
This distribution is defined on the interval (0, 1).
dekw(x, alpha = 1, beta = 1, lambda = 1, log = FALSE)dekw(x, alpha = 1, beta = 1, lambda = 1, log = FALSE)
x |
Vector of quantiles (values between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
lambda |
Shape parameter |
log |
Logical; if |
The probability density function (PDF) of the Exponentiated Kumaraswamy (EKw) distribution is given by:
for .
The EKw distribution is a special case of the five-parameter
Generalized Kumaraswamy (GKw) distribution (dgkw) obtained
by setting the parameters and .
When , the EKw distribution reduces to the standard
Kumaraswamy distribution.
A vector of density values () or log-density values
(). The length of the result is determined by the recycling
rule applied to the arguments (x, alpha, beta,
lambda). Returns 0 (or -Inf if
log = TRUE) for x strictly outside the interval [0, 1]. At the
closed boundaries x = 0 and x = 1 the limiting density is
returned rather than 0, following the convention of base R's density
functions (compare dbeta); depending on the parameters
that limit is 0, a finite positive value, or Inf.
An out-of-bound or missing parameter is an error, not a return value: the
wrapper stops with a message naming the parameter. An infinite parameter is
not currently intercepted there and reaches the C++ layer, which treats it
as invalid.
Lopes, J. E.
Nadarajah, S., Cordeiro, G. M., & Ortega, E. M. (2012). The exponentiated Kumaraswamy distribution. Journal of the Franklin Institute, 349(3),
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
dgkw (parent distribution density),
pekw, qekw, rekw (other EKw functions),
Other density functions:
dbeta_(),
dbkw(),
dgkw(),
dkkw(),
dkw(),
dmc()
x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dekw(x, alpha = 2, beta = 3, lambda = 1.2) dekw(x, alpha = 2, beta = 3, lambda = 1.2, log = TRUE) ## EKw is GKw with gamma = 1, delta = 0 all.equal(dekw(x, 2, 3, 1.2), dgkw(x, 2, 3, gamma = 1, delta = 0, lambda = 1.2)) ## The density integrates to one integrate(dekw, 0, 1, alpha = 2, beta = 3, lambda = 1.2, rel.tol = 1e-10) curve(dekw(x, alpha = 2, beta = 3, lambda = 1.2), from = 0, to = 1, ylab = "density")x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dekw(x, alpha = 2, beta = 3, lambda = 1.2) dekw(x, alpha = 2, beta = 3, lambda = 1.2, log = TRUE) ## EKw is GKw with gamma = 1, delta = 0 all.equal(dekw(x, 2, 3, 1.2), dgkw(x, 2, 3, gamma = 1, delta = 0, lambda = 1.2)) ## The density integrates to one integrate(dekw, 0, 1, alpha = 2, beta = 3, lambda = 1.2, rel.tol = 1e-10) curve(dekw(x, alpha = 2, beta = 3, lambda = 1.2), from = 0, to = 1, ylab = "density")
Computes the probability density function (PDF) for the five-parameter Generalized Kumaraswamy (GKw) distribution, defined on the interval (0, 1).
dgkw(x, alpha = 1, beta = 1, gamma = 1, delta = 0, lambda = 1, log = FALSE)dgkw(x, alpha = 1, beta = 1, gamma = 1, delta = 0, lambda = 1, log = FALSE)
x |
Vector of quantiles (values between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
gamma |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
log |
Logical; if |
The probability density function of the Generalized Kumaraswamy (GKw)
distribution with parameters alpha (), beta
(), gamma (), delta (), and
lambda () is given by:
for , where is the Beta function
beta.
This distribution was proposed by Carrasco, Ferrari & Cordeiro (2010) and includes several other distributions as special cases:
Kumaraswamy (Kw): gamma = 1, delta = 0, lambda = 1
Exponentiated Kumaraswamy (EKw): gamma = 1, delta = 0
Beta-Kumaraswamy (BKw): lambda = 1
Generalized Beta type 1 (GB1 - implies McDonald): alpha = 1, beta = 1
Beta distribution: alpha = 1, beta = 1, lambda = 1
The function includes checks for valid parameters and input values x.
It uses numerical stabilization for x close to 0 or 1.
A vector of density values () or log-density values
(). The length of the result is determined by the recycling
rule applied to the arguments (x, alpha, beta,
gamma, delta, lambda). Returns 0 (or -Inf
if log = TRUE) for x strictly outside the interval [0, 1]. At
the closed boundaries x = 0 and x = 1 the limiting density is
returned rather than 0, following the convention of base R's density
functions (compare dbeta); depending on the parameters
that limit is 0, a finite positive value, or Inf.
An out-of-bound or missing parameter is an error, not a return value: the
wrapper stops with a message naming the parameter. An infinite parameter
is not currently intercepted there and reaches the C++ layer, which
treats it as invalid.
Lopes, J. E.
Carrasco, J. M. F., Ferrari, S. L. P., & Cordeiro, G. M. (2010). A new generalized Kumaraswamy distribution. arXiv preprint arXiv:1004.0911. doi:10.48550/arXiv.1004.0911
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
pgkw, qgkw, rgkw,
dbeta, integrate
Other density functions:
dbeta_(),
dbkw(),
dekw(),
dkkw(),
dkw(),
dmc()
x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, log = TRUE) ## Kumaraswamy is GKw with gamma = 1, delta = 0, lambda = 1 (the defaults) all.equal(dgkw(x, alpha = 2, beta = 3), dkw(x, alpha = 2, beta = 3)) ## Beta(gamma, delta + 1) is GKw with alpha = beta = lambda = 1 all.equal(dgkw(x, gamma = 2, delta = 3), stats::dbeta(x, 2, 4)) ## The density integrates to one integrate(dgkw, 0, 1, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, rel.tol = 1e-10) curve(dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2), from = 0, to = 1, ylab = "density")x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, log = TRUE) ## Kumaraswamy is GKw with gamma = 1, delta = 0, lambda = 1 (the defaults) all.equal(dgkw(x, alpha = 2, beta = 3), dkw(x, alpha = 2, beta = 3)) ## Beta(gamma, delta + 1) is GKw with alpha = beta = lambda = 1 all.equal(dgkw(x, gamma = 2, delta = 3), stats::dbeta(x, 2, 4)) ## The density integrates to one integrate(dgkw, 0, 1, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, rel.tol = 1e-10) curve(dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2), from = 0, to = 1, ylab = "density")
Computes the probability density function (PDF) for the Kumaraswamy-Kumaraswamy
(KKw) distribution with parameters alpha (), beta
(), delta (), and lambda ().
This distribution is defined on the interval (0, 1).
dkkw(x, alpha = 1, beta = 1, delta = 0, lambda = 1, log = FALSE)dkkw(x, alpha = 1, beta = 1, delta = 0, lambda = 1, log = FALSE)
x |
Vector of quantiles (values between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
log |
Logical; if |
The Kumaraswamy-Kumaraswamy (KKw) distribution is a special case of the
five-parameter Generalized Kumaraswamy distribution (dgkw)
obtained by setting the parameter .
The probability density function is given by:
for . Note that corresponds to the Beta function
term when .
Numerical evaluation follows similar stability considerations as dgkw.
A vector of density values () or log-density values
(). The length of the result is determined by the recycling
rule applied to the arguments (x, alpha, beta,
delta, lambda). Returns 0 (or -Inf if
log = TRUE) for x strictly outside the interval [0, 1]. At the
closed boundaries x = 0 and x = 1 the limiting density is
returned rather than 0, following the convention of base R's density
functions (compare dbeta); depending on the parameters
that limit is 0, a finite positive value, or Inf.
An out-of-bound or missing parameter is an error, not a return value: the
wrapper stops with a message naming the parameter. An infinite parameter is
not currently intercepted there and reaches the C++ layer, which treats it
as invalid.
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
dgkw (parent distribution density),
pkkw, qkkw, rkkw,
dbeta
Other density functions:
dbeta_(),
dbkw(),
dekw(),
dgkw(),
dkw(),
dmc()
x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dkkw(x, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) dkkw(x, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, log = TRUE) ## KKw is GKw with gamma = 1 all.equal(dkkw(x, 2, 3, 0.5, 1.2), dgkw(x, 2, 3, gamma = 1, delta = 0.5, lambda = 1.2)) ## The density integrates to one integrate(dkkw, 0, 1, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, rel.tol = 1e-10) curve(dkkw(x, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2), from = 0, to = 1, ylab = "density")x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dkkw(x, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) dkkw(x, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, log = TRUE) ## KKw is GKw with gamma = 1 all.equal(dkkw(x, 2, 3, 0.5, 1.2), dgkw(x, 2, 3, gamma = 1, delta = 0.5, lambda = 1.2)) ## The density integrates to one integrate(dkkw, 0, 1, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, rel.tol = 1e-10) curve(dkkw(x, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2), from = 0, to = 1, ylab = "density")
Computes the probability density function (PDF) for the two-parameter
Kumaraswamy (Kw) distribution with shape parameters alpha ()
and beta (). This distribution is defined on the interval (0, 1).
dkw(x, alpha = 1, beta = 1, log = FALSE)dkw(x, alpha = 1, beta = 1, log = FALSE)
x |
Vector of quantiles (values between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
log |
Logical; if |
The probability density function (PDF) of the Kumaraswamy (Kw) distribution is given by:
for , , and .
The Kumaraswamy distribution is identical to the Generalized Kumaraswamy (GKw)
distribution (dgkw) with parameters ,
, and . It is also a special case of the
Exponentiated Kumaraswamy (dekw) with , and
the Kumaraswamy-Kumaraswamy (dkkw) with
and .
A vector of density values () or log-density values
(). The length of the result is determined by the recycling
rule applied to the arguments (x, alpha, beta).
Returns 0 (or -Inf if log = TRUE) for x
strictly outside the interval [0, 1]. At the closed boundaries
x = 0 and x = 1 the limiting density is returned rather than
0, following the convention of base R's density functions (compare
dbeta); depending on the parameters that limit is
0, a finite positive value, or Inf.
An out-of-bound or missing parameter is an error, not a return value: the
wrapper stops with a message naming the parameter. An infinite parameter is
not currently intercepted there and reaches the C++ layer, which treats it
as invalid.
Lopes, J. E.
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with some tractability advantages. Statistical Methodology, 6(1), 70-81. doi:10.1016/j.stamet.2008.04.001
dgkw (parent distribution density),
dekw, dkkw,
pkw, qkw, rkw (other Kw functions),
dbeta
Other density functions:
dbeta_(),
dbkw(),
dekw(),
dgkw(),
dkkw(),
dmc()
x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dkw(x, alpha = 2, beta = 3) dkw(x, alpha = 2, beta = 3, log = TRUE) ## Closed form: alpha * beta * x^(alpha - 1) * (1 - x^alpha)^(beta - 1) all.equal(dkw(x, 2, 3), 2 * 3 * x * (1 - x^2)^2) ## The density integrates to one integrate(dkw, 0, 1, alpha = 2, beta = 3, rel.tol = 1e-10) curve(dkw(x, alpha = 2, beta = 3), from = 0, to = 1, ylab = "density")x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dkw(x, alpha = 2, beta = 3) dkw(x, alpha = 2, beta = 3, log = TRUE) ## Closed form: alpha * beta * x^(alpha - 1) * (1 - x^alpha)^(beta - 1) all.equal(dkw(x, 2, 3), 2 * 3 * x * (1 - x^2)^2) ## The density integrates to one integrate(dkw, 0, 1, alpha = 2, beta = 3, rel.tol = 1e-10) curve(dkw(x, alpha = 2, beta = 3), from = 0, to = 1, ylab = "density")
Computes the probability density function (PDF) for the McDonald (Mc)
distribution (also previously referred to as Beta Power) with parameters
gamma (), delta (), and lambda
(). This distribution is defined on the interval (0, 1).
dmc(x, gamma = 1, delta = 0, lambda = 1, log = FALSE)dmc(x, gamma = 1, delta = 0, lambda = 1, log = FALSE)
x |
Vector of quantiles (values between 0 and 1). |
gamma |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
log |
Logical; if |
The probability density function (PDF) of the McDonald (Mc) distribution is given by:
for , where is the Beta function
(beta).
The Mc distribution is a special case of the five-parameter
Generalized Kumaraswamy (GKw) distribution (dgkw) obtained
by setting the parameters and .
It was introduced by McDonald (1984) and is related to the Generalized Beta
distribution of the first kind (GB1). When , it simplifies
to the standard Beta distribution with parameters and
.
A vector of density values () or log-density values
(). The length of the result is determined by the recycling
rule applied to the arguments (x, gamma, delta,
lambda). Returns 0 (or -Inf if
log = TRUE) for x strictly outside the interval [0, 1]. At the
closed boundaries x = 0 and x = 1 the limiting density is
returned rather than 0, following the convention of base R's density
functions (compare dbeta); depending on the parameters
that limit is 0, a finite positive value, or Inf.
An out-of-bound or missing parameter is an error, not a return value: the
wrapper stops with a message naming the parameter. An infinite parameter is
not currently intercepted there and reaches the C++ layer, which treats it
as invalid.
Lopes, J. E.
McDonald, J. B. (1984). Some generalized functions for the size distribution of income. Econometrica, 52(3), 647-663. doi:10.2307/1913469
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
dgkw (parent distribution density),
pmc, qmc, rmc (other Mc functions),
dbeta
Other density functions:
dbeta_(),
dbkw(),
dekw(),
dgkw(),
dkkw(),
dkw()
x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dmc(x, gamma = 0.5, delta = 5, lambda = 3) dmc(x, gamma = 0.5, delta = 5, lambda = 3, log = TRUE) ## Mc is GKw with alpha = beta = 1 all.equal(dmc(x, 0.5, 5, 3), dgkw(x, 1, 1, 0.5, 5, 3)) ## The density integrates to one integrate(dmc, 0, 1, gamma = 0.5, delta = 5, lambda = 3, rel.tol = 1e-10) curve(dmc(x, gamma = 0.5, delta = 5, lambda = 3), from = 0, to = 1, ylab = "density")x <- c(0.1, 0.3, 0.5, 0.7, 0.9) dmc(x, gamma = 0.5, delta = 5, lambda = 3) dmc(x, gamma = 0.5, delta = 5, lambda = 3, log = TRUE) ## Mc is GKw with alpha = beta = 1 all.equal(dmc(x, 0.5, 5, 3), dgkw(x, 1, 1, 0.5, 5, 3)) ## The density integrates to one integrate(dmc, 0, 1, gamma = 0.5, delta = 5, lambda = 3, rel.tol = 1e-10) curve(dmc(x, gamma = 0.5, delta = 5, lambda = 3), from = 0, to = 1, ylab = "density")
Estimates parameters for various distribution families from the Generalized Kumaraswamy family using the method of moments. The implementation is optimized for numerical stability and computational efficiency through Nelder-Mead optimization and adaptive numerical integration.
gkwgetstartvalues(x, family = "gkw", n_starts = 5L)gkwgetstartvalues(x, family = "gkw", n_starts = 5L)
x |
Numeric vector of observations. All values must be in the open interval (0,1).
Values outside it – including exact 0 and exact 1 – are truncated to the interval
so that a single boundary observation does not abort a fit, and a warning naming the
number of truncated observations and their observed range is issued. Truncation
shifts every sample moment and therefore every estimate returned, so treat the
warning as a signal to check the scale of the data rather than as noise: values such
as 5 or -3 usually mean a percentage or 0-100 scale that has to be rescaled first.
|
family |
Character string specifying the distribution family. Valid options are:
|
n_starts |
Integer specifying the number of different initial parameter values
to try during optimization. Every starting point is optimized and the candidate with
the smallest objective is returned, so more starting points can only improve the fit,
at a cost that grows linearly in |
The function uses the method of moments to estimate distribution parameters by minimizing the weighted sum of squared relative errors between theoretical and sample moments (orders 1 through 5). The optimization employs the Nelder-Mead simplex algorithm, which is derivative-free and particularly robust for this problem.
Key implementation features: logarithmic calculations for numerical stability, adaptive numerical integration using Simpson's rule with fallback to trapezoidal rule, multiple starting points to avoid local minima, decreasing weights for higher-order moments (1.0, 0.8, 0.6, 0.4, 0.2), and automatic parameter constraint enforcement.
Multiple starts: the grid of starting points is built from four fixed, family-specific
points – one of them derived from the sample moments – plus n_starts - 4
further points drawn over the family's parameter box. Nelder-Mead is run from every
point in the grid, each result is clipped to the parameter box, and the clipped
candidate with the smallest objective is returned. Because the candidate set grows
with n_starts, the returned objective is non-increasing in n_starts.
Determinism: the extra starting points are drawn from a generator with a fixed
internal seed, deliberately not from R's random number stream. The function is
therefore deterministic – two calls with the same x, family and
n_starts return the same vector, so a fit seeded by these values is
reproducible without any further precaution. Two consequences are worth stating
explicitly: set.seed has no effect on gkwgetstartvalues,
and the function neither reads nor advances .Random.seed, so it cannot
perturb simulations running alongside it. To widen the search, raise
n_starts rather than looking for a seed argument.
Parameter Constraints: All parameters are constrained to positive values. Additionally, family-specific constraints are enforced: alpha and beta in (0.1, 50.0), gamma in (0.1, 10.0) for GKw-related families or (0.1, 50.0) for Beta, delta in (0.01, 10.0), and lambda in (0.1, 20.0).
The function will issue warnings for empty input vectors, observations outside the open interval (0,1) (truncated to it), sample sizes less than 10 (unreliable estimation), or failure to find valid parameter estimates (returns defaults).
Named numeric vector containing the estimated parameters for the specified distribution family. Parameter names correspond to the distribution specification. If estimation fails, returns a vector of NA values with appropriate parameter names.
Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with some tractability advantages. Statistical Methodology, 6(1), 70-81. doi:10.1016/j.stamet.2008.04.001
llgkw, llbkw, llkkw,
llekw, llmc, llkw,
llbeta (the objectives these values are meant to seed),
optim
# Generate sample data from a Beta distribution. set.seed() here makes the # SAMPLE reproducible; gkwgetstartvalues() itself is deterministic and is # unaffected by the seed (see the Determinism note in Details). set.seed(123) x <- rbeta(100, shape1 = 2, shape2 = 3) # Estimate Beta parameters params_beta <- gkwgetstartvalues(x, family = "beta") print(params_beta) # Estimate Kumaraswamy parameters params_kw <- gkwgetstartvalues(x, family = "kw") print(params_kw) # Estimate GKw parameters with more starting points params_gkw <- gkwgetstartvalues(x, family = "gkw", n_starts = 10) print(params_gkw) # Deterministic: the seed in force does not change the answer, and the # function does not consume draws from R's stream. set.seed(1) identical(gkwgetstartvalues(x, family = "kw"), params_kw) set.seed(9999) identical(gkwgetstartvalues(x, family = "kw"), params_kw) before <- .Random.seed invisible(gkwgetstartvalues(x, family = "kw")) identical(before, .Random.seed)# Generate sample data from a Beta distribution. set.seed() here makes the # SAMPLE reproducible; gkwgetstartvalues() itself is deterministic and is # unaffected by the seed (see the Determinism note in Details). set.seed(123) x <- rbeta(100, shape1 = 2, shape2 = 3) # Estimate Beta parameters params_beta <- gkwgetstartvalues(x, family = "beta") print(params_beta) # Estimate Kumaraswamy parameters params_kw <- gkwgetstartvalues(x, family = "kw") print(params_kw) # Estimate GKw parameters with more starting points params_gkw <- gkwgetstartvalues(x, family = "gkw", n_starts = 10) print(params_gkw) # Deterministic: the seed in force does not change the answer, and the # function does not consume draws from R's stream. set.seed(1) identical(gkwgetstartvalues(x, family = "kw"), params_kw) set.seed(9999) identical(gkwgetstartvalues(x, family = "kw"), params_kw) before <- .Random.seed invisible(gkwgetstartvalues(x, family = "kw")) identical(before, .Random.seed)
Computes the gradient vector (vector of first partial derivatives) of the
negative log-likelihood function for the standard Beta distribution, using
a parameterization common in generalized distribution families. The
distribution is parameterized by gamma () and delta
(), corresponding to the standard Beta distribution with shape
parameters shape1 = gamma and shape2 = delta + 1.
The gradient is useful for optimization algorithms.
grbeta(par, data)grbeta(par, data)
par |
A numeric vector of length 2 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
This function calculates the gradient of the negative log-likelihood for a
Beta distribution with parameters shape1 = gamma () and
shape2 = delta + 1 (). The components of the gradient
vector () are:
where is the digamma function (digamma).
These formulas represent the derivatives of , consistent with
minimizing the negative log-likelihood. They correspond to the relevant components
of the general GKw gradient (grgkw) evaluated at .
Note the parameterization: the standard Beta shape parameters are and .
Returns a numeric vector of length 2 containing the partial derivatives
of the negative log-likelihood function with
respect to each parameter: .
Returns a vector of NaN if any parameter values are invalid according
to their constraints, or if any value in data is not in the
interval (0, 1).
Lopes, J. E.
Johnson, N. L., Kotz, S., & Balakrishnan, N. (1995). Continuous Univariate Distributions, Volume 2 (2nd ed.). Wiley.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
(Note: Specific gradient formulas might be derived or sourced from additional references).
grgkw, grmc (related gradients),
llbeta (negative log-likelihood function),
hsbeta (Hessian),
dbeta_, pbeta_, qbeta_, rbeta_,
optim,
grad (for numerical gradient comparison),
digamma.
Other gradient functions:
grbkw(),
grekw(),
grgkw(),
grkkw(),
grkw(),
grmc()
set.seed(123) x <- rbeta_(200, gamma = 2, delta = 3) par <- c(gamma = 2, delta = 3) ## Gradient of the negative log-likelihood llbeta(), not of the log-likelihood g <- grbeta(par, x) g ## A small step against the gradient lowers llbeta() llbeta(par - 1e-4 * g, x) < llbeta(par, x) ## Agrees with a numerical derivative of llbeta() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llbeta, par, data = x), tolerance = 1e-6)set.seed(123) x <- rbeta_(200, gamma = 2, delta = 3) par <- c(gamma = 2, delta = 3) ## Gradient of the negative log-likelihood llbeta(), not of the log-likelihood g <- grbeta(par, x) g ## A small step against the gradient lowers llbeta() llbeta(par - 1e-4 * g, x) < llbeta(par, x) ## Agrees with a numerical derivative of llbeta() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llbeta, par, data = x), tolerance = 1e-6)
Computes the gradient vector (vector of first partial derivatives) of the
negative log-likelihood function for the Beta-Kumaraswamy (BKw) distribution
with parameters alpha (), beta (),
gamma (), and delta (). This distribution
is the special case of the Generalized Kumaraswamy (GKw) distribution where
. The gradient is typically used in optimization algorithms
for maximum likelihood estimation.
grbkw(par, data)grbkw(par, data)
par |
A numeric vector of length 4 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The components of the gradient vector of the negative log-likelihood
() for the BKw () model are:
where:
is the digamma function (digamma).
These formulas represent the derivatives of , consistent with
minimizing the negative log-likelihood. They correspond to the general GKw
gradient (grgkw) components for
evaluated at . Note that the component for is omitted.
Numerical stability is maintained through careful implementation.
Returns a numeric vector of length 4 containing the partial derivatives
of the negative log-likelihood function with
respect to each parameter:
.
Returns a vector of NaN if any parameter values are invalid according
to their constraints, or if any value in data is not in the
interval (0, 1).
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
(Note: Specific gradient formulas might be derived or sourced from additional references).
grgkw (parent distribution gradient),
llbkw (negative log-likelihood for BKw),
hsbkw (Hessian for BKw),
dbkw (density for BKw),
optim,
grad (for numerical gradient comparison),
digamma.
Other gradient functions:
grbeta(),
grekw(),
grgkw(),
grkkw(),
grkw(),
grmc()
set.seed(123) x <- rbkw(200, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) ## Gradient of the negative log-likelihood llbkw(), not of the log-likelihood g <- grbkw(par, x) g ## A small step against the gradient lowers llbkw() llbkw(par - 1e-4 * g, x) < llbkw(par, x) ## Agrees with a numerical derivative of llbkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llbkw, par, data = x), tolerance = 1e-6)set.seed(123) x <- rbkw(200, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) ## Gradient of the negative log-likelihood llbkw(), not of the log-likelihood g <- grbkw(par, x) g ## A small step against the gradient lowers llbkw() llbkw(par - 1e-4 * g, x) < llbkw(par, x) ## Agrees with a numerical derivative of llbkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llbkw, par, data = x), tolerance = 1e-6)
Computes the gradient vector (vector of first partial derivatives) of the
negative log-likelihood function for the Exponentiated Kumaraswamy (EKw)
distribution with parameters alpha (), beta
(), and lambda (). This distribution is the
special case of the Generalized Kumaraswamy (GKw) distribution where
and . The gradient is useful for optimization.
grekw(par, data)grekw(par, data)
par |
A numeric vector of length 3 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The components of the gradient vector of the negative log-likelihood
() for the EKw ()
model are:
where:
These formulas represent the derivatives of , consistent with
minimizing the negative log-likelihood. They correspond to the relevant components
of the general GKw gradient (grgkw) evaluated at .
Returns a numeric vector of length 3 containing the partial derivatives
of the negative log-likelihood function with
respect to each parameter: .
Returns a vector of NaN if any parameter values are invalid according
to their constraints, or if any value in data is not in the
interval (0, 1).
Lopes, J. E.
Nadarajah, S., Cordeiro, G. M., & Ortega, E. M. (2012). The exponentiated Kumaraswamy distribution. Journal of the Franklin Institute, 349(3),
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
(Note: Specific gradient formulas might be derived or sourced from additional references).
grgkw (parent distribution gradient),
llekw (negative log-likelihood for EKw),
hsekw (Hessian for EKw),
dekw (density for EKw),
optim,
grad (for numerical gradient comparison).
Other gradient functions:
grbeta(),
grbkw(),
grgkw(),
grkkw(),
grkw(),
grmc()
set.seed(123) x <- rekw(200, alpha = 2, beta = 3, lambda = 1.2) par <- c(alpha = 2, beta = 3, lambda = 1.2) ## Gradient of the negative log-likelihood llekw(), not of the log-likelihood g <- grekw(par, x) g ## A small step against the gradient lowers llekw() llekw(par - 1e-4 * g, x) < llekw(par, x) ## Agrees with a numerical derivative of llekw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llekw, par, data = x), tolerance = 1e-6)set.seed(123) x <- rekw(200, alpha = 2, beta = 3, lambda = 1.2) par <- c(alpha = 2, beta = 3, lambda = 1.2) ## Gradient of the negative log-likelihood llekw(), not of the log-likelihood g <- grekw(par, x) g ## A small step against the gradient lowers llekw() llekw(par - 1e-4 * g, x) < llekw(par, x) ## Agrees with a numerical derivative of llekw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llekw, par, data = x), tolerance = 1e-6)
Computes the gradient vector (vector of partial derivatives) of the negative log-likelihood function for the five-parameter Generalized Kumaraswamy (GKw) distribution. This provides the analytical gradient, often used for efficient optimization via maximum likelihood estimation.
grgkw(par, data)grgkw(par, data)
par |
A numeric vector of length 5 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The components of the gradient vector of the negative log-likelihood
() are:
where:
is the digamma function (digamma).
Numerical stability is ensured through careful implementation, including checks for valid inputs and handling of intermediate calculations involving potentially small or large numbers, often leveraging the Armadillo C++ library for efficiency.
Returns a numeric vector of length 5 containing the partial derivatives
of the negative log-likelihood function with
respect to each parameter:
.
Returns a vector of NaN if any parameter values are invalid according
to their constraints, or if any value in data is not in the
interval (0, 1).
Lopes, J. E.
Carrasco, J. M. F., Ferrari, S. L. P., & Cordeiro, G. M. (2010). A new generalized Kumaraswamy distribution. arXiv preprint arXiv:1004.0911. doi:10.48550/arXiv.1004.0911
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
llgkw (negative log-likelihood),
hsgkw (Hessian matrix),
dgkw (density),
optim,
grad (for numerical gradient comparison),
digamma
Other gradient functions:
grbeta(),
grbkw(),
grekw(),
grkkw(),
grkw(),
grmc()
set.seed(123) x <- rgkw(200, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) ## Gradient of the negative log-likelihood llgkw(), not of the log-likelihood g <- grgkw(par, x) g ## A small step against the gradient lowers llgkw() llgkw(par - 1e-4 * g, x) < llgkw(par, x) ## Agrees with a numerical derivative of llgkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llgkw, par, data = x), tolerance = 1e-6)set.seed(123) x <- rgkw(200, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) ## Gradient of the negative log-likelihood llgkw(), not of the log-likelihood g <- grgkw(par, x) g ## A small step against the gradient lowers llgkw() llgkw(par - 1e-4 * g, x) < llgkw(par, x) ## Agrees with a numerical derivative of llgkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llgkw, par, data = x), tolerance = 1e-6)
Computes the gradient vector (vector of first partial derivatives) of the
negative log-likelihood function for the Kumaraswamy-Kumaraswamy (KKw)
distribution with parameters alpha (), beta
(), delta (), and lambda ().
This distribution is the special case of the Generalized Kumaraswamy (GKw)
distribution where . The gradient is typically used in
optimization algorithms for maximum likelihood estimation.
grkkw(par, data)grkkw(par, data)
par |
A numeric vector of length 4 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The components of the gradient vector of the negative log-likelihood
() for the KKw () model are:
where:
These formulas represent the derivatives of , consistent with
minimizing the negative log-likelihood. They correspond to the general GKw
gradient (grgkw) components for
evaluated at . Note that the component for is omitted.
Numerical stability is maintained through careful implementation.
Returns a numeric vector of length 4 containing the partial derivatives
of the negative log-likelihood function with
respect to each parameter:
.
Returns a vector of NaN if any parameter values are invalid according
to their constraints, or if any value in data is not in the
interval (0, 1).
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
grgkw (parent distribution gradient),
llkkw (negative log-likelihood for KKw),
hskkw (Hessian for KKw),
dkkw (density for KKw),
optim,
grad (for numerical gradient comparison).
Other gradient functions:
grbeta(),
grbkw(),
grekw(),
grgkw(),
grkw(),
grmc()
set.seed(123) x <- rkkw(200, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) ## Gradient of the negative log-likelihood llkkw(), not of the log-likelihood g <- grkkw(par, x) g ## A small step against the gradient lowers llkkw() llkkw(par - 1e-4 * g, x) < llkkw(par, x) ## Agrees with a numerical derivative of llkkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llkkw, par, data = x), tolerance = 1e-6)set.seed(123) x <- rkkw(200, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) ## Gradient of the negative log-likelihood llkkw(), not of the log-likelihood g <- grkkw(par, x) g ## A small step against the gradient lowers llkkw() llkkw(par - 1e-4 * g, x) < llkkw(par, x) ## Agrees with a numerical derivative of llkkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llkkw, par, data = x), tolerance = 1e-6)
Computes the gradient vector (vector of first partial derivatives) of the
negative log-likelihood function for the two-parameter Kumaraswamy (Kw)
distribution with parameters alpha () and beta
(). This provides the analytical gradient often used for efficient
optimization via maximum likelihood estimation.
grkw(par, data)grkw(par, data)
par |
A numeric vector of length 2 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The components of the gradient vector of the negative log-likelihood
() for the Kw model are:
where .
These formulas represent the derivatives of , consistent with
minimizing the negative log-likelihood. They correspond to the relevant components
of the general GKw gradient (grgkw) evaluated at .
Returns a numeric vector of length 2 containing the partial derivatives
of the negative log-likelihood function with
respect to each parameter: .
Returns a vector of NaN if any parameter values are invalid according
to their constraints, or if any value in data is not in the
interval (0, 1).
Lopes, J. E.
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with some tractability advantages. Statistical Methodology, 6(1), 70-81. doi:10.1016/j.stamet.2008.04.001
(Note: Specific gradient formulas might be derived or sourced from additional references).
grgkw (parent distribution gradient),
llkw (negative log-likelihood for Kw),
hskw (Hessian for Kw),
dkw (density for Kw),
optim,
grad (for numerical gradient comparison).
Other gradient functions:
grbeta(),
grbkw(),
grekw(),
grgkw(),
grkkw(),
grmc()
set.seed(123) x <- rkw(200, alpha = 2, beta = 3) par <- c(alpha = 2, beta = 3) ## Gradient of the negative log-likelihood llkw(), not of the log-likelihood g <- grkw(par, x) g ## A small step against the gradient lowers llkw() llkw(par - 1e-4 * g, x) < llkw(par, x) ## Agrees with a numerical derivative of llkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llkw, par, data = x), tolerance = 1e-6)set.seed(123) x <- rkw(200, alpha = 2, beta = 3) par <- c(alpha = 2, beta = 3) ## Gradient of the negative log-likelihood llkw(), not of the log-likelihood g <- grkw(par, x) g ## A small step against the gradient lowers llkw() llkw(par - 1e-4 * g, x) < llkw(par, x) ## Agrees with a numerical derivative of llkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llkw, par, data = x), tolerance = 1e-6)
Computes the gradient vector (vector of first partial derivatives) of the
negative log-likelihood function for the McDonald (Mc) distribution (also
known as Beta Power) with parameters gamma (), delta
(), and lambda (). This distribution is the
special case of the Generalized Kumaraswamy (GKw) distribution where
and . The gradient is useful for optimization.
grmc(par, data)grmc(par, data)
par |
A numeric vector of length 3 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The components of the gradient vector of the negative log-likelihood
() for the Mc ()
model are:
where is the digamma function (digamma).
These formulas represent the derivatives of , consistent with
minimizing the negative log-likelihood. They correspond to the relevant components
of the general GKw gradient (grgkw) evaluated at .
Returns a numeric vector of length 3 containing the partial derivatives
of the negative log-likelihood function with
respect to each parameter:
.
Returns a vector of NaN if any parameter values are invalid according
to their constraints, or if any value in data is not in the
interval (0, 1).
Lopes, J. E.
McDonald, J. B. (1984). Some generalized functions for the size distribution of income. Econometrica, 52(3), 647-663. doi:10.2307/1913469
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
(Note: Specific gradient formulas might be derived or sourced from additional references).
grgkw (parent distribution gradient),
llmc (negative log-likelihood for Mc),
hsmc (Hessian for Mc),
dmc (density for Mc),
optim,
grad (for numerical gradient comparison),
digamma.
Other gradient functions:
grbeta(),
grbkw(),
grekw(),
grgkw(),
grkkw(),
grkw()
set.seed(123) x <- rmc(200, gamma = 0.5, delta = 5, lambda = 3) par <- c(gamma = 0.5, delta = 5, lambda = 3) ## Gradient of the negative log-likelihood llmc(), not of the log-likelihood g <- grmc(par, x) g ## A small step against the gradient lowers llmc() llmc(par - 1e-4 * g, x) < llmc(par, x) ## Agrees with a numerical derivative of llmc() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llmc, par, data = x), tolerance = 1e-6)set.seed(123) x <- rmc(200, gamma = 0.5, delta = 5, lambda = 3) par <- c(gamma = 0.5, delta = 5, lambda = 3) ## Gradient of the negative log-likelihood llmc(), not of the log-likelihood g <- grmc(par, x) g ## A small step against the gradient lowers llmc() llmc(par - 1e-4 * g, x) < llmc(par, x) ## Agrees with a numerical derivative of llmc() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(g, numDeriv::grad(llmc, par, data = x), tolerance = 1e-6)
Computes the analytic 2x2 Hessian matrix (matrix of second partial derivatives)
of the negative log-likelihood function for the standard Beta distribution,
using a parameterization common in generalized distribution families. The
distribution is parameterized by gamma () and delta
(), corresponding to the standard Beta distribution with shape
parameters shape1 = gamma and shape2 = delta + 1. The Hessian
is useful for estimating standard errors and in optimization algorithms.
hsbeta(par, data)hsbeta(par, data)
par |
A numeric vector of length 2 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
This function calculates the analytic second partial derivatives of the
negative log-likelihood function () for a Beta
distribution with parameters shape1 = gamma () and
shape2 = delta + 1 (). The components of the Hessian
matrix () are:
where is the trigamma function (trigamma).
These formulas represent the second derivatives of ,
consistent with minimizing the negative log-likelihood. They correspond to
the relevant 2x2 submatrix of the general GKw Hessian (hsgkw)
evaluated at . Note the parameterization
difference from the standard Beta distribution (shape2 = delta + 1).
The returned matrix is symmetric.
Returns a 2x2 numeric matrix representing the Hessian matrix of the
negative log-likelihood function, ,
where .
Returns a 2x2 matrix populated with NaN if any parameter values are
invalid according to their constraints, or if any value in data is
not in the interval (0, 1).
Lopes, J. E.
Johnson, N. L., Kotz, S., & Balakrishnan, N. (1995). Continuous Univariate Distributions, Volume 2 (2nd ed.). Wiley.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
(Note: Specific Hessian formulas might be derived or sourced from additional references).
hsgkw, hsmc (related Hessians),
llbeta (negative log-likelihood function),
grbeta (gradient),
dbeta_, pbeta_, qbeta_, rbeta_,
optim,
hessian (for numerical Hessian comparison),
trigamma.
Other Hessian functions:
hsbkw(),
hsekw(),
hsgkw(),
hskkw(),
hskw(),
hsmc()
set.seed(123) x <- rbeta_(1000, gamma = 2, delta = 3) par <- c(gamma = 2, delta = 3) ## Hessian of the negative log-likelihood llbeta() H <- hsbeta(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llbeta() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llbeta, par, data = x), tolerance = 1e-8) ## At the MLE it is the observed information; its inverse estimates the ## covariance of the estimates fit <- optim(par, llbeta, grbeta, data = x, method = "L-BFGS-B", lower = 1e-4) sqrt(diag(solve(hsbeta(fit$par, x)))) # standard errorsset.seed(123) x <- rbeta_(1000, gamma = 2, delta = 3) par <- c(gamma = 2, delta = 3) ## Hessian of the negative log-likelihood llbeta() H <- hsbeta(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llbeta() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llbeta, par, data = x), tolerance = 1e-8) ## At the MLE it is the observed information; its inverse estimates the ## covariance of the estimates fit <- optim(par, llbeta, grbeta, data = x, method = "L-BFGS-B", lower = 1e-4) sqrt(diag(solve(hsbeta(fit$par, x)))) # standard errors
Computes the analytic 4x4 Hessian matrix (matrix of second partial derivatives)
of the negative log-likelihood function for the Beta-Kumaraswamy (BKw)
distribution with parameters alpha (), beta
(), gamma (), and delta ().
This distribution is the special case of the Generalized Kumaraswamy (GKw)
distribution where . The Hessian is useful for estimating
standard errors and in optimization algorithms.
hsbkw(par, data)hsbkw(par, data)
par |
A numeric vector of length 4 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
This function calculates the analytic second partial derivatives of the
negative log-likelihood function based on the BKw log-likelihood
( case of GKw, see llbkw):
where ,
is the Beta function (beta), and intermediate terms are:
The Hessian matrix returned contains the elements
for .
Key properties of the returned matrix:
Dimensions: 4x4.
Symmetry: The matrix is symmetric.
Ordering: Rows and columns correspond to the parameters in the order
.
Content: Analytic second derivatives of the negative log-likelihood.
This corresponds to the relevant 4x4 submatrix of the 5x5 GKw Hessian (hsgkw)
evaluated at . The exact analytical formulas are implemented directly.
Returns a 4x4 numeric matrix representing the Hessian matrix of the
negative log-likelihood function, ,
where .
Returns a 4x4 matrix populated with NaN if any parameter values are
invalid according to their constraints, or if any value in data is
not in the interval (0, 1).
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
(Note: Specific Hessian formulas might be derived or sourced from additional references).
hsgkw (parent distribution Hessian),
llbkw (negative log-likelihood for BKw),
grbkw (gradient for BKw),
dbkw (density for BKw),
optim,
hessian (for numerical Hessian comparison).
Other Hessian functions:
hsbeta(),
hsekw(),
hsgkw(),
hskkw(),
hskw(),
hsmc()
set.seed(123) x <- rbkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) ## Hessian of the negative log-likelihood llbkw() H <- hsbkw(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llbkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llbkw, par, data = x), tolerance = 1e-8)set.seed(123) x <- rbkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) ## Hessian of the negative log-likelihood llbkw() H <- hsbkw(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llbkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llbkw, par, data = x), tolerance = 1e-8)
Computes the analytic 3x3 Hessian matrix (matrix of second partial derivatives)
of the negative log-likelihood function for the Exponentiated Kumaraswamy (EKw)
distribution with parameters alpha (), beta
(), and lambda (). This distribution is the
special case of the Generalized Kumaraswamy (GKw) distribution where
and . The Hessian is useful for estimating
standard errors and in optimization algorithms.
hsekw(par, data)hsekw(par, data)
par |
A numeric vector of length 3 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
This function calculates the analytic second partial derivatives of the
negative log-likelihood function based on the EKw log-likelihood
( case of GKw, see llekw):
where and intermediate terms are:
The Hessian matrix returned contains the elements
for .
Key properties of the returned matrix:
Dimensions: 3x3.
Symmetry: The matrix is symmetric.
Ordering: Rows and columns correspond to the parameters in the order
.
Content: Analytic second derivatives of the negative log-likelihood.
This corresponds to the relevant 3x3 submatrix of the 5x5 GKw Hessian (hsgkw)
evaluated at . The exact analytical formulas are implemented directly.
Returns a 3x3 numeric matrix representing the Hessian matrix of the
negative log-likelihood function, ,
where .
Returns a 3x3 matrix populated with NaN if any parameter values are
invalid according to their constraints, or if any value in data is
not in the interval (0, 1).
Lopes, J. E.
Nadarajah, S., Cordeiro, G. M., & Ortega, E. M. (2012). The exponentiated Kumaraswamy distribution. Journal of the Franklin Institute, 349(3),
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
(Note: Specific Hessian formulas might be derived or sourced from additional references).
hsgkw (parent distribution Hessian),
llekw (negative log-likelihood for EKw),
grekw (gradient for EKw),
dekw (density for EKw),
optim,
hessian (for numerical Hessian comparison).
Other Hessian functions:
hsbeta(),
hsbkw(),
hsgkw(),
hskkw(),
hskw(),
hsmc()
set.seed(123) x <- rekw(1000, alpha = 2, beta = 3, lambda = 1.2) par <- c(alpha = 2, beta = 3, lambda = 1.2) ## Hessian of the negative log-likelihood llekw() H <- hsekw(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llekw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llekw, par, data = x), tolerance = 1e-8) ## At the MLE it is the observed information; its inverse estimates the ## covariance of the estimates fit <- optim(par, llekw, grekw, data = x, method = "L-BFGS-B", lower = 1e-4) sqrt(diag(solve(hsekw(fit$par, x)))) # standard errorsset.seed(123) x <- rekw(1000, alpha = 2, beta = 3, lambda = 1.2) par <- c(alpha = 2, beta = 3, lambda = 1.2) ## Hessian of the negative log-likelihood llekw() H <- hsekw(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llekw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llekw, par, data = x), tolerance = 1e-8) ## At the MLE it is the observed information; its inverse estimates the ## covariance of the estimates fit <- optim(par, llekw, grekw, data = x, method = "L-BFGS-B", lower = 1e-4) sqrt(diag(solve(hsekw(fit$par, x)))) # standard errors
Computes the analytic Hessian matrix (matrix of second partial derivatives) of the negative log-likelihood function for the five-parameter Generalized Kumaraswamy (GKw) distribution. This is typically used to estimate standard errors of maximum likelihood estimates or in optimization algorithms.
hsgkw(par, data)hsgkw(par, data)
par |
A numeric vector of length 5 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
This function calculates the analytic second partial derivatives of the
negative log-likelihood function based on the GKw PDF (see dgkw).
The log-likelihood function is given by:
where ,
is the Beta function (beta), and intermediate terms are:
The Hessian matrix returned contains the elements .
Key properties of the returned matrix:
Dimensions: 5x5.
Symmetry: The matrix is symmetric.
Ordering: Rows and columns correspond to the parameters in the order
.
Content: Analytic second derivatives of the negative log-likelihood.
The exact analytical formulas for the second derivatives are implemented directly (often derived using symbolic differentiation) for accuracy and efficiency, typically using C++.
Returns a 5x5 numeric matrix representing the Hessian matrix of the
negative log-likelihood function, i.e., the matrix of second partial
derivatives .
Returns a 5x5 matrix populated with NaN if any parameter values are
invalid according to their constraints, or if any value in data is
not in the interval (0, 1).
Lopes, J. E.
Carrasco, J. M. F., Ferrari, S. L. P., & Cordeiro, G. M. (2010). A new generalized Kumaraswamy distribution. arXiv preprint arXiv:1004.0911. doi:10.48550/arXiv.1004.0911
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
llgkw (negative log-likelihood function),
grgkw (gradient vector),
dgkw (density function),
optim,
hessian (for numerical Hessian comparison).
Other Hessian functions:
hsbeta(),
hsbkw(),
hsekw(),
hskkw(),
hskw(),
hsmc()
set.seed(123) x <- rgkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) ## Hessian of the negative log-likelihood llgkw() H <- hsgkw(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llgkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llgkw, par, data = x), tolerance = 1e-8)set.seed(123) x <- rgkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) ## Hessian of the negative log-likelihood llgkw() H <- hsgkw(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llgkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llgkw, par, data = x), tolerance = 1e-8)
Computes the analytic 4x4 Hessian matrix (matrix of second partial derivatives)
of the negative log-likelihood function for the Kumaraswamy-Kumaraswamy (KKw)
distribution with parameters alpha (), beta
(), delta (), and lambda ().
This distribution is the special case of the Generalized Kumaraswamy (GKw)
distribution where . The Hessian is useful for estimating
standard errors and in optimization algorithms.
hskkw(par, data)hskkw(par, data)
par |
A numeric vector of length 4 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
This function calculates the analytic second partial derivatives of the
negative log-likelihood function based on the KKw log-likelihood
( case of GKw, see llkkw):
where and intermediate terms are:
The Hessian matrix returned contains the elements
for .
Key properties of the returned matrix:
Dimensions: 4x4.
Symmetry: The matrix is symmetric.
Ordering: Rows and columns correspond to the parameters in the order
.
Content: Analytic second derivatives of the negative log-likelihood.
This corresponds to the relevant submatrix of the 5x5 GKw Hessian (hsgkw)
evaluated at . The exact analytical formulas are implemented directly.
Returns a 4x4 numeric matrix representing the Hessian matrix of the
negative log-likelihood function, ,
where .
Returns a 4x4 matrix populated with NaN if any parameter values are
invalid according to their constraints, or if any value in data is
not in the interval (0, 1).
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
hsgkw (parent distribution Hessian),
llkkw (negative log-likelihood for KKw),
grkkw (gradient for KKw),
dkkw (density for KKw),
optim,
hessian (for numerical Hessian comparison).
Other Hessian functions:
hsbeta(),
hsbkw(),
hsekw(),
hsgkw(),
hskw(),
hsmc()
set.seed(123) x <- rkkw(1000, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) ## Hessian of the negative log-likelihood llkkw() H <- hskkw(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llkkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llkkw, par, data = x), tolerance = 1e-8)set.seed(123) x <- rkkw(1000, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) ## Hessian of the negative log-likelihood llkkw() H <- hskkw(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llkkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llkkw, par, data = x), tolerance = 1e-8)
Computes the analytic 2x2 Hessian matrix (matrix of second partial derivatives)
of the negative log-likelihood function for the two-parameter Kumaraswamy (Kw)
distribution with parameters alpha () and beta
(). The Hessian is useful for estimating standard errors and in
optimization algorithms.
hskw(par, data)hskw(par, data)
par |
A numeric vector of length 2 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
This function calculates the analytic second partial derivatives of the
negative log-likelihood function (). The components
are the negative of the second derivatives of the log-likelihood
(derived from the PDF in dkw).
Let . The second derivatives of the positive log-likelihood () are:
The function returns the Hessian matrix containing the negative of these values.
Key properties of the returned matrix:
Dimensions: 2x2.
Symmetry: The matrix is symmetric.
Ordering: Rows and columns correspond to the parameters in the order
.
Content: Analytic second derivatives of the negative log-likelihood.
This corresponds to the relevant 2x2 submatrix of the 5x5 GKw Hessian (hsgkw)
evaluated at .
Returns a 2x2 numeric matrix representing the Hessian matrix of the
negative log-likelihood function, ,
where .
Returns a 2x2 matrix populated with NaN if any parameter values are
invalid according to their constraints, or if any value in data is
not in the interval (0, 1).
Lopes, J. E.
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with some tractability advantages. Statistical Methodology, 6(1), 70-81. doi:10.1016/j.stamet.2008.04.001
(Note: Specific Hessian formulas might be derived or sourced from additional references).
hsgkw (parent distribution Hessian),
llkw (negative log-likelihood for Kw),
grkw (gradient for Kw),
dkw (density for Kw),
optim,
hessian (for numerical Hessian comparison).
Other Hessian functions:
hsbeta(),
hsbkw(),
hsekw(),
hsgkw(),
hskkw(),
hsmc()
set.seed(123) x <- rkw(1000, alpha = 2, beta = 3) par <- c(alpha = 2, beta = 3) ## Hessian of the negative log-likelihood llkw() H <- hskw(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llkw, par, data = x), tolerance = 1e-8) ## At the MLE it is the observed information; its inverse estimates the ## covariance of the estimates fit <- optim(par, llkw, grkw, data = x, method = "L-BFGS-B", lower = 1e-4) sqrt(diag(solve(hskw(fit$par, x)))) # standard errorsset.seed(123) x <- rkw(1000, alpha = 2, beta = 3) par <- c(alpha = 2, beta = 3) ## Hessian of the negative log-likelihood llkw() H <- hskw(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llkw() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llkw, par, data = x), tolerance = 1e-8) ## At the MLE it is the observed information; its inverse estimates the ## covariance of the estimates fit <- optim(par, llkw, grkw, data = x, method = "L-BFGS-B", lower = 1e-4) sqrt(diag(solve(hskw(fit$par, x)))) # standard errors
Computes the analytic 3x3 Hessian matrix (matrix of second partial derivatives)
of the negative log-likelihood function for the McDonald (Mc) distribution
(also known as Beta Power) with parameters gamma (),
delta (), and lambda (). This distribution
is the special case of the Generalized Kumaraswamy (GKw) distribution where
and . The Hessian is useful for estimating
standard errors and in optimization algorithms.
hsmc(par, data)hsmc(par, data)
par |
A numeric vector of length 3 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
This function calculates the analytic second partial derivatives of the
negative log-likelihood function ().
The components are based on the second derivatives of the log-likelihood
(derived from the PDF in dmc).
Note: The formulas below represent the second derivatives of the positive
log-likelihood (). The function returns the negative of these values.
where is the trigamma function (trigamma).
The term matches the C++ implementation
(src/bpmc.cpp) and is covered by the numerical Hessian checks in
tests/testthat/test-derivatives-validation.R.
The returned matrix is symmetric, with rows/columns corresponding to
.
Returns a 3x3 numeric matrix representing the Hessian matrix of the
negative log-likelihood function, ,
where .
Returns a 3x3 matrix populated with NaN if any parameter values are
invalid according to their constraints, or if any value in data is
not in the interval (0, 1).
Lopes, J. E.
McDonald, J. B. (1984). Some generalized functions for the size distribution of income. Econometrica, 52(3), 647-663. doi:10.2307/1913469
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
(Note: Specific Hessian formulas might be derived or sourced from additional references).
hsgkw (parent distribution Hessian),
llmc (negative log-likelihood for Mc),
grmc (gradient for Mc),
dmc (density for Mc),
optim,
hessian (for numerical Hessian comparison),
trigamma.
Other Hessian functions:
hsbeta(),
hsbkw(),
hsekw(),
hsgkw(),
hskkw(),
hskw()
set.seed(123) x <- rmc(1000, gamma = 0.5, delta = 5, lambda = 3) par <- c(gamma = 0.5, delta = 5, lambda = 3) ## Hessian of the negative log-likelihood llmc() H <- hsmc(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llmc() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llmc, par, data = x), tolerance = 1e-8) ## At the MLE it is the observed information; its inverse estimates the ## covariance of the estimates fit <- optim(par, llmc, grmc, data = x, method = "L-BFGS-B", lower = 1e-4) sqrt(diag(solve(hsmc(fit$par, x)))) # standard errorsset.seed(123) x <- rmc(1000, gamma = 0.5, delta = 5, lambda = 3) par <- c(gamma = 0.5, delta = 5, lambda = 3) ## Hessian of the negative log-likelihood llmc() H <- hsmc(par, x) isSymmetric(H) ## Agrees with a numerical Hessian of llmc() if (requireNamespace("numDeriv", quietly = TRUE)) all.equal(H, numDeriv::hessian(llmc, par, data = x), tolerance = 1e-8) ## At the MLE it is the observed information; its inverse estimates the ## covariance of the estimates fit <- optim(par, llmc, grmc, data = x, method = "L-BFGS-B", lower = 1e-4) sqrt(diag(solve(hsmc(fit$par, x)))) # standard errors
Computes the negative log-likelihood function for the standard Beta
distribution, using a parameterization common in generalized distribution
families. The distribution is parameterized by gamma () and
delta (), corresponding to the standard Beta distribution
with shape parameters shape1 = gamma and shape2 = delta + 1.
This function is suitable for maximum likelihood estimation.
llbeta(par, data)llbeta(par, data)
par |
A numeric vector of length 2 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
This function calculates the negative log-likelihood for a Beta distribution
with parameters shape1 = gamma () and shape2 = delta + 1 ().
The probability density function (PDF) is:
for , where is the Beta function (beta).
The log-likelihood function for a sample
is :
where .
This function computes and returns the negative log-likelihood, ,
suitable for minimization using optimization routines like optim.
It is equivalent to the negative log-likelihood of the GKw distribution
(llgkw) evaluated at , and also
to the negative log-likelihood of the McDonald distribution (llmc)
evaluated at . The term is typically
computed using log-gamma functions (lgamma) for numerical stability.
Returns a single double value representing the negative
log-likelihood (). Returns Inf
if any parameter values in par are invalid according to their
constraints, or if any value in data is not in the interval (0, 1);
in the latter case a warning naming data is also signaled, because
an infinite objective offers an optimizer no gradient direction to follow
and more often means a sample on the wrong scale than a genuine fit
failure.
Lopes, J. E.
Johnson, N. L., Kotz, S., & Balakrishnan, N. (1995). Continuous Univariate Distributions, Volume 2 (2nd ed.). Wiley.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
llgkw, llmc (related negative log-likelihoods),
dbeta_, pbeta_, qbeta_, rbeta_,
grbeta (gradient),
hsbeta (Hessian),
optim, lbeta.
Other log-likelihood functions:
llbkw(),
llekw(),
llgkw(),
llkkw(),
llkw(),
llmc()
set.seed(123) x <- rbeta_(1000, gamma = 2, delta = 3) par <- c(gamma = 2, delta = 3) ## llbeta() is the negative log-likelihood, -sum(log f(x)) llbeta(par, x) -sum(dbeta_(x, gamma = 2, delta = 3, log = TRUE)) ## Maximum likelihood: minimize llbeta(), with grbeta() as its gradient start <- gkwgetstartvalues(x, family = "beta") fit <- optim(start, llbeta, grbeta, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged fit$par fit$value <= llbeta(par, x) # at least as good as the true valuesset.seed(123) x <- rbeta_(1000, gamma = 2, delta = 3) par <- c(gamma = 2, delta = 3) ## llbeta() is the negative log-likelihood, -sum(log f(x)) llbeta(par, x) -sum(dbeta_(x, gamma = 2, delta = 3, log = TRUE)) ## Maximum likelihood: minimize llbeta(), with grbeta() as its gradient start <- gkwgetstartvalues(x, family = "beta") fit <- optim(start, llbeta, grbeta, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged fit$par fit$value <= llbeta(par, x) # at least as good as the true values
Computes the negative log-likelihood function for the Beta-Kumaraswamy (BKw)
distribution with parameters alpha (), beta
(), gamma (), and delta (),
given a vector of observations. This distribution is the special case of the
Generalized Kumaraswamy (GKw) distribution where . This function
is typically used for maximum likelihood estimation via numerical optimization.
llbkw(par, data)llbkw(par, data)
par |
A numeric vector of length 4 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The Beta-Kumaraswamy (BKw) distribution is the GKw distribution (dgkw)
with . Its probability density function (PDF) is:
for , , and
is the Beta function (beta).
The log-likelihood function for a sample
is :
where:
This function computes and returns the negative log-likelihood, ,
suitable for minimization using optimization routines like optim.
Numerical stability is maintained similarly to llgkw.
Returns a single double value representing the negative
log-likelihood (). Returns Inf
if any parameter values in par are invalid according to their
constraints, or if any value in data is not in the interval (0, 1);
in the latter case a warning naming data is also signaled, because
an infinite objective offers an optimizer no gradient direction to follow
and more often means a sample on the wrong scale than a genuine fit
failure.
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
llgkw (parent distribution negative log-likelihood),
dbkw, pbkw, qbkw, rbkw,
grbkw (gradient),
hsbkw (Hessian),
optim, lbeta
Other log-likelihood functions:
llbeta(),
llekw(),
llgkw(),
llkkw(),
llkw(),
llmc()
set.seed(123) x <- rbkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) ## llbkw() is the negative log-likelihood, -sum(log f(x)) llbkw(par, x) -sum(dbkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, log = TRUE)) ## Maximum likelihood: minimize llbkw(), with grbkw() as its gradient start <- gkwgetstartvalues(x, family = "bkw") fit <- optim(start, llbkw, grbkw, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged ## The parameters of this family are weakly identified: compare likelihoods fit$value <= llbkw(par, x) # at least as good as the true valuesset.seed(123) x <- rbkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) ## llbkw() is the negative log-likelihood, -sum(log f(x)) llbkw(par, x) -sum(dbkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, log = TRUE)) ## Maximum likelihood: minimize llbkw(), with grbkw() as its gradient start <- gkwgetstartvalues(x, family = "bkw") fit <- optim(start, llbkw, grbkw, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged ## The parameters of this family are weakly identified: compare likelihoods fit$value <= llbkw(par, x) # at least as good as the true values
Computes the negative log-likelihood function for the Exponentiated
Kumaraswamy (EKw) distribution with parameters alpha (),
beta (), and lambda (), given a vector
of observations. This distribution is the special case of the Generalized
Kumaraswamy (GKw) distribution where and .
This function is suitable for maximum likelihood estimation.
llekw(par, data)llekw(par, data)
par |
A numeric vector of length 3 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The Exponentiated Kumaraswamy (EKw) distribution is the GKw distribution
(dekw) with and . Its probability
density function (PDF) is:
for and .
The log-likelihood function for a sample
is :
where:
This function computes and returns the negative log-likelihood, ,
suitable for minimization using optimization routines like optim.
Numerical stability is maintained similarly to llgkw.
Returns a single double value representing the negative
log-likelihood (). Returns Inf
if any parameter values in par are invalid according to their
constraints, or if any value in data is not in the interval (0, 1);
in the latter case a warning naming data is also signaled, because
an infinite objective offers an optimizer no gradient direction to follow
and more often means a sample on the wrong scale than a genuine fit
failure.
Lopes, J. E.
Nadarajah, S., Cordeiro, G. M., & Ortega, E. M. (2012). The exponentiated Kumaraswamy distribution. Journal of the Franklin Institute, 349(3),
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
llgkw (parent distribution negative log-likelihood),
dekw, pekw, qekw, rekw,
grekw (gradient),
hsekw (Hessian),
optim
Other log-likelihood functions:
llbeta(),
llbkw(),
llgkw(),
llkkw(),
llkw(),
llmc()
set.seed(123) x <- rekw(1000, alpha = 2, beta = 3, lambda = 1.2) par <- c(alpha = 2, beta = 3, lambda = 1.2) ## llekw() is the negative log-likelihood, -sum(log f(x)) llekw(par, x) -sum(dekw(x, alpha = 2, beta = 3, lambda = 1.2, log = TRUE)) ## Maximum likelihood: minimize llekw(), with grekw() as its gradient start <- gkwgetstartvalues(x, family = "ekw") fit <- optim(start, llekw, grekw, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged fit$par fit$value <= llekw(par, x) # at least as good as the true valuesset.seed(123) x <- rekw(1000, alpha = 2, beta = 3, lambda = 1.2) par <- c(alpha = 2, beta = 3, lambda = 1.2) ## llekw() is the negative log-likelihood, -sum(log f(x)) llekw(par, x) -sum(dekw(x, alpha = 2, beta = 3, lambda = 1.2, log = TRUE)) ## Maximum likelihood: minimize llekw(), with grekw() as its gradient start <- gkwgetstartvalues(x, family = "ekw") fit <- optim(start, llekw, grekw, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged fit$par fit$value <= llekw(par, x) # at least as good as the true values
Computes the negative log-likelihood function for the five-parameter Generalized Kumaraswamy (GKw) distribution given a vector of observations. This function is designed for use in optimization routines (e.g., maximum likelihood estimation).
llgkw(par, data)llgkw(par, data)
par |
A numeric vector of length 5 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The probability density function (PDF) of the GKw distribution is given in
dgkw. The log-likelihood function for a sample
is:
where ,
is the Beta function (beta), and:
This function computes .
Numerical stability is prioritized using:
lbeta function for the log-Beta term.
Log-transformations of intermediate terms () and
use of log1p where appropriate to handle values
close to 0 or 1 accurately.
Checks for invalid parameters and data.
Returns a single double value representing the negative
log-likelihood (). Returns Inf
if any parameter values in par are invalid according to their
constraints, or if any value in data is not in the interval (0, 1);
in the latter case a warning naming data is also signaled, because
an infinite objective offers an optimizer no gradient direction to follow
and more often means a sample on the wrong scale than a genuine fit
failure.
Lopes, J. E.
Carrasco, J. M. F., Ferrari, S. L. P., & Cordeiro, G. M. (2010). A new generalized Kumaraswamy distribution. arXiv preprint arXiv:1004.0911. doi:10.48550/arXiv.1004.0911
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
dgkw, pgkw, qgkw, rgkw,
grgkw, hsgkw (gradient and Hessian),
optim, lbeta, log1p
Other log-likelihood functions:
llbeta(),
llbkw(),
llekw(),
llkkw(),
llkw(),
llmc()
set.seed(123) x <- rgkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) ## llgkw() is the negative log-likelihood, -sum(log f(x)) llgkw(par, x) -sum(dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, log = TRUE)) ## Maximum likelihood: minimize llgkw(), with grgkw() as its gradient start <- gkwgetstartvalues(x, family = "gkw") fit <- optim(start, llgkw, grgkw, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged ## The parameters of this family are weakly identified: compare likelihoods fit$value <= llgkw(par, x) # at least as good as the true valuesset.seed(123) x <- rgkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) ## llgkw() is the negative log-likelihood, -sum(log f(x)) llgkw(par, x) -sum(dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, log = TRUE)) ## Maximum likelihood: minimize llgkw(), with grgkw() as its gradient start <- gkwgetstartvalues(x, family = "gkw") fit <- optim(start, llgkw, grgkw, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged ## The parameters of this family are weakly identified: compare likelihoods fit$value <= llgkw(par, x) # at least as good as the true values
Computes the negative log-likelihood function for the Kumaraswamy-Kumaraswamy
(KKw) distribution with parameters alpha (), beta
(), delta (), and lambda (),
given a vector of observations. This distribution is a special case of the
Generalized Kumaraswamy (GKw) distribution where .
llkkw(par, data)llkkw(par, data)
par |
A numeric vector of length 4 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The KKw distribution is the GKw distribution (dgkw) with .
Its probability density function (PDF) is:
for and .
The log-likelihood function for a sample
is :
where:
This function computes and returns the negative log-likelihood, ,
suitable for minimization using optimization routines like optim.
Numerical stability is maintained similarly to llgkw.
Returns a single double value representing the negative
log-likelihood (). Returns Inf
if any parameter values in par are invalid according to their
constraints, or if any value in data is not in the interval (0, 1);
in the latter case a warning naming data is also signaled, because
an infinite objective offers an optimizer no gradient direction to follow
and more often means a sample on the wrong scale than a genuine fit
failure.
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
llgkw (parent distribution negative log-likelihood),
dkkw, pkkw, qkkw, rkkw,
grkkw (gradient),
hskkw (Hessian),
optim
Other log-likelihood functions:
llbeta(),
llbkw(),
llekw(),
llgkw(),
llkw(),
llmc()
set.seed(123) x <- rkkw(1000, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) ## llkkw() is the negative log-likelihood, -sum(log f(x)) llkkw(par, x) -sum(dkkw(x, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, log = TRUE)) ## Maximum likelihood: minimize llkkw(), with grkkw() as its gradient start <- gkwgetstartvalues(x, family = "kkw") fit <- optim(start, llkkw, grkkw, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged ## The parameters of this family are weakly identified: compare likelihoods fit$value <= llkkw(par, x) # at least as good as the true valuesset.seed(123) x <- rkkw(1000, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) par <- c(alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) ## llkkw() is the negative log-likelihood, -sum(log f(x)) llkkw(par, x) -sum(dkkw(x, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, log = TRUE)) ## Maximum likelihood: minimize llkkw(), with grkkw() as its gradient start <- gkwgetstartvalues(x, family = "kkw") fit <- optim(start, llkkw, grkkw, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged ## The parameters of this family are weakly identified: compare likelihoods fit$value <= llkkw(par, x) # at least as good as the true values
Computes the negative log-likelihood function for the two-parameter
Kumaraswamy (Kw) distribution with parameters alpha ()
and beta (), given a vector of observations. This function
is suitable for maximum likelihood estimation.
llkw(par, data)llkw(par, data)
par |
A numeric vector of length 2 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The Kumaraswamy (Kw) distribution's probability density function (PDF) is
(see dkw):
for and .
The log-likelihood function for a sample
is :
where .
This function computes and returns the negative log-likelihood, ,
suitable for minimization using optimization routines like optim.
It is equivalent to the negative log-likelihood of the GKw distribution
(llgkw) evaluated at .
Returns a single double value representing the negative
log-likelihood (). Returns Inf
if any parameter values in par are invalid according to their
constraints, or if any value in data is not in the interval (0, 1);
in the latter case a warning naming data is also signaled, because
an infinite objective offers an optimizer no gradient direction to follow
and more often means a sample on the wrong scale than a genuine fit
failure.
Lopes, J. E.
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with some tractability advantages. Statistical Methodology, 6(1), 70-81. doi:10.1016/j.stamet.2008.04.001
llgkw (parent distribution negative log-likelihood),
dkw, pkw, qkw, rkw,
grkw (gradient),
hskw (Hessian),
optim
Other log-likelihood functions:
llbeta(),
llbkw(),
llekw(),
llgkw(),
llkkw(),
llmc()
set.seed(123) x <- rkw(1000, alpha = 2, beta = 3) par <- c(alpha = 2, beta = 3) ## llkw() is the negative log-likelihood, -sum(log f(x)) llkw(par, x) -sum(dkw(x, alpha = 2, beta = 3, log = TRUE)) ## Maximum likelihood: minimize llkw(), with grkw() as its gradient start <- gkwgetstartvalues(x, family = "kw") fit <- optim(start, llkw, grkw, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged fit$par fit$value <= llkw(par, x) # at least as good as the true valuesset.seed(123) x <- rkw(1000, alpha = 2, beta = 3) par <- c(alpha = 2, beta = 3) ## llkw() is the negative log-likelihood, -sum(log f(x)) llkw(par, x) -sum(dkw(x, alpha = 2, beta = 3, log = TRUE)) ## Maximum likelihood: minimize llkw(), with grkw() as its gradient start <- gkwgetstartvalues(x, family = "kw") fit <- optim(start, llkw, grkw, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged fit$par fit$value <= llkw(par, x) # at least as good as the true values
Computes the negative log-likelihood function for the McDonald (Mc)
distribution (also known as Beta Power) with parameters gamma
(), delta (), and lambda (),
given a vector of observations. This distribution is the special case of the
Generalized Kumaraswamy (GKw) distribution where and
. This function is suitable for maximum likelihood estimation.
llmc(par, data)llmc(par, data)
par |
A numeric vector of length 3 containing the distribution parameters
in the order: |
data |
A numeric vector of observations. All values must be strictly between 0 and 1 (exclusive). |
The McDonald (Mc) distribution is the GKw distribution (dmc)
with and . Its probability density function (PDF) is:
for , , and
is the Beta function (beta).
The log-likelihood function for a sample
is :
This function computes and returns the negative log-likelihood, ,
suitable for minimization using optimization routines like optim.
Numerical stability is maintained, including using the log-gamma function
(lgamma) for the Beta function term.
Returns a single double value representing the negative
log-likelihood (). Returns Inf
if any parameter values in par are invalid according to their
constraints, or if any value in data is not in the interval (0, 1);
in the latter case a warning naming data is also signaled, because
an infinite objective offers an optimizer no gradient direction to follow
and more often means a sample on the wrong scale than a genuine fit
failure.
Lopes, J. E.
McDonald, J. B. (1984). Some generalized functions for the size distribution of income. Econometrica, 52(3), 647-663. doi:10.2307/1913469
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
llgkw (parent distribution negative log-likelihood),
dmc, pmc, qmc, rmc,
grmc (gradient),
hsmc (Hessian),
optim, lbeta
Other log-likelihood functions:
llbeta(),
llbkw(),
llekw(),
llgkw(),
llkkw(),
llkw()
set.seed(123) x <- rmc(1000, gamma = 0.5, delta = 5, lambda = 3) par <- c(gamma = 0.5, delta = 5, lambda = 3) ## llmc() is the negative log-likelihood, -sum(log f(x)) llmc(par, x) -sum(dmc(x, gamma = 0.5, delta = 5, lambda = 3, log = TRUE)) ## Maximum likelihood: minimize llmc(), with grmc() as its gradient start <- gkwgetstartvalues(x, family = "mc") fit <- optim(start, llmc, grmc, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged fit$par fit$value <= llmc(par, x) # at least as good as the true valuesset.seed(123) x <- rmc(1000, gamma = 0.5, delta = 5, lambda = 3) par <- c(gamma = 0.5, delta = 5, lambda = 3) ## llmc() is the negative log-likelihood, -sum(log f(x)) llmc(par, x) -sum(dmc(x, gamma = 0.5, delta = 5, lambda = 3, log = TRUE)) ## Maximum likelihood: minimize llmc(), with grmc() as its gradient start <- gkwgetstartvalues(x, family = "mc") fit <- optim(start, llmc, grmc, data = x, method = "L-BFGS-B", lower = 1e-4) fit$convergence # 0: converged fit$par fit$value <= llmc(par, x) # at least as good as the true values
Computes the cumulative distribution function (CDF), ,
for the standard Beta distribution, using a parameterization common in
generalized distribution families. The distribution is parameterized by
gamma () and delta (), corresponding to
the standard Beta distribution with shape parameters shape1 = gamma
and shape2 = delta + 1.
pbeta_(q, gamma = 1, delta = 0, lower.tail = TRUE, log.p = FALSE)pbeta_(q, gamma = 1, delta = 0, lower.tail = TRUE, log.p = FALSE)
q |
Vector of quantiles (values generally between 0 and 1). |
gamma |
First shape parameter ( |
delta |
Second shape parameter is |
lower.tail |
Logical; if |
log.p |
Logical; if |
This function computes the CDF of a Beta distribution with parameters
shape1 = gamma and shape2 = delta + 1. It is equivalent to
calling stats::pbeta(q, shape1 = gamma, shape2 = delta + 1,
lower.tail = lower.tail, log.p = log.p).
This distribution arises as a special case of the five-parameter
Generalized Kumaraswamy (GKw) distribution (pgkw) obtained
by setting , , and .
It is therefore also equivalent to the McDonald (Mc)/Beta Power distribution
(pmc) with .
The function likely calls R's underlying pbeta function but ensures
consistent parameter recycling and handling within the C++ environment,
matching the style of other functions in the related families.
A vector of probabilities, , or their logarithms/complements
depending on lower.tail and log.p. The length of the result
is determined by the recycling rule applied to the arguments (q,
gamma, delta). When lower.tail = TRUE, returns
0 (or -Inf if log.p = TRUE) for q <= 0 and
1 (or 0 if log.p = TRUE) for q >= 1. An
out-of-bound or missing parameter is an error, not a return value: the
wrapper stops with a message naming the parameter. An infinite parameter
is not currently intercepted there and reaches the C++ layer, which
treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Johnson, N. L., Kotz, S., & Balakrishnan, N. (1995). Continuous Univariate Distributions, Volume 2 (2nd ed.). Wiley.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
pbeta (standard R implementation),
pgkw (parent distribution CDF),
pmc (McDonald/Beta Power CDF),
dbeta_, qbeta_, rbeta_.
Other cumulative distribution functions:
pbkw(),
pekw(),
pgkw(),
pkkw(),
pkw(),
pmc()
q <- c(0.2, 0.5, 0.8) pbeta_(q, gamma = 2, delta = 3) pbeta_(q, gamma = 2, delta = 3, lower.tail = FALSE) # P(X > q) pbeta_(q, gamma = 2, delta = 3, log.p = TRUE) ## pbeta_() is the integral of dbeta_() Fq <- pbeta_(0.5, gamma = 2, delta = 3) all.equal(Fq, integrate(dbeta_, 0, 0.5, gamma = 2, delta = 3, rel.tol = 1e-10)$value)q <- c(0.2, 0.5, 0.8) pbeta_(q, gamma = 2, delta = 3) pbeta_(q, gamma = 2, delta = 3, lower.tail = FALSE) # P(X > q) pbeta_(q, gamma = 2, delta = 3, log.p = TRUE) ## pbeta_() is the integral of dbeta_() Fq <- pbeta_(0.5, gamma = 2, delta = 3) all.equal(Fq, integrate(dbeta_, 0, 0.5, gamma = 2, delta = 3, rel.tol = 1e-10)$value)
Computes the cumulative distribution function (CDF), , for the
Beta-Kumaraswamy (BKw) distribution with parameters alpha (),
beta (), gamma (), and delta
(). This distribution is defined on the interval (0, 1) and is
a special case of the Generalized Kumaraswamy (GKw) distribution where
.
pbkw( q, alpha = 1, beta = 1, gamma = 1, delta = 0, lower.tail = TRUE, log.p = FALSE )pbkw( q, alpha = 1, beta = 1, gamma = 1, delta = 0, lower.tail = TRUE, log.p = FALSE )
q |
Vector of quantiles (values generally between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
gamma |
Shape parameter |
delta |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The Beta-Kumaraswamy (BKw) distribution is a special case of the
five-parameter Generalized Kumaraswamy distribution (pgkw)
obtained by setting the shape parameter .
The CDF of the GKw distribution is ,
where and
is the regularized incomplete beta function (pbeta).
Setting simplifies to ,
yielding the BKw CDF:
This is evaluated using the pbeta function.
A vector of probabilities, , or their logarithms/complements
depending on lower.tail and log.p. The length of the result
is determined by the recycling rule applied to the arguments (q,
alpha, beta, gamma, delta). When
lower.tail = TRUE, returns 0 (or -Inf if
log.p = TRUE) for q <= 0 and 1 (or 0 if
log.p = TRUE) for q >= 1. An out-of-bound or missing
parameter is an error, not a return value: the wrapper stops with a
message naming the parameter. An infinite parameter is not currently
intercepted there and reaches the C++ layer, which treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
pgkw (parent distribution CDF),
dbkw, qbkw, rbkw (other BKw functions),
pbeta
Other cumulative distribution functions:
pbeta_(),
pekw(),
pgkw(),
pkkw(),
pkw(),
pmc()
q <- c(0.2, 0.5, 0.8) pbkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) # P(X > q) pbkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lower.tail = FALSE) pbkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, log.p = TRUE) ## pbkw() is the integral of dbkw() Fq <- pbkw(0.5, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) all.equal(Fq, integrate(dbkw, 0, 0.5, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, rel.tol = 1e-10)$value)q <- c(0.2, 0.5, 0.8) pbkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) # P(X > q) pbkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lower.tail = FALSE) pbkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, log.p = TRUE) ## pbkw() is the integral of dbkw() Fq <- pbkw(0.5, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) all.equal(Fq, integrate(dbkw, 0, 0.5, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, rel.tol = 1e-10)$value)
Computes the cumulative distribution function (CDF), , for the
Exponentiated Kumaraswamy (EKw) distribution with parameters alpha
(), beta (), and lambda ().
This distribution is defined on the interval (0, 1) and is a special case
of the Generalized Kumaraswamy (GKw) distribution where
and .
pekw(q, alpha = 1, beta = 1, lambda = 1, lower.tail = TRUE, log.p = FALSE)pekw(q, alpha = 1, beta = 1, lambda = 1, lower.tail = TRUE, log.p = FALSE)
q |
Vector of quantiles (values generally between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
lambda |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The Exponentiated Kumaraswamy (EKw) distribution is a special case of the
five-parameter Generalized Kumaraswamy distribution (pgkw)
obtained by setting parameters and .
The CDF of the GKw distribution is ,
where and
is the regularized incomplete beta function (pbeta).
Setting and gives . Since
, the CDF simplifies to :
for .
The implementation uses this closed-form expression for efficiency and handles
lower.tail and log.p arguments appropriately.
A vector of probabilities, , or their logarithms/complements
depending on lower.tail and log.p. The length of the result
is determined by the recycling rule applied to the arguments (q,
alpha, beta, lambda). When lower.tail = TRUE,
returns 0 (or -Inf if log.p = TRUE) for q <= 0
and 1 (or 0 if log.p = TRUE) for q >= 1. An
out-of-bound or missing parameter is an error, not a return value: the
wrapper stops with a message naming the parameter. An infinite parameter
is not currently intercepted there and reaches the C++ layer, which
treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Nadarajah, S., Cordeiro, G. M., & Ortega, E. M. (2012). The exponentiated Kumaraswamy distribution. Journal of the Franklin Institute, 349(3),
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
pgkw (parent distribution CDF),
dekw, qekw, rekw (other EKw functions),
Other cumulative distribution functions:
pbeta_(),
pbkw(),
pgkw(),
pkkw(),
pkw(),
pmc()
q <- c(0.2, 0.5, 0.8) pekw(q, alpha = 2, beta = 3, lambda = 1.2) pekw(q, alpha = 2, beta = 3, lambda = 1.2, lower.tail = FALSE) # P(X > q) pekw(q, alpha = 2, beta = 3, lambda = 1.2, log.p = TRUE) ## pekw() is the integral of dekw() Fq <- pekw(0.5, alpha = 2, beta = 3, lambda = 1.2) all.equal(Fq, integrate(dekw, 0, 0.5, alpha = 2, beta = 3, lambda = 1.2, rel.tol = 1e-10)$value)q <- c(0.2, 0.5, 0.8) pekw(q, alpha = 2, beta = 3, lambda = 1.2) pekw(q, alpha = 2, beta = 3, lambda = 1.2, lower.tail = FALSE) # P(X > q) pekw(q, alpha = 2, beta = 3, lambda = 1.2, log.p = TRUE) ## pekw() is the integral of dekw() Fq <- pekw(0.5, alpha = 2, beta = 3, lambda = 1.2) all.equal(Fq, integrate(dekw, 0, 0.5, alpha = 2, beta = 3, lambda = 1.2, rel.tol = 1e-10)$value)
Computes the cumulative distribution function (CDF) for the five-parameter
Generalized Kumaraswamy (GKw) distribution, defined on the interval (0, 1).
Calculates .
pgkw( q, alpha = 1, beta = 1, gamma = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE )pgkw( q, alpha = 1, beta = 1, gamma = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE )
q |
Vector of quantiles (values generally between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
gamma |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The cumulative distribution function (CDF) of the Generalized Kumaraswamy (GKw)
distribution with parameters alpha (), beta
(), gamma (), delta (), and
lambda () is given by:
where and
is the regularized incomplete beta function, defined as:
This corresponds to the pbeta function in R, such that
.
The GKw distribution includes several special cases, such as the Kumaraswamy,
Beta, and Exponentiated Kumaraswamy distributions (see dgkw for details).
The function utilizes numerical algorithms for computing the regularized
incomplete beta function accurately, especially near the boundaries.
A vector of probabilities, , or their logarithms/complements
depending on lower.tail and log.p. The length of the result
is determined by the recycling rule applied to the arguments (q,
alpha, beta, gamma, delta, lambda). When
lower.tail = TRUE, returns 0 (or -Inf if
log.p = TRUE) for q <= 0 and 1 (or 0 if
log.p = TRUE) for q >= 1. An out-of-bound or missing
parameter is an error, not a return value: the wrapper stops with a
message naming the parameter. An infinite parameter is not currently
intercepted there and reaches the C++ layer, which treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Carrasco, J. M. F., Ferrari, S. L. P., & Cordeiro, G. M. (2010). A new generalized Kumaraswamy distribution. arXiv preprint arXiv:1004.0911. doi:10.48550/arXiv.1004.0911
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Other cumulative distribution functions:
pbeta_(),
pbkw(),
pekw(),
pkkw(),
pkw(),
pmc()
q <- c(0.2, 0.5, 0.8) pgkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) pgkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, lower.tail = FALSE) # P(X > q) pgkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, log.p = TRUE) ## pgkw() is the integral of dgkw() Fq <- pgkw(0.5, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) all.equal(Fq, integrate(dgkw, 0, 0.5, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, rel.tol = 1e-10)$value)q <- c(0.2, 0.5, 0.8) pgkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) pgkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, lower.tail = FALSE) # P(X > q) pgkw(q, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, log.p = TRUE) ## pgkw() is the integral of dgkw() Fq <- pgkw(0.5, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) all.equal(Fq, integrate(dgkw, 0, 0.5, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, rel.tol = 1e-10)$value)
Computes the cumulative distribution function (CDF), , for the
Kumaraswamy-Kumaraswamy (KKw) distribution with parameters alpha
(), beta (), delta (),
and lambda (). This distribution is defined on the
interval (0, 1).
pkkw( q, alpha = 1, beta = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE )pkkw( q, alpha = 1, beta = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE )
q |
Vector of quantiles (values generally between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The Kumaraswamy-Kumaraswamy (KKw) distribution is a special case of the
five-parameter Generalized Kumaraswamy distribution (pgkw)
obtained by setting the shape parameter .
The CDF of the GKw distribution is ,
where and
is the regularized incomplete beta function (pbeta).
Setting utilizes the property ,
yielding the KKw CDF:
for .
The implementation uses this closed-form expression for efficiency and handles
lower.tail and log.p arguments appropriately.
A vector of probabilities, , or their logarithms/complements
depending on lower.tail and log.p. The length of the result
is determined by the recycling rule applied to the arguments (q,
alpha, beta, delta, lambda). When
lower.tail = TRUE, returns 0 (or -Inf if
log.p = TRUE) for q <= 0 and 1 (or 0 if
log.p = TRUE) for q >= 1. An out-of-bound or missing
parameter is an error, not a return value: the wrapper stops with a
message naming the parameter. An infinite parameter is not currently
intercepted there and reaches the C++ layer, which treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
pgkw (parent distribution CDF),
dkkw, qkkw, rkkw,
pbeta
Other cumulative distribution functions:
pbeta_(),
pbkw(),
pekw(),
pgkw(),
pkw(),
pmc()
q <- c(0.2, 0.5, 0.8) pkkw(q, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) # P(X > q) pkkw(q, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, lower.tail = FALSE) pkkw(q, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, log.p = TRUE) ## pkkw() is the integral of dkkw() Fq <- pkkw(0.5, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) all.equal(Fq, integrate(dkkw, 0, 0.5, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, rel.tol = 1e-10)$value)q <- c(0.2, 0.5, 0.8) pkkw(q, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) # P(X > q) pkkw(q, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, lower.tail = FALSE) pkkw(q, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, log.p = TRUE) ## pkkw() is the integral of dkkw() Fq <- pkkw(0.5, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) all.equal(Fq, integrate(dkkw, 0, 0.5, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, rel.tol = 1e-10)$value)
Computes the cumulative distribution function (CDF), , for the
two-parameter Kumaraswamy (Kw) distribution with shape parameters alpha
() and beta (). This distribution is defined
on the interval (0, 1).
pkw(q, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE)pkw(q, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE)
q |
Vector of quantiles (values generally between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The cumulative distribution function (CDF) of the Kumaraswamy (Kw) distribution is given by:
for , , and .
The Kw distribution is a special case of several generalized distributions:
Generalized Kumaraswamy (pgkw) with .
Exponentiated Kumaraswamy (pekw) with .
Kumaraswamy-Kumaraswamy (pkkw) with .
The implementation uses the closed-form expression for efficiency.
A vector of probabilities, , or their logarithms/complements
depending on lower.tail and log.p. The length of the result
is determined by the recycling rule applied to the arguments (q,
alpha, beta). When lower.tail = TRUE, returns
0 (or -Inf if log.p = TRUE) for q <= 0 and
1 (or 0 if log.p = TRUE) for q >= 1. An
out-of-bound or missing parameter is an error, not a return value: the
wrapper stops with a message naming the parameter. An infinite parameter
is not currently intercepted there and reaches the C++ layer, which
treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with some tractability advantages. Statistical Methodology, 6(1), 70-81. doi:10.1016/j.stamet.2008.04.001
pgkw, pekw, pkkw (related generalized CDFs),
dkw, qkw, rkw (other Kw functions),
pbeta
Other cumulative distribution functions:
pbeta_(),
pbkw(),
pekw(),
pgkw(),
pkkw(),
pmc()
q <- c(0.2, 0.5, 0.8) pkw(q, alpha = 2, beta = 3) pkw(q, alpha = 2, beta = 3, lower.tail = FALSE) # P(X > q) pkw(q, alpha = 2, beta = 3, log.p = TRUE) ## pkw() is the integral of dkw() Fq <- pkw(0.5, alpha = 2, beta = 3) all.equal(Fq, integrate(dkw, 0, 0.5, alpha = 2, beta = 3, rel.tol = 1e-10)$value)q <- c(0.2, 0.5, 0.8) pkw(q, alpha = 2, beta = 3) pkw(q, alpha = 2, beta = 3, lower.tail = FALSE) # P(X > q) pkw(q, alpha = 2, beta = 3, log.p = TRUE) ## pkw() is the integral of dkw() Fq <- pkw(0.5, alpha = 2, beta = 3) all.equal(Fq, integrate(dkw, 0, 0.5, alpha = 2, beta = 3, rel.tol = 1e-10)$value)
Computes the cumulative distribution function (CDF), ,
for the McDonald (Mc) distribution (also known as Beta Power) with
parameters gamma (), delta (), and
lambda (). This distribution is defined on the interval
(0, 1) and is a special case of the Generalized Kumaraswamy (GKw)
distribution where and .
pmc(q, gamma = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE)pmc(q, gamma = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE)
q |
Vector of quantiles (values generally between 0 and 1). |
gamma |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The McDonald (Mc) distribution is a special case of the five-parameter
Generalized Kumaraswamy (GKw) distribution (pgkw) obtained
by setting parameters and .
The CDF of the GKw distribution is ,
where and
is the regularized incomplete beta function (pbeta).
Setting and simplifies to ,
yielding the Mc CDF:
This is evaluated using the pbeta function as
pbeta(q^lambda, shape1 = gamma, shape2 = delta + 1).
A vector of probabilities, , or their logarithms/complements
depending on lower.tail and log.p. The length of the result
is determined by the recycling rule applied to the arguments (q,
gamma, delta, lambda). When lower.tail = TRUE,
returns 0 (or -Inf if log.p = TRUE) for q <= 0
and 1 (or 0 if log.p = TRUE) for q >= 1. An
out-of-bound or missing parameter is an error, not a return value: the
wrapper stops with a message naming the parameter. An infinite parameter
is not currently intercepted there and reaches the C++ layer, which
treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
McDonald, J. B. (1984). Some generalized functions for the size distribution of income. Econometrica, 52(3), 647-663. doi:10.2307/1913469
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
pgkw (parent distribution CDF),
dmc, qmc, rmc (other Mc functions),
pbeta
Other cumulative distribution functions:
pbeta_(),
pbkw(),
pekw(),
pgkw(),
pkkw(),
pkw()
q <- c(0.2, 0.5, 0.8) pmc(q, gamma = 0.5, delta = 5, lambda = 3) pmc(q, gamma = 0.5, delta = 5, lambda = 3, lower.tail = FALSE) # P(X > q) pmc(q, gamma = 0.5, delta = 5, lambda = 3, log.p = TRUE) ## pmc() is the integral of dmc() Fq <- pmc(0.5, gamma = 0.5, delta = 5, lambda = 3) all.equal(Fq, integrate(dmc, 0, 0.5, gamma = 0.5, delta = 5, lambda = 3, rel.tol = 1e-10)$value)q <- c(0.2, 0.5, 0.8) pmc(q, gamma = 0.5, delta = 5, lambda = 3) pmc(q, gamma = 0.5, delta = 5, lambda = 3, lower.tail = FALSE) # P(X > q) pmc(q, gamma = 0.5, delta = 5, lambda = 3, log.p = TRUE) ## pmc() is the integral of dmc() Fq <- pmc(0.5, gamma = 0.5, delta = 5, lambda = 3) all.equal(Fq, integrate(dmc, 0, 0.5, gamma = 0.5, delta = 5, lambda = 3, rel.tol = 1e-10)$value)
Computes the quantile function (inverse CDF) for the standard Beta
distribution, using a parameterization common in generalized distribution
families. It finds the value q such that . The
distribution is parameterized by gamma () and delta
(), corresponding to the standard Beta distribution with shape
parameters shape1 = gamma and shape2 = delta + 1.
qbeta_(p, gamma = 1, delta = 0, lower.tail = TRUE, log.p = FALSE)qbeta_(p, gamma = 1, delta = 0, lower.tail = TRUE, log.p = FALSE)
p |
Vector of probabilities (values between 0 and 1). |
gamma |
First shape parameter ( |
delta |
Second shape parameter is |
lower.tail |
Logical; if |
log.p |
Logical; if |
This function computes the quantiles of a Beta distribution with parameters
shape1 = gamma and shape2 = delta + 1. It is equivalent to
calling stats::qbeta(p, shape1 = gamma, shape2 = delta + 1,
lower.tail = lower.tail, log.p = log.p).
This distribution arises as a special case of the five-parameter
Generalized Kumaraswamy (GKw) distribution (qgkw) obtained
by setting , , and .
It is therefore also equivalent to the McDonald (Mc)/Beta Power distribution
(qmc) with .
The function likely calls R's underlying qbeta function but ensures
consistent parameter recycling and handling within the C++ environment,
matching the style of other functions in the related families. Boundary
conditions (p=0, p=1) are handled explicitly.
A vector of quantiles corresponding to the given probabilities p.
The length of the result is determined by the recycling rule applied to
the arguments (p, gamma, delta).
Returns:
0 for p = 0 (or p = -Inf if log.p = TRUE,
when lower.tail = TRUE).
1 for p = 1 (or p = 0 if log.p = TRUE,
when lower.tail = TRUE).
NaN for p < 0 or p > 1 (or corresponding log scale).
An out-of-bound or missing parameter is an error, not a return value: the wrapper stops with a message naming the parameter. An infinite parameter is not currently intercepted there and reaches the C++ layer, which treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Johnson, N. L., Kotz, S., & Balakrishnan, N. (1995). Continuous Univariate Distributions, Volume 2 (2nd ed.). Wiley.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
qbeta (standard R implementation),
qgkw (parent distribution quantile function),
qmc (McDonald/Beta Power quantile function),
dbeta_, pbeta_, rbeta_.
Other quantile functions:
qbkw(),
qekw(),
qgkw(),
qkkw(),
qkw(),
qmc()
p <- c(0.1, 0.5, 0.9) qbeta_(p, gamma = 2, delta = 3) qbeta_(p, gamma = 2, delta = 3, lower.tail = FALSE) # upper-tail quantiles ## qbeta_() inverts pbeta_() all.equal(pbeta_(qbeta_(p, gamma = 2, delta = 3), gamma = 2, delta = 3), p)p <- c(0.1, 0.5, 0.9) qbeta_(p, gamma = 2, delta = 3) qbeta_(p, gamma = 2, delta = 3, lower.tail = FALSE) # upper-tail quantiles ## qbeta_() inverts pbeta_() all.equal(pbeta_(qbeta_(p, gamma = 2, delta = 3), gamma = 2, delta = 3), p)
Computes the quantile function (inverse CDF) for the Beta-Kumaraswamy (BKw)
distribution with parameters alpha (), beta
(), gamma (), and delta ().
It finds the value q such that . This distribution
is a special case of the Generalized Kumaraswamy (GKw) distribution where
the parameter .
qbkw( p, alpha = 1, beta = 1, gamma = 1, delta = 0, lower.tail = TRUE, log.p = FALSE )qbkw( p, alpha = 1, beta = 1, gamma = 1, delta = 0, lower.tail = TRUE, log.p = FALSE )
p |
Vector of probabilities (values between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
gamma |
Shape parameter |
delta |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The quantile function is the inverse of the CDF . The CDF
for the BKw () distribution is ,
where and is the
regularized incomplete beta function (see pbkw).
To find the quantile , we first invert the outer Beta part: let
, where is the
inverse of the regularized incomplete beta function, computed via
qbeta. Then, we invert the inner Kumaraswamy part:
, which leads to .
Substituting gives the quantile function:
The function uses this formula, calculating
via qbeta(p, gamma, delta + 1, ...) while respecting the
lower.tail and log.p arguments.
A vector of quantiles corresponding to the given probabilities p.
The length of the result is determined by the recycling rule applied to
the arguments (p, alpha, beta, gamma, delta).
Returns:
0 for p = 0 (or p = -Inf if log.p = TRUE,
when lower.tail = TRUE).
1 for p = 1 (or p = 0 if log.p = TRUE,
when lower.tail = TRUE).
NaN for p < 0 or p > 1 (or corresponding log scale).
An out-of-bound or missing parameter is an error, not a return value: the wrapper stops with a message naming the parameter. An infinite parameter is not currently intercepted there and reaches the C++ layer, which treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
qgkw (parent distribution quantile function),
dbkw, pbkw, rbkw (other BKw functions),
qbeta
Other quantile functions:
qbeta_(),
qekw(),
qgkw(),
qkkw(),
qkw(),
qmc()
p <- c(0.1, 0.5, 0.9) qbkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) # upper-tail quantiles qbkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lower.tail = FALSE) ## qbkw() inverts pbkw() all.equal(pbkw(qbkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5), alpha = 2, beta = 3, gamma = 1.5, delta = 0.5), p)p <- c(0.1, 0.5, 0.9) qbkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) # upper-tail quantiles qbkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lower.tail = FALSE) ## qbkw() inverts pbkw() all.equal(pbkw(qbkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5), alpha = 2, beta = 3, gamma = 1.5, delta = 0.5), p)
Computes the quantile function (inverse CDF) for the Exponentiated
Kumaraswamy (EKw) distribution with parameters alpha (),
beta (), and lambda ().
It finds the value q such that . This distribution
is a special case of the Generalized Kumaraswamy (GKw) distribution where
and .
qekw(p, alpha = 1, beta = 1, lambda = 1, lower.tail = TRUE, log.p = FALSE)qekw(p, alpha = 1, beta = 1, lambda = 1, lower.tail = TRUE, log.p = FALSE)
p |
Vector of probabilities (values between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
lambda |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The quantile function is the inverse of the CDF . The CDF
for the EKw () distribution is
(see pekw). Inverting this equation for yields the
quantile function:
The function uses this closed-form expression and correctly handles the
lower.tail and log.p arguments by transforming p
appropriately before applying the formula. This is equivalent to the general
GKw quantile function (qgkw) evaluated with .
A vector of quantiles corresponding to the given probabilities p.
The length of the result is determined by the recycling rule applied to
the arguments (p, alpha, beta, lambda).
Returns:
0 for p = 0 (or p = -Inf if log.p = TRUE,
when lower.tail = TRUE).
1 for p = 1 (or p = 0 if log.p = TRUE,
when lower.tail = TRUE).
NaN for p < 0 or p > 1 (or corresponding log scale).
An out-of-bound or missing parameter is an error, not a return value: the wrapper stops with a message naming the parameter. An infinite parameter is not currently intercepted there and reaches the C++ layer, which treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Nadarajah, S., Cordeiro, G. M., & Ortega, E. M. (2012). The exponentiated Kumaraswamy distribution. Journal of the Franklin Institute, 349(3),
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
qgkw (parent distribution quantile function),
dekw, pekw, rekw (other EKw functions),
qunif
Other quantile functions:
qbeta_(),
qbkw(),
qgkw(),
qkkw(),
qkw(),
qmc()
p <- c(0.1, 0.5, 0.9) qekw(p, alpha = 2, beta = 3, lambda = 1.2) # upper-tail quantiles qekw(p, alpha = 2, beta = 3, lambda = 1.2, lower.tail = FALSE) ## qekw() inverts pekw() all.equal(pekw(qekw(p, alpha = 2, beta = 3, lambda = 1.2), alpha = 2, beta = 3, lambda = 1.2), p)p <- c(0.1, 0.5, 0.9) qekw(p, alpha = 2, beta = 3, lambda = 1.2) # upper-tail quantiles qekw(p, alpha = 2, beta = 3, lambda = 1.2, lower.tail = FALSE) ## qekw() inverts pekw() all.equal(pekw(qekw(p, alpha = 2, beta = 3, lambda = 1.2), alpha = 2, beta = 3, lambda = 1.2), p)
Computes the quantile function (inverse CDF) for the five-parameter
Generalized Kumaraswamy (GKw) distribution. Finds the value x such
that , where X follows the GKw distribution.
qgkw( p, alpha = 1, beta = 1, gamma = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE )qgkw( p, alpha = 1, beta = 1, gamma = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE )
p |
Vector of probabilities (values between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
gamma |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The quantile function is the inverse of the CDF .
Given where
, the quantile function is:
where is the inverse of the regularized incomplete beta
function, which corresponds to the quantile function of the Beta distribution,
qbeta.
The computation proceeds as follows:
Calculate y = stats::qbeta(p, shape1 = gamma, shape2 = delta + 1, lower.tail = lower.tail, log.p = log.p).
Calculate .
Calculate . Note: Requires .
Calculate . Note: Requires .
Numerical stability is maintained by handling boundary cases (p = 0,
p = 1) directly and checking intermediate results (e.g., ensuring
arguments to powers are non-negative).
A vector of quantiles corresponding to the given probabilities p.
The length of the result is determined by the recycling rule applied to
the arguments (p, alpha, beta, gamma,
delta, lambda). Returns:
0 for p = 0 (or p = -Inf if log.p = TRUE,
when lower.tail = TRUE).
1 for p = 1 (or p = 0 if log.p = TRUE,
when lower.tail = TRUE).
NaN for p < 0 or p > 1 (or corresponding log scale).
An out-of-bound or missing parameter is an error, not a return value: the wrapper stops with a message naming the parameter. An infinite parameter is not currently intercepted there and reaches the C++ layer, which treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Carrasco, J. M. F., Ferrari, S. L. P., & Cordeiro, G. M. (2010). A new generalized Kumaraswamy distribution. arXiv preprint arXiv:1004.0911. doi:10.48550/arXiv.1004.0911
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Other quantile functions:
qbeta_(),
qbkw(),
qekw(),
qkkw(),
qkw(),
qmc()
p <- c(0.1, 0.5, 0.9) qgkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) qgkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, lower.tail = FALSE) # upper-tail quantiles ## qgkw() inverts pgkw() all.equal(pgkw(qgkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2), alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2), p)p <- c(0.1, 0.5, 0.9) qgkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) qgkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2, lower.tail = FALSE) # upper-tail quantiles ## qgkw() inverts pgkw() all.equal(pgkw(qgkw(p, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2), alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2), p)
Computes the quantile function (inverse CDF) for the Kumaraswamy-Kumaraswamy
(KKw) distribution with parameters alpha (), beta
(), delta (), and lambda ().
It finds the value q such that . This distribution
is a special case of the Generalized Kumaraswamy (GKw) distribution where
the parameter .
qkkw( p, alpha = 1, beta = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE )qkkw( p, alpha = 1, beta = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE )
p |
Vector of probabilities (values between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The quantile function is the inverse of the CDF . The CDF
for the KKw () distribution is (see pkkw):
Inverting this equation for yields the quantile function:
The function uses this closed-form expression and correctly handles the
lower.tail and log.p arguments by transforming p
appropriately before applying the formula.
A vector of quantiles corresponding to the given probabilities p.
The length of the result is determined by the recycling rule applied to
the arguments (p, alpha, beta, delta,
lambda). Returns:
0 for p = 0 (or p = -Inf if log.p = TRUE,
when lower.tail = TRUE).
1 for p = 1 (or p = 0 if log.p = TRUE,
when lower.tail = TRUE).
NaN for p < 0 or p > 1 (or corresponding log scale).
An out-of-bound or missing parameter is an error, not a return value: the wrapper stops with a message naming the parameter. An infinite parameter is not currently intercepted there and reaches the C++ layer, which treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
qgkw (parent distribution quantile function),
dkkw, pkkw, rkkw,
qbeta
Other quantile functions:
qbeta_(),
qbkw(),
qekw(),
qgkw(),
qkw(),
qmc()
p <- c(0.1, 0.5, 0.9) qkkw(p, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) # upper-tail quantiles qkkw(p, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, lower.tail = FALSE) ## qkkw() inverts pkkw() all.equal(pkkw(qkkw(p, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2), alpha = 2, beta = 3, delta = 0.5, lambda = 1.2), p)p <- c(0.1, 0.5, 0.9) qkkw(p, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) # upper-tail quantiles qkkw(p, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2, lower.tail = FALSE) ## qkkw() inverts pkkw() all.equal(pkkw(qkkw(p, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2), alpha = 2, beta = 3, delta = 0.5, lambda = 1.2), p)
Computes the quantile function (inverse CDF) for the two-parameter
Kumaraswamy (Kw) distribution with shape parameters alpha ()
and beta (). It finds the value q such that
.
qkw(p, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE)qkw(p, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE)
p |
Vector of probabilities (values between 0 and 1). |
alpha |
Shape parameter |
beta |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The quantile function is the inverse of the CDF . The CDF
for the Kumaraswamy distribution is
(see pkw). Inverting this equation for yields the
quantile function:
The function uses this closed-form expression and correctly handles the
lower.tail and log.p arguments by transforming p
appropriately before applying the formula. This is equivalent to the general
GKw quantile function (qgkw) evaluated with .
A vector of quantiles corresponding to the given probabilities p.
The length of the result is determined by the recycling rule applied to
the arguments (p, alpha, beta).
Returns:
0 for p = 0 (or p = -Inf if log.p = TRUE,
when lower.tail = TRUE).
1 for p = 1 (or p = 0 if log.p = TRUE,
when lower.tail = TRUE).
NaN for p < 0 or p > 1 (or corresponding log scale).
An out-of-bound or missing parameter is an error, not a return value: the wrapper stops with a message naming the parameter. An infinite parameter is not currently intercepted there and reaches the C++ layer, which treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with some tractability advantages. Statistical Methodology, 6(1), 70-81. doi:10.1016/j.stamet.2008.04.001
qgkw (parent distribution quantile function),
dkw, pkw, rkw (other Kw functions),
qbeta, qunif
Other quantile functions:
qbeta_(),
qbkw(),
qekw(),
qgkw(),
qkkw(),
qmc()
p <- c(0.1, 0.5, 0.9) qkw(p, alpha = 2, beta = 3) qkw(p, alpha = 2, beta = 3, lower.tail = FALSE) # upper-tail quantiles ## qkw() inverts pkw() all.equal(pkw(qkw(p, alpha = 2, beta = 3), alpha = 2, beta = 3), p)p <- c(0.1, 0.5, 0.9) qkw(p, alpha = 2, beta = 3) qkw(p, alpha = 2, beta = 3, lower.tail = FALSE) # upper-tail quantiles ## qkw() inverts pkw() all.equal(pkw(qkw(p, alpha = 2, beta = 3), alpha = 2, beta = 3), p)
Computes the quantile function (inverse CDF) for the McDonald (Mc) distribution
(also known as Beta Power) with parameters gamma (),
delta (), and lambda (). It finds the
value q such that . This distribution is a special
case of the Generalized Kumaraswamy (GKw) distribution where
and .
qmc(p, gamma = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE)qmc(p, gamma = 1, delta = 0, lambda = 1, lower.tail = TRUE, log.p = FALSE)
p |
Vector of probabilities (values between 0 and 1). |
gamma |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
lower.tail |
Logical; if |
log.p |
Logical; if |
The quantile function is the inverse of the CDF . The CDF
for the Mc () distribution is ,
where is the regularized incomplete beta function (see pmc).
To find the quantile , we first invert the Beta function part: let
, where is the
inverse computed via qbeta. We then solve
for , yielding the quantile function:
The function uses this formula, calculating
via qbeta(p, gamma, delta + 1, ...) while respecting the
lower.tail and log.p arguments. This is equivalent to the general
GKw quantile function (qgkw) evaluated with .
A vector of quantiles corresponding to the given probabilities p.
The length of the result is determined by the recycling rule applied to
the arguments (p, gamma, delta, lambda).
Returns:
0 for p = 0 (or p = -Inf if log.p = TRUE,
when lower.tail = TRUE).
1 for p = 1 (or p = 0 if log.p = TRUE,
when lower.tail = TRUE).
NaN for p < 0 or p > 1 (or corresponding log scale).
An out-of-bound or missing parameter is an error, not a return value: the wrapper stops with a message naming the parameter. An infinite parameter is not currently intercepted there and reaches the C++ layer, which treats it as invalid.
Boundary return values are adjusted accordingly for lower.tail = FALSE.
Lopes, J. E.
McDonald, J. B. (1984). Some generalized functions for the size distribution of income. Econometrica, 52(3), 647-663. doi:10.2307/1913469
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
qgkw (parent distribution quantile function),
dmc, pmc, rmc (other Mc functions),
qbeta
Other quantile functions:
qbeta_(),
qbkw(),
qekw(),
qgkw(),
qkkw(),
qkw()
p <- c(0.1, 0.5, 0.9) qmc(p, gamma = 0.5, delta = 5, lambda = 3) # upper-tail quantiles qmc(p, gamma = 0.5, delta = 5, lambda = 3, lower.tail = FALSE) ## qmc() inverts pmc() all.equal(pmc(qmc(p, gamma = 0.5, delta = 5, lambda = 3), gamma = 0.5, delta = 5, lambda = 3), p)p <- c(0.1, 0.5, 0.9) qmc(p, gamma = 0.5, delta = 5, lambda = 3) # upper-tail quantiles qmc(p, gamma = 0.5, delta = 5, lambda = 3, lower.tail = FALSE) ## qmc() inverts pmc() all.equal(pmc(qmc(p, gamma = 0.5, delta = 5, lambda = 3), gamma = 0.5, delta = 5, lambda = 3), p)
Generates random deviates from the standard Beta distribution, using a
parameterization common in generalized distribution families. The distribution
is parameterized by gamma () and delta (),
corresponding to the standard Beta distribution with shape parameters
shape1 = gamma and shape2 = delta + 1. This is a special case
of the Generalized Kumaraswamy (GKw) distribution where ,
, and .
rbeta_(n, gamma = 1, delta = 0)rbeta_(n, gamma = 1, delta = 0)
n |
Number of observations. If |
gamma |
First shape parameter ( |
delta |
Second shape parameter is |
This function generates samples from a Beta distribution with parameters
shape1 = gamma and shape2 = delta + 1. It is equivalent to
calling stats::rbeta(n, shape1 = gamma, shape2 = delta + 1).
This distribution arises as a special case of the five-parameter
Generalized Kumaraswamy (GKw) distribution (rgkw) obtained
by setting , , and .
It is therefore also equivalent to the McDonald (Mc)/Beta Power distribution
(rmc) with .
The function likely calls R's underlying rbeta function but ensures
consistent parameter recycling and handling within the C++ environment,
matching the style of other functions in the related families.
A numeric vector of length n containing random deviates from the
Beta() distribution, with values in (0, 1). The length
of the result is determined by n and the recycling rule applied to
the parameters (gamma, delta). An out-of-bound or missing parameter is an
error, not a return value: the wrapper stops with a message naming the
parameter. An infinite parameter is not currently intercepted there and
reaches the C++ layer, which treats it as invalid.
Lopes, J. E.
Johnson, N. L., Kotz, S., & Balakrishnan, N. (1995). Continuous Univariate Distributions, Volume 2 (2nd ed.). Wiley.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag.
rbeta (standard R implementation),
rgkw (parent distribution random generation),
rmc (McDonald/Beta Power random generation),
dbeta_, pbeta_, qbeta_.
Other random generation functions:
rbkw(),
rekw(),
rgkw(),
rkkw(),
rkw(),
rmc()
set.seed(123) x <- rbeta_(1000, gamma = 2, delta = 3) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dbeta_(x, gamma = 2, delta = 3), add = TRUE) ks.test(x, pbeta_, gamma = 2, delta = 3)set.seed(123) x <- rbeta_(1000, gamma = 2, delta = 3) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dbeta_(x, gamma = 2, delta = 3), add = TRUE) ks.test(x, pbeta_, gamma = 2, delta = 3)
Generates random deviates from the Beta-Kumaraswamy (BKw) distribution
with parameters alpha (), beta (),
gamma (), and delta (). This distribution
is a special case of the Generalized Kumaraswamy (GKw) distribution where
the parameter .
rbkw(n, alpha = 1, beta = 1, gamma = 1, delta = 0)rbkw(n, alpha = 1, beta = 1, gamma = 1, delta = 0)
n |
Number of observations. If |
alpha |
Shape parameter |
beta |
Shape parameter |
gamma |
Shape parameter |
delta |
Shape parameter |
The generation method uses the relationship between the GKw distribution and the
Beta distribution. The general procedure for GKw (rgkw) is:
If , then
follows the
GKw() distribution.
For the BKw distribution, . Therefore, the algorithm simplifies to:
Generate using
rbeta.
Compute the BKw variate .
This procedure is implemented efficiently, handling parameter recycling as needed.
A vector of length n containing random deviates from the BKw
distribution. The length of the result is determined by n and the
recycling rule applied to the parameters (alpha, beta,
gamma, delta). An out-of-bound or missing parameter is an
error, not a return value: the wrapper stops with a message naming the
parameter. An infinite parameter is not currently intercepted there and
reaches the C++ layer, which treats it as invalid.
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag. (General methods for random variate generation).
rgkw (parent distribution random generation),
dbkw, pbkw, qbkw (other BKw functions),
rbeta
Other random generation functions:
rbeta_(),
rekw(),
rgkw(),
rkkw(),
rkw(),
rmc()
set.seed(123) x <- rbkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dbkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5), add = TRUE) ks.test(x, pbkw, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5)set.seed(123) x <- rbkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dbkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5), add = TRUE) ks.test(x, pbkw, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5)
Generates random deviates from the Exponentiated Kumaraswamy (EKw)
distribution with parameters alpha (), beta
(), and lambda (). This distribution is a
special case of the Generalized Kumaraswamy (GKw) distribution where
and .
rekw(n, alpha = 1, beta = 1, lambda = 1)rekw(n, alpha = 1, beta = 1, lambda = 1)
n |
Number of observations. If |
alpha |
Shape parameter |
beta |
Shape parameter |
lambda |
Shape parameter |
The generation method uses the inverse transform (quantile) method.
That is, if is a random variable following a standard Uniform
distribution on (0, 1), then follows the EKw distribution,
where is the EKw quantile function (qekw):
This is computationally equivalent to the general GKw generation method
(rgkw) when specialized for , as the
required Beta(1, 1) random variate is equivalent to a standard Uniform(0, 1)
variate. The implementation generates using runif
and applies the transformation above.
A vector of length n containing random deviates from the EKw
distribution. The length of the result is determined by n and the
recycling rule applied to the parameters (alpha, beta,
lambda). An out-of-bound or missing parameter is an
error, not a return value: the wrapper stops with a message naming the
parameter. An infinite parameter is not currently intercepted there and
reaches the C++ layer, which treats it as invalid.
Lopes, J. E.
Nadarajah, S., Cordeiro, G. M., & Ortega, E. M. (2012). The exponentiated Kumaraswamy distribution. Journal of the Franklin Institute, 349(3),
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag. (General methods for random variate generation).
rgkw (parent distribution random generation),
dekw, pekw, qekw (other EKw functions),
runif
Other random generation functions:
rbeta_(),
rbkw(),
rgkw(),
rkkw(),
rkw(),
rmc()
set.seed(123) x <- rekw(1000, alpha = 2, beta = 3, lambda = 1.2) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dekw(x, alpha = 2, beta = 3, lambda = 1.2), add = TRUE) ks.test(x, pekw, alpha = 2, beta = 3, lambda = 1.2)set.seed(123) x <- rekw(1000, alpha = 2, beta = 3, lambda = 1.2) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dekw(x, alpha = 2, beta = 3, lambda = 1.2), add = TRUE) ks.test(x, pekw, alpha = 2, beta = 3, lambda = 1.2)
Generates random deviates from the five-parameter Generalized Kumaraswamy (GKw) distribution defined on the interval (0, 1).
rgkw(n, alpha = 1, beta = 1, gamma = 1, delta = 0, lambda = 1)rgkw(n, alpha = 1, beta = 1, gamma = 1, delta = 0, lambda = 1)
n |
Number of observations. If |
alpha |
Shape parameter |
beta |
Shape parameter |
gamma |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
The generation method relies on the transformation property: if
, then the random variable X
defined as
follows the GKw() distribution.
The algorithm proceeds as follows:
Generate V from stats::rbeta(n, shape1 = gamma, shape2 = delta + 1).
Calculate .
Calculate .
Calculate .
Parameters (alpha, beta, gamma, delta, lambda)
are recycled to match the length required by n. Numerical stability is
maintained by handling potential edge cases during the transformations.
A vector of length n containing random deviates from the GKw
distribution. The length of the result is determined by n and the
recycling rule applied to the parameters (alpha, beta,
gamma, delta, lambda). An out-of-bound or missing parameter is an
error, not a return value: the wrapper stops with a message naming the
parameter. An infinite parameter is not currently intercepted there and
reaches the C++ layer, which treats it as invalid.
Lopes, J. E.
Carrasco, J. M. F., Ferrari, S. L. P., & Cordeiro, G. M. (2010). A new generalized Kumaraswamy distribution. arXiv preprint arXiv:1004.0911. doi:10.48550/arXiv.1004.0911
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
dgkw, pgkw, qgkw,
rbeta, set.seed
Other random generation functions:
rbeta_(),
rbkw(),
rekw(),
rkkw(),
rkw(),
rmc()
set.seed(123) x <- rgkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2), add = TRUE) ks.test(x, pgkw, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2)set.seed(123) x <- rgkw(1000, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dgkw(x, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2), add = TRUE) ks.test(x, pgkw, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5, lambda = 1.2)
Generates random deviates from the Kumaraswamy-Kumaraswamy (KKw)
distribution with parameters alpha (), beta
(), delta (), and lambda ().
This distribution is a special case of the Generalized Kumaraswamy (GKw)
distribution where the parameter .
rkkw(n, alpha = 1, beta = 1, delta = 0, lambda = 1)rkkw(n, alpha = 1, beta = 1, delta = 0, lambda = 1)
n |
Number of observations. If |
alpha |
Shape parameter |
beta |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
The generation method uses the inverse transform method based on the quantile
function (qkkw). The KKw quantile function is:
Random deviates are generated by evaluating where is a
random variable following the standard Uniform distribution on (0, 1)
(runif).
This is equivalent to the general method for the GKw distribution
(rgkw) specialized for . The GKw method generates
and then applies transformations.
When , , which can be
generated via where .
Substituting this into the GKw transformation yields the same result
as evaluating above (noting is also Uniform).
A vector of length n containing random deviates from the KKw
distribution. The length of the result is determined by n and the
recycling rule applied to the parameters (alpha, beta,
delta, lambda). An out-of-bound or missing parameter is an
error, not a return value: the wrapper stops with a message naming the
parameter. An infinite parameter is not currently intercepted there and
reaches the C++ layer, which treats it as invalid.
Lopes, J. E.
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag. (General methods for random variate generation).
rgkw (parent distribution random generation),
dkkw, pkkw, qkkw,
runif, rbeta
Other random generation functions:
rbeta_(),
rbkw(),
rekw(),
rgkw(),
rkw(),
rmc()
set.seed(123) x <- rkkw(1000, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dkkw(x, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2), add = TRUE) ks.test(x, pkkw, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2)set.seed(123) x <- rkkw(1000, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dkkw(x, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2), add = TRUE) ks.test(x, pkkw, alpha = 2, beta = 3, delta = 0.5, lambda = 1.2)
Generates random deviates from the two-parameter Kumaraswamy (Kw)
distribution with shape parameters alpha () and
beta ().
rkw(n, alpha = 1, beta = 1)rkw(n, alpha = 1, beta = 1)
n |
Number of observations. If |
alpha |
Shape parameter |
beta |
Shape parameter |
The generation method uses the inverse transform (quantile) method.
That is, if is a random variable following a standard Uniform
distribution on (0, 1), then follows the Kw distribution,
where is the Kw quantile function (qkw):
The implementation generates using runif
and applies this transformation. This is equivalent to the general GKw
generation method (rgkw) evaluated at .
A vector of length n containing random deviates from the Kw
distribution, with values in (0, 1). The length of the result is determined
by n and the recycling rule applied to the parameters (alpha,
beta). An out-of-bound or missing parameter is an
error, not a return value: the wrapper stops with a message naming the
parameter. An infinite parameter is not currently intercepted there and
reaches the C++ layer, which treats it as invalid.
Lopes, J. E.
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with some tractability advantages. Statistical Methodology, 6(1), 70-81. doi:10.1016/j.stamet.2008.04.001
Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag. (General methods for random variate generation).
rgkw (parent distribution random generation),
dkw, pkw, qkw (other Kw functions),
runif
Other random generation functions:
rbeta_(),
rbkw(),
rekw(),
rgkw(),
rkkw(),
rmc()
set.seed(123) x <- rkw(1000, alpha = 2, beta = 3) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dkw(x, alpha = 2, beta = 3), add = TRUE) ks.test(x, pkw, alpha = 2, beta = 3)set.seed(123) x <- rkw(1000, alpha = 2, beta = 3) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dkw(x, alpha = 2, beta = 3), add = TRUE) ks.test(x, pkw, alpha = 2, beta = 3)
Generates random deviates from the McDonald (Mc) distribution (also known as
Beta Power) with parameters gamma (), delta
(), and lambda (). This distribution is a
special case of the Generalized Kumaraswamy (GKw) distribution where
and .
rmc(n, gamma = 1, delta = 0, lambda = 1)rmc(n, gamma = 1, delta = 0, lambda = 1)
n |
Number of observations. If |
gamma |
Shape parameter |
delta |
Shape parameter |
lambda |
Shape parameter |
The generation method uses the relationship between the GKw distribution and the
Beta distribution. The general procedure for GKw (rgkw) is:
If , then
follows the
GKw() distribution.
For the Mc distribution, and . Therefore, the
algorithm simplifies significantly:
Generate using
rbeta.
Compute the Mc variate .
This procedure is implemented efficiently, handling parameter recycling as needed.
A vector of length n containing random deviates from the Mc
distribution, with values in (0, 1). The length of the result is determined
by n and the recycling rule applied to the parameters (gamma,
delta, lambda). An out-of-bound or missing parameter is an
error, not a return value: the wrapper stops with a message naming the
parameter. An infinite parameter is not currently intercepted there and
reaches the C++ layer, which treats it as invalid.
Lopes, J. E.
McDonald, J. B. (1984). Some generalized functions for the size distribution of income. Econometrica, 52(3), 647-663. doi:10.2307/1913469
Cordeiro, G. M., & de Castro, M. (2011). A new family of generalized distributions. Journal of Statistical Computation and Simulation, 81(7), 883-898. doi:10.1080/00949650903530745
Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology, 46(1-2), 79-88. doi:10.1016/0022-1694(80)90036-0
Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag. (General methods for random variate generation).
rgkw (parent distribution random generation),
dmc, pmc, qmc (other Mc functions),
rbeta
Other random generation functions:
rbeta_(),
rbkw(),
rekw(),
rgkw(),
rkkw(),
rkw()
set.seed(123) x <- rmc(1000, gamma = 0.5, delta = 5, lambda = 3) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dmc(x, gamma = 0.5, delta = 5, lambda = 3), add = TRUE) ks.test(x, pmc, gamma = 0.5, delta = 5, lambda = 3)set.seed(123) x <- rmc(1000, gamma = 0.5, delta = 5, lambda = 3) summary(x) ## The sample follows the distribution hist(x, breaks = 30, freq = FALSE, main = "") curve(dmc(x, gamma = 0.5, delta = 5, lambda = 3), add = TRUE) ks.test(x, pmc, gamma = 0.5, delta = 5, lambda = 3)