Package {cvcqv}


Type: Package
Title: Coefficient of Variation (CV) with Confidence Intervals (CI)
Version: 1.0.3
Date: 2026-05-08
Maintainer: Maani Beigy <manibeygi@gmail.com>
Description: Provides some easy-to-use functions and classes to calculate variability measures such as coefficient of variation with confidence intervals provided with all available methods. References are 'Panichkitkosolkul' (2013) <doi:10.1155/2013/324940>, 'Altunkaynak' & 'Gamgam' (2018) <doi:10.1080/03610918.2018.1435800>, 'Albatineh', 'Kibria', Wilcox & 'Zogheib' (2014) <doi:10.1080/02664763.2013.847405>.
Depends: R (≥ 3.5.0), dplyr (≥ 0.8.0.1)
Imports: R6, SciViews, boot, MBESS
Suggests: testthat, knitr, rmarkdown, covr
VignetteBuilder: knitr
URL: https://github.com/MaaniBeigy/cvcqv
BugReports: https://github.com/MaaniBeigy/cvcqv/issues
License: GPL-3
Encoding: UTF-8
RoxygenNote: 8.0.0
Config/roxygen2/version: 8.0.0
NeedsCompilation: no
Packaged: 2026-05-07 22:19:14 UTC; 20240700
Author: Maani Beigy [aut, cre]
Repository: CRAN
Date/Publication: 2026-05-21 09:30:07 UTC

R6 Bootstrap Resampling for Coefficient of Quartile Variation

Description

The R6 class BootCoefQuartVar produces the bootstrap resampling for the coefficient of quartile variation (cqv) of the given numeric vectors. It uses boot from the package boot. Also, it produces the bootstrap confidence intervals for the cqv based on the boot.ci from the package boot.

Arguments

x

An R object. Currently there are methods for numeric vectors

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

alpha

The allowed type I error probability

R

integer indicating the number of bootstrap replicates.

References

Canty, A., & Ripley, B, 2017, boot: Bootstrap R (S-Plus) Functions. R package version 1.3-20.

Davison, AC., & Hinkley, DV., 1997, Bootstrap Methods and Their Applications. Cambridge University Press, Cambridge. ISBN 0-521-57391-2

Altunkaynak, B., Gamgam, H., 2018, Bootstrap confidence intervals for the coefficient of quartile variation, Simulation and Computation, 1-9, DOI: doi:10.1080/03610918.2018.1435800

Examples

x <- c(
    0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4,
    4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9
)
cqv_x <- BootCoefQuartVar$new(x)
cqv_x$boot_cqv()
cqv_x$boot_basic_ci()
cqv_x$boot_norm_ci()
cqv_x$boot_perc_ci()
cqv_x$boot_bca_ci()
R6::is.R6(cqv_x)

R6 Bootstrap Resampling for Coefficient of Variation

Description

The R6 class BootCoefVar produces the bootstrap resampling for the coefficient of variation (cv) of the given numeric vectors. It uses boot and boot.ci from the package boot.

Arguments

x

An R object. Currently there are methods for numeric vectors

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

alpha

The allowed type I error probability

R

integer indicating the number of bootstrap replicates.

References

Canty, A., & Ripley, B, 2017, boot: Bootstrap R (S-Plus) Functions. R package version 1.3-20.

Davison, AC., & Hinkley, DV., 1997, Bootstrap Methods and Their Applications. Cambridge University Press, Cambridge. ISBN 0-521-57391-2

Examples

x <- c(
    0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4,
    4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9
)
cv_x <- BootCoefVar$new(x)
cv_x$boot_cv()
cv_x$boot_cv_corr()
cv_x$boot_basic_ci_cv()
cv_x$boot_norm_ci_cv()
cv_x$boot_perc_ci_cv()
cv_x$boot_bca_ci_cv()
cv_x$boot_basic_ci_cv_corr()
cv_x$boot_norm_ci_cv_corr()
cv_x$boot_perc_ci_cv_corr()
cv_x$boot_bca_ci_cv_corr()
R6::is.R6(cv_x)

R6 Coefficient of Quartile Variation (cqv)

Description

The R6 class CoefQuartVar for the coefficient of quartile variation (cqv)

Arguments

x

