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).

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.

“It is interesting to note the differences between a model's CV and R-squared values. Both are unitless measures that are indicative of model fit, but they define model fit in two different ways: CV evaluates the relative closeness of the predictions to the actual values while R-squared evaluates how much of the variability in the actual values is explained by the model.” (source: UCLA-FAQ)

References

Everitt, Brian (1998). The Cambridge Dictionary of Statistics. Cambridge, UK New York: Cambridge University Press

See also

Examples

data(efc) cv(efc$e17age)
#> [1] 0.1023027
fit <- lm(neg_c_7 ~ e42dep, data = efc) cv(fit)
#> [1] 0.3017953
library(lme4) fit <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy) cv(fit)
#> [1] 0.07851737
library(nlme)
#> #> Attaching package: ‘nlme’
#> The following object is masked from ‘package:lme4’: #> #> lmList
#> The following object is masked from ‘package:dplyr’: #> #> collapse
fit <- lme(Reaction ~ Days, random = ~ Days | Subject, data = sleepstudy) cv(fit)
#> [1] 0.07851744