Learn R Programming

multiColl (version 2.0)

CVs: Coeficients of Variation

Description

The function returns the Coeficient of Variation (CV) of a matrix with quantitative columns.

Usage

CVs(X, dummy = FALSE, pos = NULL)

Value

The CV of each column of X.

Arguments

X

A numeric design matrix that should contain more than one regressor (intercept included).

dummy

A logical value that indicates if there are dummy variables in the design matrix X. By default dummy=FALSE.

pos

A numeric vector that indicates the position of the dummy variables, if these exist, in the design matrix X. By default pos=NULL.

Author

R. Salmerón (romansg@ugr.es) and C. García (cbgarcia@ugr.es).

Details

Due to the calculation of the CV only makes sense for quantitative data, other kind of data should be ignored in the calculation. For this reason, it is necessary to indicate if there are non-quantitative variables and also its position in the matrix.

See Also

CV.

Examples

Run this code
# random

cte = array(1, 50)
x1 = sample(1:50, 25)
x2 = sample(1:50, 25)
Z = cbind(cte, x1, x2)
head(Z)
CVs(Z)

x3 = sample(c(array(1,25), array(0,25)), 25)
W = cbind(Z, x3)
head(W)
CVs(W, dummy=TRUE, pos = 4)

x0 = sample(c(array(1,25), array(0,25)), 25)
Y = cbind(cte, x0, x1, x2, x3)
head(Y)
CVs(Y, dummy=TRUE, pos=c(2,5))

Run the code above in your browser using DataLab