Learn R Programming

sjmisc (version 1.0.2)

cv: Compute coefficient of variation

Description

Compute coefficient of variation for single variables (standard deviation divided by mean) or for fitted linear (mixed effects) models (root mean squared error (RMSE) divided by mean of dependent variable).

Usage

cv(x)

Arguments

x
a (numeric) vector / variable or a fitted linear model of class lm, merMod (lme4) or lme (nlme).

Value

  • The coefficient of variation of x.

Details

The advantage of the cv is that it is unitless. This allows coefficient of variation to be compared to each other in ways that other measures, like standard deviations or root mean squared residuals, cannot be (http://www.ats.ucla.edu/stat/mult_pkg/faq/general/coefficient_of_variation.htm{source: UCLA-FAQ}).

References

http://www.ats.ucla.edu/stat/mult_pkg/faq/general/coefficient_of_variation.htm{UCLA-FAQ: What is the coefficient of variation?}

See Also

rmse

Examples

Run this code
data(efc)
cv(efc$e17age)

fit <- lm(neg_c_7 ~ e42dep, data = efc)
cv(fit)

library(lme4)
fit <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
cv(fit)

library(nlme)
fit <- lme(distance ~ age, data = Orthodont) # random is ~ age
cv(fit)

Run the code above in your browser using DataLab