Factor for dissimilarity of mixed type data
Computes a factor that can be used to standardise ordinal categorical variables and binary dummy variables coding categories of nominal scaled variables for Euclidean dissimilarity computation in mixed type data. See Hennig and Liao (2013).
distancefactor(cat,n=NULL, catsizes=NULL,type="categorical", normfactor=2,qfactor=ifelse(type=="categorical",1/2, 1/(1+1/(cat-1))))
cat |
integer. Number of categories of the variable to be standardised.
Note that for |
n |
integer. Number of data points. |
catsizes |
vector of integers giving numbers of observations per
category. One of |
type |
|
normfactor |
numeric. Factor on which standardisation is based.
As a default, this is |
qfactor |
numeric. Factor q in Hennig and Liao (2013) to adjust for clumping effects due to discreteness. |
A factor by which to multiply the variable in order to make it
comparable to a unit variance continuous variable when aggregated in
Euclidean fashion for dissimilarity computation, so that expected
effective difference between two realisations of the variable equals
qfactor*normfactor
.
Hennig, C. and Liao, T. (2013) How to find an appropriate clustering for mixed-type variables with application to socio-economic stratification, Journal of the Royal Statistical Society, Series C Applied Statistics, 62, 309-369.
set.seed(776655) d1 <- sample(1:5,20,replace=TRUE) d2 <- sample(1:4,20,replace=TRUE) ldata <- cbind(d1,d2) lc <- cat2bin(ldata,categorical=1)$data lc[,1:5] <- lc[,1:5]*distancefactor(5,20,type="categorical") lc[,6] <- lc[,6]*distancefactor(4,20,type="ordinal")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.