Learn R Programming

sjmisc (version 1.8)

cv: 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
(Numeric) vector or a fitted linear model of class lm, merMod (lme4) or lme (nlme).
...
More fitted model objects, to compute multiple coefficients of variation at once.

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 (source: UCLA-FAQ).

References

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)
cv(fit)

Run the code above in your browser using DataLab