An R object. Currently there are methods for numeric vectors

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

digits

integer indicating the number of decimal places to be used.

Details

Coefficient of Quartile Variation

cqv is a measure of relative dispersion that is based on interquartile range (iqr). Since cqv is unitless, it is useful for comparison of variables with different units. It is also a measure of homogeneity [1].

References

[1] Bonett, DG., 2006, Confidence interval for a coefficient of quartile variation, Computational Statistics & Data Analysis, 50(11), 2953-7, DOI: doi:10.1016/j.csda.2005.05.007

Examples

x <- c(
   0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4,
   4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9
)
CoefQuartVar$new(x)$est()
cqv_x <- CoefQuartVar$new(x, digits = 2)
cqv_x$est()
R6::is.R6(cqv_x)

R6 Confidence Intervals for the Coefficient of Quartile Variation (cqv)

Description

The R6 class CoefQuartVarCI for the confidence intervals of coefficient of quartile variation (cqv)

Arguments

x

An R object. Currently there are methods for numeric vectors

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

digits

integer indicating the number of decimal places to be used.

methods

the available computation methods of confidence intervals are: "bonett_ci", "norm_ci", "basic_ci", "perc_ci", "bca_ci" or "all_ci".

R

integer indicating the number of bootstrap replicates.

Details

Coefficient of Quartile Variation

The cqv is a measure of relative dispersion that is based on interquartile range (iqr). Since cqv is unitless, it is useful for comparison of variables with different units. It is also a measure of homogeneity [1, 2].

Value

An object of type "list" which contains the estimate, the intervals, and the computation method. It has two components:

$method

A description of statistical method used for the computations.

$statistics

A data frame representing three vectors: est, lower and upper limits of 95% confidence interval (CI):

est: cqv*100

Bonett 95% CI: It uses a centering adjustment which helps to equalize the tail error probabilities [1, 2].

Normal approximation 95% CI: The intervals calculated by the normal approximation [3, 4], using boot.ci.

Basic bootstrap 95% CI: The intervals calculated by the basic bootstrap method [3, 4], using boot.ci.

Bootstrap percentile 95% CI: The intervals calculated by the bootstrap percentile method [3, 4], using boot.ci.

Adjusted bootstrap percentile (BCa) 95% CI: The intervals calculated by the adjusted bootstrap percentile (BCa) method [3, 4], using boot.ci.

References

[1] Bonett, DG., 2006, Confidence interval for a coefficient of quartile variation, Computational Statistics & Data Analysis, 50(11), 2953-7, DOI: doi:10.1016/j.csda.2005.05.007

[2] Altunkaynak, B., Gamgam, H., 2018, Bootstrap confidence intervals for the coefficient of quartile variation, Simulation and Computation, 1-9, DOI: doi:10.1080/03610918.2018.1435800

[3] Canty, A., & Ripley, B, 2017, boot: Bootstrap R (S-Plus) Functions. R package version 1.3-20.

[4] Davison, AC., & Hinkley, DV., 1997, Bootstrap Methods and Their Applications. Cambridge University Press, Cambridge. ISBN 0-521-57391-2

Examples

y <- c(
0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4,
4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9
)
CoefQuartVarCI$new(x = y)$bonett_ci()
cqv_y <- CoefQuartVarCI$new(
    x = y,
    alpha = 0.05,
    R = 1000,
    digits = 2
)
cqv_y$bonett_ci()
R6::is.R6(cqv_y)

R6 Coefficient of Variation (cv)

Description

The R6 class CoefVar for the coefficient of variation (cv)

Arguments

x

An R object. Currently there are methods for numeric vectors

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

digits

integer indicating the number of decimal places to be used.

Details

Coefficient of Variation

The cv is a measure of relative dispersion representing the degree of variability relative to the mean [1]. Since cv is unitless, it is useful for comparison of variables with different units. It is also a measure of homogeneity [1].

References

[1] Albatineh, AN., Kibria, BM., Wilcox, ML., & Zogheib, B, 2014, Confidence interval estimation for the population coefficient of variation using ranked set sampling: A simulation study, Journal of Applied Statistics, 41(4), 733–751, DOI: doi:10.1080/02664763.2013.847405

Examples

