recodmix: Recoding mixed data

Description Usage Arguments Value References Examples

View source: R/recodmix.R

Description

This function transforms and scales a dataset with numerical and/or categorical variables. Numerical variables are scaled to zero mean and unit variance. Categorical variables are first transformed into dummy variables according to their levels, and second centered and normalized with respect to the square roots of the relative frequencies of the levels. The complete procedure is described in Chavent et al. (2014).

Usage

1
recodmix(X, renamelevel = FALSE)

Arguments

X

a matrix or a dataframe with numerical and/or categorical variables. Categorical variables must be given as factors.

renamelevel

a boolean. If TRUE (default value), the levels of the categorical variables are renamed as 'variable_name=level_name'.

Value

X

a data frame or a matrix. The input data X with reordered columns (numerical first, categorical second).

Z

a data frame. The transformed data matrix with scaled numerical variables and scaled dummy variables coding for the levels.

index

a vector of integers. Contains an implicit partitioning of the transformed variables: each scaled numerical variable represents a group, all scaled dummy variables summarizing the levels of a categorical variable represent a group. index allows to preserve the information on the initial structure of the data, particularly for categorical variables.

References

M. Chavent, V. Kuentz-Simonet, A. Labenne and J. Saracco (2014). Multivariate analysis of mixed data: the PCAmixdata R package, arXiv:1411.4911.

Examples

1
2
3
4
5
6
7
8
head(HDdata)
out <- recodmix(HDdata[,-14], renamelevel=TRUE)
# reordered data (numerical/categorical)
colnames(out$X)
# transformed and scaled data
colnames(out$Z)
# transformed variables partitioning and group membership
out$index

vimpclust documentation built on Jan. 8, 2021, 5:34 p.m.