cvcqv

cvcqv provides some easy-to-use functions and classes to calculate Coefficient of Variation (cv) and Coefficient of Quartile Variation (cqv) with confidence intervals provided with all available methods.

Overview

Background

There are abundant methods available for the calculation of confidence intervals of a dispersion measure like coefficient of variation (cv) or coefficient of quartile variation (cqv), which have not yet been implemented in R. Also, cqv is quite useful in conditions where the distribution of variables does not follow normal distribution.

Coefficient of Variation

cv is a measure of relative dispersion representing the degree of variability relative to the mean (Albatineh et al, 2014). Since cv is unitless, it is useful for comparison of variables with different units. It is also a measure of homogeneity (Albatineh et al, 2014).

Coefficient of Quartile Variation

cqv is a measure of relative dispersion that is based on interquartile range (IQR). Since cqv is unitless, it is also useful for comparison of variables with different units. It is also a measure of homogeneity (Bonett, 2006; Altunkaynak, 2018).

Confidence Interval

Since the measurements of cv and cqv are obtained from samples, we cannot easily generalize them and decide based upon them. Confidence Intervals (CI) help us to make a probabilistic interval around the estimation of calculated cv and cqv. For example, 95% CI indicates that it is 95% probable that the measurement for a population lies between the lower and upper bounds of that CI.

Aims

The authors' intention is to create a small R package adhering to K-I-S-S principle to facilitate the use of the most available rigorous methods for calculation of confidence intervals around the variability measures of cv and cqv.

Convention

We are bound by the high standards of functional programming (FP) and object-oriented programming (OOP). The majority of tools provided by cvcqv are developed as both FP tools and R6 classes, for sake of versatility, portability and efficiency.

Getting started

If you are an ubuntu user, you are going to need these non-R packages:

sudo apt install libcurl4-openssl-dev libssl-dev libxml2-dev libgsl-dev   

The cvcqv is available on github. To install it in R, use:

devtools::install_github('MaaniBeigy/cvcqv')  

* Currently, these tools are available:

nameis.R6..Description
CoefVarTRUECoefficient of Variation (cv)
CoefQuartVarTRUECoefficient of Quartile Variation (cqv)
CoefVarCITRUEConfidence Intervals for cv
CoefQuartVarCITRUEConfidence Intervals for cqv
SampleQuantilesTRUESample Quantiles
cv_versatileFALSECoefficient of Variation
cqv_versatileFALSECoefficient of Quartile Variation
BootCoefVarTRUEBootstrap Resampling for cv
BootCoefQuartVarTRUEBootstrap Resampling for cqv

* This package is inspired by dplyr, R6, SciView, boot, and MBESS.

Examples

Here, we want to observe all available confidence intervals for the cv of variable x:

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
)
results <- CoefVarCI$new(x, digits = 3)$all_ci()  # R6 class
# or alternatively: 
results <- cv_versatile(x, digits = 3, method = "all")  # functional programming

The results will be:

estlowerupperdescription
kelley57.77441.28797.894cv with Kelley 95% CI
mckay57.77441.441108.483cv with McKay 95% CI
miller57.77434.05381.495cv with Miller 95% CI
vangel57.77441.264105.426cv with Vangel 95% CI
mahmoudvand_hassani57.77443.47682.857cv with Mahmoudvand-Hassani 95% CI
equal_tailed57.77443.93784.383cv with Equal-Tailed 95% CI
shortest_length57.77442.01581.013cv with Shortest-Length 95% CI
normal_approximation57.77444.53385.272cv with Normal Approximation 95% CI
norm57.77438.79978.937cv with Normal Approximation Bootstrap 95% CI
basic57.77435.05578.167cv with Basic Bootstrap 95% CI
perc57.77438.87979.174cv with Bootstrap Percentile 95% CI
bca57.77440.80782.297cv with Adjusted Bootstrap Percentile (BCa) 95% CI

Next, we want to find all of the available confidence intervals for the cqv of variable x:

results <- CoefQuartVarCI$new(x, digits = 3)$all_ci()  # R6 class
# or alternatively:
results <- cqv_versatile(x, , digits = 3, method = "all")  # functional programming

The results will be:

estlowerupperdescription
bonett45.62524.78577.329cqv with Bonett CI
norm45.62519.95770.840cqv with normal approximation CI
basic45.62518.99273.917cqv with basic bootstrap CI
percent45.62517.12268.683cqv with bootstrap percentile CI
bca45.62524.27383.264cqv with adjusted bootstrap percentile (BCa) CI

Documentation

Download the cvcqv_1.0.0.tar.gz. Install the source package cvcqv from the Packages >> Install >> Package Archive File (.tar.gz) >> Browse >> cvcqv_1.0.0.tar.gz. Or run an installation code like:

install.packages("~/cvcqv_1.0.0.tar.gz", repos = NULL, type = "source")

Then, browse for vignettes:

browseVignettes("cvcqv")

Then, select html to show the vignette.

References

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: http://doi.org/10.1080/02664763.2013.847405

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

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

Copy Link

Version

Down Chevron

Install

install.packages('cvcqv')

Monthly Downloads

11

Version

1.0.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

August 6th, 2019

Functions in cvcqv (1.0.0)