x <- c(
    0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4,
    4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9
)
CoefVar$new(x)$est()
cv_x <- CoefVar$new(x, digits = 2)
cv_x$est()
cv_x$est_corr()
R6::is.R6(cv_x)

R6 Confidence Intervals for the Coefficient of Variation (cv)

Description

The R6 class CoefVarCI for the confidence intervals of coefficient of variation (cv)

Arguments

x

An R object. Currently there are methods for numeric vectors

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

digits

integer indicating the number of decimal places to be used.

method

a scalar representing the type of confidence intervals required. The value should be any of the values "kelley_ci", "mckay_ci", "miller_ci", "vangel_ci", "mahmoudvand_hassani_ci", "equal_tailed_ci", "shortest_length_ci", "normal_approximation_ci", "norm_ci","basic_ci", or "all_ci".

alpha

The allowed type I error probability

R

integer indicating the number of bootstrap replicates.

correction

returns the unbiased estimate of the coefficient of variation if TRUE is determined.

Details

Coefficient of Variation

The cv is a measure of relative dispersion representing the degree of variability relative to the mean [1]. Since cv is unitless, it is useful for comparison of variables with different units. It is also a measure of homogeneity [1].

Value

An object of type "list" which contains the estimate, the intervals, and the computation method. It has two main components:

$method

A description of statistical method used for the computations.

$statistics

A data frame representing three vectors: est/, lower and upper limits of confidence interval (CI); additional description vector is provided when "all" is selected:

est: cv*100

Kelley Confidence Interval: Thanks to package MBESS [2] for the computation of confidence limits for the noncentrality parameter from a t distribution conf.limits.nct [3].

McKay Confidence Interval: The intervals calculated by the method introduced by McKay [4], using chi-square distribution.

Miller Confidence Interval: The intervals calculated by the method introduced by Miller [5], using the standard normal distribution.

Vangel Confidence Interval: Vangel [6] proposed a method for the calculation of CI for cv; which is a modification on McKay’s CI.

Mahmoudvand-Hassani Confidence Interval: Mahmoudvand and Hassani [7] proposed a new CI for cv; which is obtained using ranked set sampling (RSS)

Normal Approximation Confidence Interval: Wararit Panichkitkosolkul [8] proposed another CI for cv; which is a normal approximation.

Shortest-Length Confidence Interval: Wararit Panichkitkosolkul [8] proposed another CI for cv; which is obtained through minimizing the length of CI.

Equal-Tailed Confidence Interval: Wararit Panichkitkosolkul [8] proposed another CI for cv; which is obtained using chi-square distribution.

Bootstrap Confidence Intervals: Thanks to package boot by Canty & Ripley [9] we can obtain bootstrap CI around cv using boot.ci.

References

[1] Albatineh, AN., Kibria, BM., Wilcox, ML., & Zogheib, B, 2014, Confidence interval estimation for the population coefficient of variation using ranked set sampling: A simulation study, Journal of Applied Statistics, 41(4), 733–751, DOI: doi:10.1080/02664763.2013.847405

[2] Kelley, K., 2018, MBESS: The MBESS R Package. R package version 4.4. 3.

[3] Kelley, K., 2007, Sample size planning for the coefficient of variation from the accuracy in parameter estimation approach, Behavior Research Methods, 39(4), 755–766, DOI: doi:10.3758/BF03192966

[4] McKay, AT., 1932, Distribution of the Coefficient of Variation and the Extended“ t” Distribution, Journal of the Royal Statistical Society, 95(4), 695–698

[5] Miller, E., 1991, Asymptotic test statistics for coefficients of variation, Communications in Statistics-Theory and Methods, 20(10), 3351–3363

[6] Vangel, MG., 1996, Confidence intervals for a normal coefficient of variation, The American Statistician, 50(1), 21–26

[7] Mahmoudvand, R., & Hassani, H., 2009, Two new confidence intervals for the coefficient of variation in a normal distribution, Journal of Applied Statistics, 36(4), 429–442

[8] Panichkitkosolkul, W., 2013, Confidence Intervals for the Coefficient of Variation in a Normal Distribution with a Known Population Mean, Journal of Probability and Statistics, 2013, 1–11, doi:10.1155/2013/324940

