cv {EnvStats}  R Documentation 
Sample Coefficient of Variation.
Description
Compute the sample coefficient of variation.
Usage
cv(x, method = "moments", sd.method = "sqrt.unbiased",
l.moment.method = "unbiased", plot.pos.cons = c(a = 0.35, b = 0),
na.rm = FALSE)
Arguments
x 
numeric vector of observations. 
method 
character string specifying what method to use to compute the sample coefficient
of variation. The possible values are 
sd.method 
character string specifying what method to use to compute the sample standard
deviation when 
l.moment.method 
character string specifying what method to use to compute the

plot.pos.cons 
numeric vector of length 2 specifying the constants used in the formula for
the plotting positions when 
na.rm 
logical scalar indicating whether to remove missing values from 
Details
Let \underline{x}
denote a random sample of n
observations from
some distribution with mean \mu
and standard deviation \sigma
.
Product Moment Coefficient of Variation (method="moments"
)
The coefficient of variation (sometimes denoted CV) of a distribution is
defined as the ratio of the standard deviation to the mean. That is:
CV = \frac{\sigma}{\mu} \;\;\;\;\;\; (1)
The coefficient of variation measures how spread out the distribution is relative to the size of the mean. It is usually used to characterize positive, rightskewed distributions such as the lognormal distribution.
When sd.method="sqrt.unbiased"
, the coefficient of variation is estimated
using the sample mean and the square root of the unbaised estimator of variance:
\widehat{CV} = \frac{s}{\bar{x}} \;\;\;\;\;\; (2)
where
\bar{x} = \frac{1}{n} \sum_{i=1}^n x_i \;\;\;\;\;\; (3)
s = [\frac{1}{n1} \sum_{i=1}^n (x_i  \bar{x})^2]^{1/2} \;\;\;\;\;\; (4)
Note that the estimator of standard deviation in equation (4) is not unbiased.
When sd.method="moments"
, the coefficient of variation is estimated using
the sample mean and the square root of the method of moments estimator of variance:
\widehat{CV} = \frac{s_m}{\bar{x}} \;\;\;\;\;\; (5)
s = [\frac{1}{n} \sum_{i=1}^n (x_i  \bar{x})^2]^{1/2} \;\;\;\;\;\; (6)
LMoment Coefficient of Variation (method="l.moments"
)
Hosking (1990) defines an L
moment analog of the
coefficient of variation (denoted the L
CV) as:
\tau = \frac{l_2}{l_1} \;\;\;\;\;\; (7)
that is, the second L
moment divided by the first L
moment.
He shows that for a positivevalued random variable, the L
CV lies in the
interval (0, 1).
When l.moment.method="unbiased"
, the L
CV is estimated by:
t = \frac{l_2}{l_1} \;\;\;\;\;\; (8)
that is, the unbiased estimator of the second L
moment divided by
the unbiased estimator of the first L
moment.
When l.moment.method="plotting.position"
, the L
CV is estimated by:
\tilde{t} = \frac{\tilde{l_2}}{\tilde{l_1}} \;\;\;\;\;\; (9)
that is, the plottingposition estimator of the second L
moment divided by
the plottingposition estimator of the first L
moment.
See the help file for lMoment
for more information on
estimating L
moments.
Value
A numeric scalar – the sample coefficient of variation.
Note
Traditionally, the coefficient of variation has been estimated using
product moment estimators. Hosking (1990) introduced the idea of
L
moments and the L
CV. Vogel and Fennessey (1993) argue that
L
moment ratios should replace product moment ratios because of their
superior performance (they are nearly unbiased and better for discriminating
between distributions).
Author(s)
Steven P. Millard (EnvStats@ProbStatInfo.com)
References
Berthouex, P.M., and L.C. Brown. (2002). Statistics for Environmental Engineers, Second Edition. Lewis Publishers, Boca Raton, FL.
Gilbert, R.O. (1987). Statistical Methods for Environmental Pollution Monitoring. Van Nostrand Reinhold, NY.
Ott, W.R. (1995). Environmental Statistics and Data Analysis. Lewis Publishers, Boca Raton, FL.
Taylor, J.K. (1990). Statistical Techniques for Data Analysis. Lewis Publishers, Boca Raton, FL.
Vogel, R.M., and N.M. Fennessey. (1993). L
Moment Diagrams Should Replace
Product Moment Diagrams. Water Resources Research 29(6), 1745–1752.
Zar, J.H. (2010). Biostatistical Analysis. Fifth Edition. PrenticeHall, Upper Saddle River, NJ.
See Also
Summary Statistics, summaryFull
, var
,
sd
, skewness
, kurtosis
.
Examples
# Generate 20 observations from a lognormal distribution with
# parameters mean=10 and cv=1, and estimate the coefficient of variation.
# (Note: the call to set.seed simply allows you to reproduce this example.)
set.seed(250)
dat < rlnormAlt(20, mean = 10, cv = 1)
cv(dat)
#[1] 0.5077981
cv(dat, sd.method = "moments")
#[1] 0.4949403
cv(dat, method = "l.moments")
#[1] 0.2804148
#
# Clean up
rm(dat)