[9] Canty, A., & Ripley, B., 2017, boot: Bootstrap R (S-Plus) Functions, R package version 1.3-20

Examples

y <- c(
    0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4,
    4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9
)
CoefVarCI$new(x = y)$kelley_ci()
cv_y <- CoefVarCI$new(
   x = y,
   alpha = 0.05,
   R = 1000,
   digits = 2,
   correction = TRUE
)
cv_y$kelley_ci()
cv_y$mckay_ci()
R6::is.R6(cv_y)

R6 Sample Quantiles

Description

The R6 class SampleQuantiles produces the sample quantiles corresponding to the given probabilities. It uses quantile from the package stats.

Arguments

x

An R object. Currently there are methods for numeric vectors

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

digits

integer indicating the number of decimal places to be used.

probs

numeric vector of probabilities with values in [0,1].

names

logical; if TRUE, the result has a names attribute regarding the percentiles.

type

an integer between 1 and 9 selecting one of the nine quantile algorithms explained in quantile to be used.

Examples

x <- c(
   0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4,
   4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9
)
SampleQuantiles$new(x)$qx()
percentile_95 <-  SampleQuantiles$new(x, na.rm = TRUE, digits = 2, probs = 0.95)
percentile_95$qx()
percentile_75 <-  SampleQuantiles$new(x, na.rm = TRUE, digits = 3, probs = 0.75)
percentile_75$qx()
R6::is.R6(percentile_95)

Coefficient of Quartile Variation (cqv)

Description

Versatile function for the coefficient of quartile variation (cqv)

Arguments

x

An R object. Currently there are methods for numeric vectors

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

digits

integer indicating the number of decimal places to be used.

method

a scalar representing the type of confidence intervals required. The value should be any of the values "bonett", "norm", "basic", "perc", "bca" or "all".

R

integer indicating the number of bootstrap replicates.

Details

Coefficient of Quartile Variation

The cqv is a measure of relative dispersion that is based on interquartile range (iqr). Since cqv is unitless, it is useful for comparison of variables with different units. It is also a measure of homogeneity [1, 2].

Value

An object of type "list" which contains the estimate, the intervals, and the computation method. It has two components:

$method

A description of statistical method used for the computations.

$statistics

A data frame representing three vectors: est, lower and upper limits of 95% confidence interval (CI):

est: cqv*100

Bonett 95% CI: It uses a centering adjustment which helps to equalize the tail error probabilities [1, 2].

Normal approximation 95% CI: The intervals calculated by the normal approximation [3, 4], using boot.ci.

Basic bootstrap 95% CI: The intervals calculated by the basic bootstrap method [3, 4], using boot.ci.

Bootstrap percentile 95% CI: The intervals calculated by the bootstrap percentile method [3, 4], using boot.ci.

Adjusted bootstrap percentile (BCa) 95% CI: The intervals calculated by the adjusted bootstrap percentile (BCa) method [3, 4], using boot.ci.

References

[1] Bonett, DG., 2006, Confidence interval for a coefficient of quartile variation, Computational Statistics & Data Analysis, 50(11), 2953-7, DOI: doi:10.1016/j.csda.2005.05.007

[2] Altunkaynak, B., Gamgam, H., 2018, Bootstrap confidence intervals for the coefficient of quartile variation, Simulation and Computation, 1-9, DOI: doi:10.1080/03610918.2018.1435800

[3] Canty, A., & Ripley, B, 2017, boot: Bootstrap R (S-Plus) Functions. R package version 1.3-20.

[4] Davison, AC., & Hinkley, DV., 1997, Bootstrap Methods and Their Applications. Cambridge University Press, Cambridge. ISBN 0-521-57391-2

Examples

x <- c(
    0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4,
    4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9
)
cqv_versatile(x)
cqv_versatile(x, na.rm = TRUE, digits = 2)
cqv_versatile(x, na.rm = TRUE, digits = 2, method = "bonett")

Coefficient of Variation (cv)

Description

Versatile function for the coefficient of variation (cv)

Arguments

x

An R object. Currently there are methods for numeric vectors

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

digits

integer indicating the number of decimal places to be used.

method

a scalar representing the type of confidence intervals required. The value should be any of the values "kelley", "mckay", "miller", "vangel", "mahmoudvand_hassani", "equal_tailed", "shortest_length", "normal_approximation", "norm","basic", or "all".

correction

returns the unbiased estimate of the coefficient of variation

alpha

The allowed type I error probability

R

integer indicating the number of bootstrap replicates.

Details

Coefficient of Variation

The cv is a measure of relative dispersion representing the degree of variability relative to the mean [1]. Since cv is unitless, it is useful for comparison of variables with different units. It is also a measure of homogeneity [1].

Value

An object of type "list" which contains the estimate, the intervals, and the computation method. It has two main components:

$method

A description of statistical method used for the computations.

$statistics

A data frame representing three vectors: est, lower and upper limits of confidence interval (CI); additional description vector is provided when "all" is selected:

est: cv*100

Kelley Confidence Interval: Thanks to package MBESS [2] for the computation of confidence limits for the noncentrality parameter from a t distribution conf.limits.nct [3].

McKay Confidence Interval: The intervals calculated by the method introduced by McKay [4], using chi-square distribution.

Miller Confidence Interval: The intervals calculated by the method introduced by Miller [5], using the standard normal distribution.

Vangel Confidence Interval: Vangel [6] proposed a method for the calculation of CI for cv; which is a modification on McKay’s CI.

Mahmoudvand-Hassani Confidence Interval: Mahmoudvand and Hassani [7] proposed a new CI for cv; which is obtained using ranked set sampling (RSS)

Normal Approximation Confidence Interval: Wararit Panichkitkosolkul [8] proposed another CI for cv; which is a normal approximation.

Shortest-Length Confidence Interval: Wararit Panichkitkosolkul [8] proposed another CI for cv; which is obtained through minimizing the length of CI.

Equal-Tailed Confidence Interval: Wararit Panichkitkosolkul [8] proposed another CI for cv; which is obtained using chi-square distribution.

Bootstrap Confidence Intervals: Thanks to package boot by Canty & Ripley [9] we can obtain bootstrap CI around cv using boot.ci.

References

[1] Albatineh, AN., Kibria, BM., Wilcox, ML., & Zogheib, B, 2014, Confidence interval estimation for the population coefficient of variation using ranked set sampling: A simulation study, Journal of Applied Statistics, 41(4), 733–751, DOI: doi:10.1080/02664763.2013.847405

[2] Kelley, K., 2018, MBESS: The MBESS R Package. R package version 4.4. 3.

[3] Kelley, K., 2007, Sample size planning for the coefficient of variation from the accuracy in parameter estimation approach, Behavior Research Methods, 39(4), 755–766, DOI: doi:10.3758/BF03192966

[4] McKay, AT., 1932, Distribution of the Coefficient of Variation and the Extended“ t” Distribution, Journal of the Royal Statistical Society, 95(4), 695–698

[5] Miller, E., 1991, Asymptotic test statistics for coefficients of variation, Communications in Statistics-Theory and Methods, 20(10), 3351–3363

[6] Vangel, MG., 1996, Confidence intervals for a normal coefficient of variation, The American Statistician, 50(1), 21–26

[7] Mahmoudvand, R., & Hassani, H., 2009, Two new confidence intervals for the coefficient of variation in a normal distribution, Journal of Applied Statistics, 36(4), 429–442

[8] Panichkitkosolkul, W., 2013, Confidence Intervals for the Coefficient of Variation in a Normal Distribution with a Known Population Mean, Journal of Probability and Statistics, 2013, 1–11, doi:10.1155/2013/324940

[9] Canty, A., & Ripley, B., 2017, boot: Bootstrap R (S-Plus) Functions, R package version 1.3-20

Examples

x <- c(
    0.2, 0.5, 1.1, 1.4, 1.8, 2.3, 2.5, 2.7, 3.5, 4.4,
    4.6, 5.4, 5.4, 5.7, 5.8, 5.9, 6.0, 6.6, 7.1, 7.9
)
cv_versatile(x)
cv_versatile(x, correction = TRUE)
cv_versatile(x, na.rm = TRUE, digits = 3, method = "kelley", correction = TRUE)
cv_versatile(x, na.rm = TRUE, method = "mahmoudvand_hassani", correction = TRUE)